2004-10-21 msnyder <msnyder@redhat.com>
[deliverable/binutils-gdb.git] / gdb / ppcobsd-tdep.c
CommitLineData
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>. */
36struct 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
45void
46ppcobsd_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
71void
72ppcobsd_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
94struct 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
103static const struct regset *
104ppcobsd_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
114static void
115ppcobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
116{
117 /* OpenBSD uses SVR4-style shared libraries. */
118 set_gdbarch_in_solib_call_trampoline
119 (gdbarch, generic_in_solib_call_trampoline);
120 set_solib_svr4_fetch_link_map_offsets
121 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
122
123 set_gdbarch_regset_from_core_section
124 (gdbarch, ppcobsd_regset_from_core_section);
125}
126\f
127
128/* OpenBSD uses uses the traditional NetBSD core file format, even for
129 ports that use ELF. */
130#define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF
131
132static enum gdb_osabi
133ppcobsd_core_osabi_sniffer (bfd *abfd)
134{
135 if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
136 return GDB_OSABI_NETBSD_CORE;
137
138 return GDB_OSABI_UNKNOWN;
139}
140\f
141
142/* Provide a prototype to silence -Wmissing-prototypes. */
143void _initialize_ppcobsd_tdep (void);
144
145void
146_initialize_ppcobsd_tdep (void)
147{
148 /* BFD doesn't set a flavour for NetBSD style a.out core files. */
149 gdbarch_register_osabi_sniffer (bfd_arch_powerpc, bfd_target_unknown_flavour,
150 ppcobsd_core_osabi_sniffer);
151
152 gdbarch_register_osabi (bfd_arch_powerpc, 0, GDB_OSABI_OPENBSD_ELF,
153 ppcobsd_init_abi);
154
155 /* Avoid initializing the register offsets again if they were
156 already initailized by ppcobsd-nat.c. */
157 if (ppcobsd_reg_offsets.pc_offset == 0)
158 {
159 /* General-purpose registers. */
160 ppcobsd_reg_offsets.r0_offset = 0;
161 ppcobsd_reg_offsets.pc_offset = 384;
162 ppcobsd_reg_offsets.ps_offset = 388;
163 ppcobsd_reg_offsets.cr_offset = 392;
164 ppcobsd_reg_offsets.lr_offset = 396;
165 ppcobsd_reg_offsets.ctr_offset = 400;
166 ppcobsd_reg_offsets.xer_offset = 404;
167 ppcobsd_reg_offsets.mq_offset = 408;
168
169 /* Floating-point registers. */
170 ppcobsd_reg_offsets.f0_offset = 128;
171 ppcobsd_reg_offsets.fpscr_offset = -1;
172
173 /* AltiVec registers. */
174 ppcobsd_reg_offsets.vr0_offset = 0;
175 ppcobsd_reg_offsets.vscr_offset = 512;
176 ppcobsd_reg_offsets.vrsave_offset = 520;
177 }
178}
This page took 0.084845 seconds and 4 git commands to generate.