]>
Commit | Line | Data |
---|---|---|
d195bc9f MK |
1 | /* Target-dependent code for OpenBSD/powerpc. |
2 | ||
3 | Copyright 2004 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 2 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, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | #include "defs.h" | |
23 | #include "arch-utils.h" | |
24 | #include "osabi.h" | |
25 | #include "regcache.h" | |
26 | #include "regset.h" | |
383f0f5b | 27 | #include "gdb_assert.h" |
d195bc9f MK |
28 | |
29 | #include "gdb_string.h" | |
30 | ||
31 | #include "ppc-tdep.h" | |
32 | #include "ppcobsd-tdep.h" | |
33 | #include "solib-svr4.h" | |
34 | ||
35 | /* Register offsets from <machine/reg.h>. */ | |
36 | struct ppc_reg_offsets ppcobsd_reg_offsets; | |
37 | \f | |
38 | ||
39 | /* Core file support. */ | |
40 | ||
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. */ | |
44 | ||
45 | void | |
46 | ppcobsd_supply_gregset (const struct regset *regset, | |
47 | struct regcache *regcache, int regnum, | |
48 | const void *gregs, size_t len) | |
49 | { | |
383f0f5b JB |
50 | /* FIXME: jimb/2004-05-05: Some PPC variants don't have floating |
51 | point registers. Traditionally, GDB's register set has still | |
52 | listed the floating point registers for such machines, so this | |
53 | code is harmless. However, the new E500 port actually omits the | |
54 | floating point registers entirely from the register set --- they | |
55 | don't even have register numbers assigned to them. | |
56 | ||
57 | It's not clear to me how best to update this code, so this assert | |
58 | will alert the first person to encounter the OpenBSD/E500 | |
59 | combination to the problem. */ | |
60 | gdb_assert (ppc_floating_point_unit_p (current_gdbarch)); | |
61 | ||
d195bc9f MK |
62 | ppc_supply_gregset (regset, regcache, regnum, gregs, len); |
63 | ppc_supply_fpregset (regset, regcache, regnum, gregs, len); | |
64 | } | |
65 | ||
66 | /* Collect register REGNUM in the general-purpose register set | |
67 | REGSET. from register cache REGCACHE into the buffer specified by | |
68 | GREGS and LEN. If REGNUM is -1, do this for all registers in | |
69 | REGSET. */ | |
70 | ||
71 | void | |
72 | ppcobsd_collect_gregset (const struct regset *regset, | |
73 | const struct regcache *regcache, int regnum, | |
74 | void *gregs, size_t len) | |
75 | { | |
383f0f5b JB |
76 | /* FIXME: jimb/2004-05-05: Some PPC variants don't have floating |
77 | point registers. Traditionally, GDB's register set has still | |
78 | listed the floating point registers for such machines, so this | |
79 | code is harmless. However, the new E500 port actually omits the | |
80 | floating point registers entirely from the register set --- they | |
81 | don't even have register numbers assigned to them. | |
82 | ||
83 | It's not clear to me how best to update this code, so this assert | |
84 | will alert the first person to encounter the OpenBSD/E500 | |
85 | combination to the problem. */ | |
86 | gdb_assert (ppc_floating_point_unit_p (current_gdbarch)); | |
87 | ||
d195bc9f MK |
88 | ppc_collect_gregset (regset, regcache, regnum, gregs, len); |
89 | ppc_collect_fpregset (regset, regcache, regnum, gregs, len); | |
90 | } | |
91 | ||
92 | /* OpenBS/powerpc register set. */ | |
93 | ||
94 | struct regset ppcobsd_gregset = | |
95 | { | |
96 | &ppcobsd_reg_offsets, | |
97 | ppcobsd_supply_gregset | |
98 | }; | |
99 | ||
100 | /* Return the appropriate register set for the core section identified | |
101 | by SECT_NAME and SECT_SIZE. */ | |
102 | ||
103 | static const struct regset * | |
104 | ppcobsd_regset_from_core_section (struct gdbarch *gdbarch, | |
105 | const char *sect_name, size_t sect_size) | |
106 | { | |
107 | if (strcmp (sect_name, ".reg") == 0 && sect_size >= 412) | |
108 | return &ppcobsd_gregset; | |
109 | ||
110 | return NULL; | |
111 | } | |
112 | \f | |
113 | ||
114 | static void | |
115 | ppcobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | |
116 | { | |
117 | /* OpenBSD uses SVR4-style shared libraries. */ | |
d195bc9f MK |
118 | set_solib_svr4_fetch_link_map_offsets |
119 | (gdbarch, svr4_ilp32_fetch_link_map_offsets); | |
120 | ||
121 | set_gdbarch_regset_from_core_section | |
122 | (gdbarch, ppcobsd_regset_from_core_section); | |
123 | } | |
124 | \f | |
125 | ||
126 | /* OpenBSD uses uses the traditional NetBSD core file format, even for | |
127 | ports that use ELF. */ | |
128 | #define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF | |
129 | ||
130 | static enum gdb_osabi | |
131 | ppcobsd_core_osabi_sniffer (bfd *abfd) | |
132 | { | |
133 | if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0) | |
134 | return GDB_OSABI_NETBSD_CORE; | |
135 | ||
136 | return GDB_OSABI_UNKNOWN; | |
137 | } | |
138 | \f | |
139 | ||
140 | /* Provide a prototype to silence -Wmissing-prototypes. */ | |
141 | void _initialize_ppcobsd_tdep (void); | |
142 | ||
143 | void | |
144 | _initialize_ppcobsd_tdep (void) | |
145 | { | |
146 | /* BFD doesn't set a flavour for NetBSD style a.out core files. */ | |
147 | gdbarch_register_osabi_sniffer (bfd_arch_powerpc, bfd_target_unknown_flavour, | |
148 | ppcobsd_core_osabi_sniffer); | |
149 | ||
150 | gdbarch_register_osabi (bfd_arch_powerpc, 0, GDB_OSABI_OPENBSD_ELF, | |
151 | ppcobsd_init_abi); | |
152 | ||
153 | /* Avoid initializing the register offsets again if they were | |
154 | already initailized by ppcobsd-nat.c. */ | |
155 | if (ppcobsd_reg_offsets.pc_offset == 0) | |
156 | { | |
157 | /* General-purpose registers. */ | |
158 | ppcobsd_reg_offsets.r0_offset = 0; | |
159 | ppcobsd_reg_offsets.pc_offset = 384; | |
160 | ppcobsd_reg_offsets.ps_offset = 388; | |
161 | ppcobsd_reg_offsets.cr_offset = 392; | |
162 | ppcobsd_reg_offsets.lr_offset = 396; | |
163 | ppcobsd_reg_offsets.ctr_offset = 400; | |
164 | ppcobsd_reg_offsets.xer_offset = 404; | |
165 | ppcobsd_reg_offsets.mq_offset = 408; | |
166 | ||
167 | /* Floating-point registers. */ | |
168 | ppcobsd_reg_offsets.f0_offset = 128; | |
169 | ppcobsd_reg_offsets.fpscr_offset = -1; | |
170 | ||
171 | /* AltiVec registers. */ | |
172 | ppcobsd_reg_offsets.vr0_offset = 0; | |
173 | ppcobsd_reg_offsets.vscr_offset = 512; | |
174 | ppcobsd_reg_offsets.vrsave_offset = 520; | |
175 | } | |
176 | } |