1 /* Target-dependent code for OpenBSD/powerpc.
3 Copyright 2004 Free Software Foundation, Inc.
5 This file is part of GDB.
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 2 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 #include "arch-utils.h"
27 #include "gdb_assert.h"
29 #include "gdb_string.h"
32 #include "ppcobsd-tdep.h"
33 #include "solib-svr4.h"
35 /* Register offsets from <machine/reg.h>. */
36 struct ppc_reg_offsets ppcobsd_reg_offsets
;
39 /* Core file support. */
41 /* Supply register REGNUM in the general-purpose register set REGSET
42 from the buffer specified by GREGS and LEN to register cache
43 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
46 ppcobsd_supply_gregset (const struct regset
*regset
,
47 struct regcache
*regcache
, int regnum
,
48 const void *gregs
, size_t len
)
50 /* FIXME: jimb/2004-05-05: Some PPC variants don't have
51 floating-point registers. For such variants,
52 tdep->ppc_fp0_regnum and tdep->ppc_fpscr_regnum will be -1. I
53 don't think OpenBSD runs on any of those chips, but we can at
54 least make sure that if someone tries it, they'll get a proper
56 gdb_assert (ppc_floating_point_unit_p (current_gdbarch
));
58 ppc_supply_gregset (regset
, regcache
, regnum
, gregs
, len
);
59 ppc_supply_fpregset (regset
, regcache
, regnum
, gregs
, len
);
62 /* Collect register REGNUM in the general-purpose register set
63 REGSET. from register cache REGCACHE into the buffer specified by
64 GREGS and LEN. If REGNUM is -1, do this for all registers in
68 ppcobsd_collect_gregset (const struct regset
*regset
,
69 const struct regcache
*regcache
, int regnum
,
70 void *gregs
, size_t len
)
72 /* FIXME: jimb/2004-05-05: Some PPC variants don't have
73 floating-point registers. For such variants,
74 tdep->ppc_fp0_regnum and tdep->ppc_fpscr_regnum will be -1. I
75 don't think OpenBSD runs on any of those chips, but we can at
76 least make sure that if someone tries it, they'll get a proper
78 gdb_assert (ppc_floating_point_unit_p (current_gdbarch
));
80 ppc_collect_gregset (regset
, regcache
, regnum
, gregs
, len
);
81 ppc_collect_fpregset (regset
, regcache
, regnum
, gregs
, len
);
84 /* OpenBS/powerpc register set. */
86 struct regset ppcobsd_gregset
=
89 ppcobsd_supply_gregset
92 /* Return the appropriate register set for the core section identified
93 by SECT_NAME and SECT_SIZE. */
95 static const struct regset
*
96 ppcobsd_regset_from_core_section (struct gdbarch
*gdbarch
,
97 const char *sect_name
, size_t sect_size
)
99 if (strcmp (sect_name
, ".reg") == 0 && sect_size
>= 412)
100 return &ppcobsd_gregset
;
107 ppcobsd_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
109 /* OpenBSD uses SVR4-style shared libraries. */
110 set_gdbarch_in_solib_call_trampoline
111 (gdbarch
, generic_in_solib_call_trampoline
);
112 set_solib_svr4_fetch_link_map_offsets
113 (gdbarch
, svr4_ilp32_fetch_link_map_offsets
);
115 set_gdbarch_regset_from_core_section
116 (gdbarch
, ppcobsd_regset_from_core_section
);
120 /* OpenBSD uses uses the traditional NetBSD core file format, even for
121 ports that use ELF. */
122 #define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF
124 static enum gdb_osabi
125 ppcobsd_core_osabi_sniffer (bfd
*abfd
)
127 if (strcmp (bfd_get_target (abfd
), "netbsd-core") == 0)
128 return GDB_OSABI_NETBSD_CORE
;
130 return GDB_OSABI_UNKNOWN
;
134 /* Provide a prototype to silence -Wmissing-prototypes. */
135 void _initialize_ppcobsd_tdep (void);
138 _initialize_ppcobsd_tdep (void)
140 /* BFD doesn't set a flavour for NetBSD style a.out core files. */
141 gdbarch_register_osabi_sniffer (bfd_arch_powerpc
, bfd_target_unknown_flavour
,
142 ppcobsd_core_osabi_sniffer
);
144 gdbarch_register_osabi (bfd_arch_powerpc
, 0, GDB_OSABI_OPENBSD_ELF
,
147 /* Avoid initializing the register offsets again if they were
148 already initailized by ppcobsd-nat.c. */
149 if (ppcobsd_reg_offsets
.pc_offset
== 0)
151 /* General-purpose registers. */
152 ppcobsd_reg_offsets
.r0_offset
= 0;
153 ppcobsd_reg_offsets
.pc_offset
= 384;
154 ppcobsd_reg_offsets
.ps_offset
= 388;
155 ppcobsd_reg_offsets
.cr_offset
= 392;
156 ppcobsd_reg_offsets
.lr_offset
= 396;
157 ppcobsd_reg_offsets
.ctr_offset
= 400;
158 ppcobsd_reg_offsets
.xer_offset
= 404;
159 ppcobsd_reg_offsets
.mq_offset
= 408;
161 /* Floating-point registers. */
162 ppcobsd_reg_offsets
.f0_offset
= 128;
163 ppcobsd_reg_offsets
.fpscr_offset
= -1;
165 /* AltiVec registers. */
166 ppcobsd_reg_offsets
.vr0_offset
= 0;
167 ppcobsd_reg_offsets
.vscr_offset
= 512;
168 ppcobsd_reg_offsets
.vrsave_offset
= 520;