Change tui_update_locator_fullname to take a symtab
[deliverable/binutils-gdb.git] / gdb / sparc64-nbsd-nat.c
CommitLineData
386c036b
MK
1/* Native-dependent code for NetBSD/sparc64.
2
42a4f53d 3 Copyright (C) 2003-2019 Free Software Foundation, Inc.
9ce5c36a
JT
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
9ce5c36a
JT
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
9ce5c36a
JT
19
20#include "defs.h"
6df5070e 21#include "gdbcore.h"
90f3cecd 22#include "regcache.h"
1b9445c2 23#include "target.h"
9ce5c36a 24
386c036b
MK
25#include "sparc64-tdep.h"
26#include "sparc-nat.h"
9ce5c36a 27
386c036b
MK
28/* NetBSD is different from the other OSes that support both SPARC and
29 UltraSPARC in that the result of ptrace(2) depends on whether the
30 traced process is 32-bit or 64-bit. */
9ce5c36a 31
386c036b 32static void
b4fd25c9 33sparc64nbsd_supply_gregset (const struct sparc_gregmap *gregmap,
386c036b
MK
34 struct regcache *regcache,
35 int regnum, const void *gregs)
36{
ac7936df 37 int sparc32 = (gdbarch_ptr_bit (regcache->arch ()) == 32);
9ce5c36a 38
386c036b 39 if (sparc32)
b4fd25c9 40 sparc32_supply_gregset (&sparc32nbsd_gregmap, regcache, regnum, gregs);
386c036b 41 else
b4fd25c9 42 sparc64_supply_gregset (&sparc64nbsd_gregmap, regcache, regnum, gregs);
386c036b
MK
43}
44
45static void
b4fd25c9 46sparc64nbsd_collect_gregset (const struct sparc_gregmap *gregmap,
386c036b
MK
47 const struct regcache *regcache,
48 int regnum, void *gregs)
49{
ac7936df 50 int sparc32 = (gdbarch_ptr_bit (regcache->arch ()) == 32);
386c036b
MK
51
52 if (sparc32)
b4fd25c9 53 sparc32_collect_gregset (&sparc32nbsd_gregmap, regcache, regnum, gregs);
386c036b 54 else
b4fd25c9 55 sparc64_collect_gregset (&sparc64nbsd_gregmap, regcache, regnum, gregs);
386c036b
MK
56}
57
58static void
b4fd25c9 59sparc64nbsd_supply_fpregset (const struct sparc_fpregmap *fpregmap,
db75c717 60 struct regcache *regcache,
386c036b
MK
61 int regnum, const void *fpregs)
62{
ac7936df 63 int sparc32 = (gdbarch_ptr_bit (regcache->arch ()) == 32);
386c036b
MK
64
65 if (sparc32)
b4fd25c9 66 sparc32_supply_fpregset (&sparc32_bsd_fpregmap, regcache, regnum, fpregs);
386c036b 67 else
b4fd25c9 68 sparc64_supply_fpregset (&sparc64_bsd_fpregmap, regcache, regnum, fpregs);
386c036b
MK
69}
70
71static void
b4fd25c9 72sparc64nbsd_collect_fpregset (const struct sparc_fpregmap *fpregmap,
8507e05d 73 const struct regcache *regcache,
386c036b 74 int regnum, void *fpregs)
9ce5c36a 75{
ac7936df 76 int sparc32 = (gdbarch_ptr_bit (regcache->arch ()) == 32);
386c036b
MK
77
78 if (sparc32)
b4fd25c9 79 sparc32_collect_fpregset (&sparc32_bsd_fpregmap, regcache, regnum, fpregs);
386c036b 80 else
b4fd25c9 81 sparc64_collect_fpregset (&sparc64_bsd_fpregmap, regcache, regnum, fpregs);
9ce5c36a
JT
82}
83
386c036b
MK
84/* Determine whether `gregset_t' contains register REGNUM. */
85
9ce5c36a 86static int
ec22ec34 87sparc64nbsd_gregset_supplies_p (struct gdbarch *gdbarch, int regnum)
9ce5c36a 88{
ec22ec34
UW
89 if (gdbarch_ptr_bit (gdbarch) == 32)
90 return sparc32_gregset_supplies_p (gdbarch, regnum);
386c036b
MK
91
92 /* Integer registers. */
93 if ((regnum >= SPARC_G1_REGNUM && regnum <= SPARC_G7_REGNUM)
94 || (regnum >= SPARC_O0_REGNUM && regnum <= SPARC_O7_REGNUM)
95 || (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_L7_REGNUM)
96 || (regnum >= SPARC_I0_REGNUM && regnum <= SPARC_I7_REGNUM))
97 return 1;
98
99 /* Control registers. */
100 if (regnum == SPARC64_PC_REGNUM
101 || regnum == SPARC64_NPC_REGNUM
102 || regnum == SPARC64_STATE_REGNUM
103 || regnum == SPARC64_Y_REGNUM)
104 return 1;
105
106 return 0;
9ce5c36a
JT
107}
108
386c036b
MK
109/* Determine whether `fpregset_t' contains register REGNUM. */
110
111static int
ec22ec34 112sparc64nbsd_fpregset_supplies_p (struct gdbarch *gdbarch, int regnum)
9ce5c36a 113{
ec22ec34
UW
114 if (gdbarch_ptr_bit (gdbarch) == 32)
115 return sparc32_fpregset_supplies_p (gdbarch, regnum);
386c036b
MK
116
117 /* Floating-point registers. */
118 if ((regnum >= SPARC_F0_REGNUM && regnum <= SPARC_F31_REGNUM)
119 || (regnum >= SPARC64_F32_REGNUM && regnum <= SPARC64_F62_REGNUM))
120 return 1;
121
122 /* Control registers. */
123 if (regnum == SPARC64_FSR_REGNUM)
124 return 1;
125
126 return 0;
9ce5c36a 127}
90f3cecd
MK
128\f
129
130/* Support for debugging kernel virtual memory images. */
131
132#include <sys/types.h>
133#include <machine/pcb.h>
134
135#include "bsd-kvm.h"
136
137static int
138sparc64nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
139{
6df5070e 140 u_int64_t state;
90f3cecd
MK
141 int regnum;
142
143 /* The following is true for NetBSD 1.6.2:
144
e5a6ba44
MK
145 The pcb contains %sp and %pc, %pstate and %cwp. From this
146 information we reconstruct the register state as it would look
147 when we just returned from cpu_switch(). */
90f3cecd
MK
148
149 /* The stack pointer shouldn't be zero. */
150 if (pcb->pcb_sp == 0)
151 return 0;
152
6df5070e
MK
153 /* If the program counter is zero, this is probably a core dump, and
154 we can get %pc from the stack. */
155 if (pcb->pcb_pc == 0)
156 read_memory(pcb->pcb_sp + BIAS - 176 + (11 * 8),
157 (gdb_byte *)&pcb->pcb_pc, sizeof pcb->pcb_pc);
158
73e1c03f
SM
159 regcache->raw_supply (SPARC_SP_REGNUM, &pcb->pcb_sp);
160 regcache->raw_supply (SPARC64_PC_REGNUM, &pcb->pcb_pc);
90f3cecd 161
6df5070e 162 state = pcb->pcb_pstate << 8 | pcb->pcb_cwp;
73e1c03f 163 regcache->raw_supply (SPARC64_STATE_REGNUM, &state);
6df5070e 164
90f3cecd
MK
165 sparc_supply_rwindow (regcache, pcb->pcb_sp, -1);
166
167 return 1;
168}
9ce5c36a 169
f6ac5f3d
PA
170/* We've got nothing to add to the generic SPARC target. */
171static sparc_target<inf_ptrace_target> the_sparc64_nbsd_nat_target;
172
9ce5c36a 173void
90f3cecd 174_initialize_sparc64nbsd_nat (void)
9ce5c36a 175{
386c036b
MK
176 sparc_supply_gregset = sparc64nbsd_supply_gregset;
177 sparc_collect_gregset = sparc64nbsd_collect_gregset;
178 sparc_supply_fpregset = sparc64nbsd_supply_fpregset;
179 sparc_collect_fpregset = sparc64nbsd_collect_fpregset;
180 sparc_gregset_supplies_p = sparc64nbsd_gregset_supplies_p;
181 sparc_fpregset_supplies_p = sparc64nbsd_fpregset_supplies_p;
90f3cecd 182
d9f719f1 183 add_inf_child_target (&the_sparc64_nbsd_nat_target);
1b9445c2 184
90f3cecd
MK
185 /* Support debugging kernel virtual memory images. */
186 bsd_kvm_add_target (sparc64nbsd_supply_pcb);
9ce5c36a 187}
This page took 1.862243 seconds and 4 git commands to generate.