GDB (xrefs)
Loading...
Searching...
No Matches
sparc64-netbsd-nat.c
Go to the documentation of this file.
1/* Native-dependent code for NetBSD/sparc64.
2
3 Copyright (C) 2003-2023 Free Software Foundation, Inc.
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
9 the Free Software Foundation; either version 3 of the License, or
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
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#include "defs.h"
21#include "gdbcore.h"
22#include "regcache.h"
23#include "target.h"
24
25#include "sparc64-tdep.h"
26#include "sparc-nat.h"
27
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. */
31
32static void
34 struct regcache *regcache,
35 int regnum, const void *gregs)
36{
37 int sparc32 = (gdbarch_ptr_bit (regcache->arch ()) == 32);
38
39 if (sparc32)
41 else
43}
44
45static void
47 const struct regcache *regcache,
48 int regnum, void *gregs)
49{
50 int sparc32 = (gdbarch_ptr_bit (regcache->arch ()) == 32);
51
52 if (sparc32)
54 else
56}
57
58static void
60 struct regcache *regcache,
61 int regnum, const void *fpregs)
62{
63 int sparc32 = (gdbarch_ptr_bit (regcache->arch ()) == 32);
64
65 if (sparc32)
67 else
69}
70
71static void
73 const struct regcache *regcache,
74 int regnum, void *fpregs)
75{
76 int sparc32 = (gdbarch_ptr_bit (regcache->arch ()) == 32);
77
78 if (sparc32)
80 else
82}
83
84/* Determine whether `gregset_t' contains register REGNUM. */
85
86static int
88{
89 if (gdbarch_ptr_bit (gdbarch) == 32)
91
92 /* Integer registers. */
97 return 1;
98
99 /* Control registers. */
104 return 1;
105
106 return 0;
107}
108
109/* Determine whether `fpregset_t' contains register REGNUM. */
110
111static int
113{
114 if (gdbarch_ptr_bit (gdbarch) == 32)
116
117 /* Floating-point registers. */
120 return 1;
121
122 /* Control registers. */
124 return 1;
125
126 return 0;
127}
128
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{
140 u_int64_t state;
141 int regnum;
142
143 /* The following is true for NetBSD 1.6.2:
144
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(). */
148
149 /* The stack pointer shouldn't be zero. */
150 if (pcb->pcb_sp == 0)
151 return 0;
152
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
159 regcache->raw_supply (SPARC_SP_REGNUM, &pcb->pcb_sp);
160 regcache->raw_supply (SPARC64_PC_REGNUM, &pcb->pcb_pc);
161
162 state = pcb->pcb_pstate << 8 | pcb->pcb_cwp;
164
165 sparc_supply_rwindow (regcache, pcb->pcb_sp, -1);
166
167 return 1;
168}
169
170/* We've got nothing to add to the generic SPARC target. */
172
174void
int regnum
void bsd_kvm_add_target(int(*supply_pcb)(struct regcache *, struct pcb *))
Definition bsd-kvm.c:380
gdbarch * arch() const
Definition regcache.c:231
void raw_supply(int regnum, const void *buf) override
Definition regcache.c:1062
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition corefile.c:238
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
Definition gdbarch.c:1722
void add_inf_child_target(inf_child_target *target)
Definition inf-child.c:418
int sparc32_fpregset_supplies_p(struct gdbarch *gdbarch, int regnum)
Definition sparc-nat.c:133
int(* sparc_fpregset_supplies_p)(struct gdbarch *, int)
Definition sparc-nat.c:106
int sparc32_gregset_supplies_p(struct gdbarch *gdbarch, int regnum)
Definition sparc-nat.c:111
int(* sparc_gregset_supplies_p)(struct gdbarch *, int)
Definition sparc-nat.c:105
const struct sparc_gregmap sparc32nbsd_gregmap
#define sparc_supply_fpregset
#define sparc_supply_gregset
#define sparc_collect_fpregset
#define sparc_collect_gregset
void sparc_supply_rwindow(struct regcache *regcache, CORE_ADDR sp, int regnum)
void sparc32_supply_gregset(const struct sparc_gregmap *gregmap, struct regcache *regcache, int regnum, const void *gregs)
#define BIAS
Definition sparc-tdep.c:68
const struct sparc_fpregmap sparc32_bsd_fpregmap
void sparc32_supply_fpregset(const struct sparc_fpregmap *fpregmap, struct regcache *regcache, int regnum, const void *fpregs)
void sparc32_collect_fpregset(const struct sparc_fpregmap *fpregmap, const struct regcache *regcache, int regnum, void *fpregs)
void sparc32_collect_gregset(const struct sparc_gregmap *gregmap, const struct regcache *regcache, int regnum, void *gregs)
@ SPARC_O0_REGNUM
Definition sparc-tdep.h:112
@ SPARC_G1_REGNUM
Definition sparc-tdep.h:105
@ SPARC_L0_REGNUM
Definition sparc-tdep.h:120
@ SPARC_I0_REGNUM
Definition sparc-tdep.h:128
@ SPARC_G7_REGNUM
Definition sparc-tdep.h:111
@ SPARC_F0_REGNUM
Definition sparc-tdep.h:136
@ SPARC_L7_REGNUM
Definition sparc-tdep.h:127
@ SPARC_I7_REGNUM
Definition sparc-tdep.h:135
@ SPARC_F31_REGNUM
Definition sparc-tdep.h:144
@ SPARC_O7_REGNUM
Definition sparc-tdep.h:119
@ SPARC_SP_REGNUM
Definition sparc-tdep.h:118
static void sparc64nbsd_supply_fpregset(const struct sparc_fpregmap *fpregmap, struct regcache *regcache, int regnum, const void *fpregs)
static void sparc64nbsd_supply_gregset(const struct sparc_gregmap *gregmap, struct regcache *regcache, int regnum, const void *gregs)
static int sparc64nbsd_supply_pcb(struct regcache *regcache, struct pcb *pcb)
static int sparc64nbsd_fpregset_supplies_p(struct gdbarch *gdbarch, int regnum)
void _initialize_sparc64nbsd_nat()
static int sparc64nbsd_gregset_supplies_p(struct gdbarch *gdbarch, int regnum)
static void sparc64nbsd_collect_fpregset(const struct sparc_fpregmap *fpregmap, const struct regcache *regcache, int regnum, void *fpregs)
static sparc_target< inf_ptrace_target > the_sparc64_nbsd_nat_target
static void sparc64nbsd_collect_gregset(const struct sparc_gregmap *gregmap, const struct regcache *regcache, int regnum, void *gregs)
const struct sparc_gregmap sparc64nbsd_gregmap
void sparc64_supply_gregset(const struct sparc_gregmap *gregmap, struct regcache *regcache, int regnum, const void *gregs)
void sparc64_supply_fpregset(const struct sparc_fpregmap *fpregmap, struct regcache *regcache, int regnum, const void *fpregs)
void sparc64_collect_fpregset(const struct sparc_fpregmap *fpregmap, const struct regcache *regcache, int regnum, void *fpregs)
const struct sparc_fpregmap sparc64_bsd_fpregmap
void sparc64_collect_gregset(const struct sparc_gregmap *gregmap, const struct regcache *regcache, int regnum, void *gregs)
@ SPARC64_FSR_REGNUM
@ SPARC64_Y_REGNUM
@ SPARC64_PC_REGNUM
@ SPARC64_F32_REGNUM
@ SPARC64_NPC_REGNUM
@ SPARC64_STATE_REGNUM
@ SPARC64_F62_REGNUM