GDB (xrefs)
Loading...
Searching...
No Matches
ppc-netbsd-tdep.c
Go to the documentation of this file.
1/* Target-dependent code for NetBSD/powerpc.
2
3 Copyright (C) 2002-2023 Free Software Foundation, Inc.
4
5 Contributed by Wasabi Systems, Inc.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22#include "defs.h"
23#include "gdbtypes.h"
24#include "osabi.h"
25#include "regcache.h"
26#include "regset.h"
27#include "trad-frame.h"
28#include "tramp-frame.h"
29
30#include "ppc-tdep.h"
31#include "netbsd-tdep.h"
32#include "ppc-tdep.h"
33#include "solib-svr4.h"
34
35/* Register offsets from <machine/reg.h>. */
37
38
39/* Core file support. */
40
41/* NetBSD/powerpc register sets. */
42
48
54
55/* Iterate over core file register note sections. */
56
57static void
60 void *cb_data,
61 const struct regcache *regcache)
62{
63 cb (".reg", 148, 148, &ppcnbsd_gregset, NULL, cb_data);
64 cb (".reg2", 264, 264, &ppcnbsd_fpregset, NULL, cb_data);
65}
66
67
68/* NetBSD is confused. It appears that 1.5 was using the correct SVR4
69 convention but, 1.6 switched to the below broken convention. For
70 the moment use the broken convention. Ulgh! */
71
73ppcnbsd_return_value (struct gdbarch *gdbarch, struct value *function,
74 struct type *valtype, struct regcache *regcache,
75 gdb_byte *readbuf, const gdb_byte *writebuf)
76{
77#if 0
78 if ((valtype->code () == TYPE_CODE_STRUCT
79 || valtype->code () == TYPE_CODE_UNION)
80 && !((valtype->length () == 16 || valtype->length () == 8)
81 && valtype->is_vector ())
82 && !(valtype->length () == 1
83 || valtype->length () == 2
84 || valtype->length () == 4
85 || valtype->length () == 8))
87 else
88#endif
89 return ppc_sysv_abi_broken_return_value (gdbarch, function, valtype,
90 regcache, readbuf, writebuf);
91}
92
93
94/* Signal trampolines. */
95
96extern const struct tramp_frame ppcnbsd2_sigtramp;
97
98static void
100 frame_info_ptr this_frame,
101 struct trad_frame_cache *this_cache,
102 CORE_ADDR func)
103{
104 struct gdbarch *gdbarch = get_frame_arch (this_frame);
105 ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
106 CORE_ADDR addr, base;
107 int i;
108
109 base = get_frame_register_unsigned (this_frame,
111 if (self == &ppcnbsd2_sigtramp)
112 addr = base + 0x10 + 2 * tdep->wordsize;
113 else
114 addr = base + 0x18 + 2 * tdep->wordsize;
115 for (i = 0; i < ppc_num_gprs; i++, addr += tdep->wordsize)
116 {
117 int regnum = i + tdep->ppc_gp0_regnum;
118 trad_frame_set_reg_addr (this_cache, regnum, addr);
119 }
120 trad_frame_set_reg_addr (this_cache, tdep->ppc_lr_regnum, addr);
121 addr += tdep->wordsize;
122 trad_frame_set_reg_addr (this_cache, tdep->ppc_cr_regnum, addr);
123 addr += tdep->wordsize;
124 trad_frame_set_reg_addr (this_cache, tdep->ppc_xer_regnum, addr);
125 addr += tdep->wordsize;
126 trad_frame_set_reg_addr (this_cache, tdep->ppc_ctr_regnum, addr);
127 addr += tdep->wordsize;
129 addr); /* SRR0? */
130 addr += tdep->wordsize;
131
132 /* Construct the frame ID using the function start. */
133 trad_frame_set_id (this_cache, frame_id_build (base, func));
134}
135
136static const struct tramp_frame ppcnbsd_sigtramp =
137{
139 4,
140 {
141 { 0x3821fff0, ULONGEST_MAX }, /* add r1,r1,-16 */
142 { 0x4e800021, ULONGEST_MAX }, /* blrl */
143 { 0x38610018, ULONGEST_MAX }, /* addi r3,r1,24 */
144 { 0x38000127, ULONGEST_MAX }, /* li r0,295 */
145 { 0x44000002, ULONGEST_MAX }, /* sc */
146 { 0x38000001, ULONGEST_MAX }, /* li r0,1 */
147 { 0x44000002, ULONGEST_MAX }, /* sc */
148 { TRAMP_SENTINEL_INSN, ULONGEST_MAX }
149 },
151};
152
153/* NetBSD 2.0 introduced a slightly different signal trampoline. */
154
156{
158 4,
159 {
160 { 0x3821fff0, ULONGEST_MAX }, /* add r1,r1,-16 */
161 { 0x4e800021, ULONGEST_MAX }, /* blrl */
162 { 0x38610010, ULONGEST_MAX }, /* addi r3,r1,16 */
163 { 0x38000127, ULONGEST_MAX }, /* li r0,295 */
164 { 0x44000002, ULONGEST_MAX }, /* sc */
165 { 0x38000001, ULONGEST_MAX }, /* li r0,1 */
166 { 0x44000002, ULONGEST_MAX }, /* sc */
167 { TRAMP_SENTINEL_INSN, ULONGEST_MAX }
168 },
170};
171
172
173static void
175 struct gdbarch *gdbarch)
176{
177 nbsd_init_abi (info, gdbarch);
178
179 /* For NetBSD, this is an on again, off again thing. Some systems
180 do use the broken struct convention, and some don't. */
182
183 /* NetBSD uses SVR4-style shared libraries. */
186
189
192}
193
195void
197{
198 gdbarch_register_osabi (bfd_arch_powerpc, 0, GDB_OSABI_NETBSD,
200
201 /* Avoid initializing the register offsets again if they were
202 already initialized by ppc-netbsd-nat.c. */
204 {
205 /* General-purpose registers. */
216
217 /* Floating-point registers. */
221
222 }
223}
int regnum
return_value_convention
Definition defs.h:257
@ RETURN_VALUE_STRUCT_CONVENTION
Definition defs.h:267
ULONGEST get_frame_register_unsigned(frame_info_ptr frame, int regnum)
Definition frame.c:1399
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition frame.c:736
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
Definition frame.c:3027
@ SIGTRAMP_FRAME
Definition frame.h:198
int gdbarch_pc_regnum(struct gdbarch *gdbarch)
Definition gdbarch.c:2054
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype *return_value)
int gdbarch_sp_regnum(struct gdbarch *gdbarch)
Definition gdbarch.c:2037
void set_gdbarch_iterate_over_regset_sections(struct gdbarch *gdbarch, gdbarch_iterate_over_regset_sections_ftype *iterate_over_regset_sections)
void iterate_over_regset_sections_cb(const char *sect_name, int supply_size, int collect_size, const struct regset *regset, const char *human_name, void *cb_data)
Definition gdbarch.h:104
void nbsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
void gdbarch_register_osabi(enum bfd_architecture arch, unsigned long machine, enum gdb_osabi osabi, void(*init_osabi)(struct gdbarch_info, struct gdbarch *))
Definition osabi.c:146
@ GDB_OSABI_NETBSD
Definition osabi.h:34
static void ppcnbsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
const struct regset ppcnbsd_gregset
static ppc_reg_offsets ppcnbsd_reg_offsets
const struct tramp_frame ppcnbsd2_sigtramp
const struct regset ppcnbsd_fpregset
static const struct tramp_frame ppcnbsd_sigtramp
static void ppcnbsd_iterate_over_regset_sections(struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache)
void _initialize_ppcnbsd_tdep()
static void ppcnbsd_sigtramp_cache_init(const struct tramp_frame *self, frame_info_ptr this_frame, struct trad_frame_cache *this_cache, CORE_ADDR func)
static enum return_value_convention ppcnbsd_return_value(struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
enum return_value_convention ppc_sysv_abi_broken_return_value(struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
void ppc_supply_fpregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *fpregs, size_t len)
void ppc_supply_gregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len)
@ ppc_num_gprs
Definition ppc-tdep.h:318
void(* func)(remote_target *remote, char *)
void set_solib_svr4_fetch_link_map_offsets(struct gdbarch *gdbarch, struct link_map_offsets *(*flmo)(void))
struct link_map_offsets * svr4_ilp32_fetch_link_map_offsets(void)
type_code code() const
Definition gdbtypes.h:956
ULONGEST length() const
Definition gdbtypes.h:983
bool is_vector() const
Definition gdbtypes.h:1186
Definition value.h:130
void trad_frame_set_reg_addr(struct trad_frame_cache *this_trad_cache, int regnum, CORE_ADDR addr)
Definition trad-frame.c:110
void trad_frame_set_id(struct trad_frame_cache *this_trad_cache, struct frame_id this_id)
Definition trad-frame.c:220
void tramp_frame_prepend_unwinder(struct gdbarch *gdbarch, const struct tramp_frame *tramp_frame)
#define TRAMP_SENTINEL_INSN
Definition tramp-frame.h:44