2004-05-08 Andrew Cagney <cagney@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"
27
28#include "gdb_string.h"
29
30#include "ppc-tdep.h"
31#include "ppcobsd-tdep.h"
32#include "solib-svr4.h"
33
34/* Register offsets from <machine/reg.h>. */
35struct ppc_reg_offsets ppcobsd_reg_offsets;
36\f
37
38/* Core file support. */
39
40/* Supply register REGNUM in the general-purpose register set REGSET
41 from the buffer specified by GREGS and LEN to register cache
42 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
43
44void
45ppcobsd_supply_gregset (const struct regset *regset,
46 struct regcache *regcache, int regnum,
47 const void *gregs, size_t len)
48{
49 ppc_supply_gregset (regset, regcache, regnum, gregs, len);
50 ppc_supply_fpregset (regset, regcache, regnum, gregs, len);
51}
52
53/* Collect register REGNUM in the general-purpose register set
54 REGSET. from register cache REGCACHE into the buffer specified by
55 GREGS and LEN. If REGNUM is -1, do this for all registers in
56 REGSET. */
57
58void
59ppcobsd_collect_gregset (const struct regset *regset,
60 const struct regcache *regcache, int regnum,
61 void *gregs, size_t len)
62{
63 ppc_collect_gregset (regset, regcache, regnum, gregs, len);
64 ppc_collect_fpregset (regset, regcache, regnum, gregs, len);
65}
66
67/* OpenBS/powerpc register set. */
68
69struct regset ppcobsd_gregset =
70{
71 &ppcobsd_reg_offsets,
72 ppcobsd_supply_gregset
73};
74
75/* Return the appropriate register set for the core section identified
76 by SECT_NAME and SECT_SIZE. */
77
78static const struct regset *
79ppcobsd_regset_from_core_section (struct gdbarch *gdbarch,
80 const char *sect_name, size_t sect_size)
81{
82 if (strcmp (sect_name, ".reg") == 0 && sect_size >= 412)
83 return &ppcobsd_gregset;
84
85 return NULL;
86}
87\f
88
89static void
90ppcobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
91{
92 /* OpenBSD uses SVR4-style shared libraries. */
93 set_gdbarch_in_solib_call_trampoline
94 (gdbarch, generic_in_solib_call_trampoline);
95 set_solib_svr4_fetch_link_map_offsets
96 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
97
98 set_gdbarch_regset_from_core_section
99 (gdbarch, ppcobsd_regset_from_core_section);
100}
101\f
102
103/* OpenBSD uses uses the traditional NetBSD core file format, even for
104 ports that use ELF. */
105#define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF
106
107static enum gdb_osabi
108ppcobsd_core_osabi_sniffer (bfd *abfd)
109{
110 if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
111 return GDB_OSABI_NETBSD_CORE;
112
113 return GDB_OSABI_UNKNOWN;
114}
115\f
116
117/* Provide a prototype to silence -Wmissing-prototypes. */
118void _initialize_ppcobsd_tdep (void);
119
120void
121_initialize_ppcobsd_tdep (void)
122{
123 /* BFD doesn't set a flavour for NetBSD style a.out core files. */
124 gdbarch_register_osabi_sniffer (bfd_arch_powerpc, bfd_target_unknown_flavour,
125 ppcobsd_core_osabi_sniffer);
126
127 gdbarch_register_osabi (bfd_arch_powerpc, 0, GDB_OSABI_OPENBSD_ELF,
128 ppcobsd_init_abi);
129
130 /* Avoid initializing the register offsets again if they were
131 already initailized by ppcobsd-nat.c. */
132 if (ppcobsd_reg_offsets.pc_offset == 0)
133 {
134 /* General-purpose registers. */
135 ppcobsd_reg_offsets.r0_offset = 0;
136 ppcobsd_reg_offsets.pc_offset = 384;
137 ppcobsd_reg_offsets.ps_offset = 388;
138 ppcobsd_reg_offsets.cr_offset = 392;
139 ppcobsd_reg_offsets.lr_offset = 396;
140 ppcobsd_reg_offsets.ctr_offset = 400;
141 ppcobsd_reg_offsets.xer_offset = 404;
142 ppcobsd_reg_offsets.mq_offset = 408;
143
144 /* Floating-point registers. */
145 ppcobsd_reg_offsets.f0_offset = 128;
146 ppcobsd_reg_offsets.fpscr_offset = -1;
147
148 /* AltiVec registers. */
149 ppcobsd_reg_offsets.vr0_offset = 0;
150 ppcobsd_reg_offsets.vscr_offset = 512;
151 ppcobsd_reg_offsets.vrsave_offset = 520;
152 }
153}
This page took 0.037292 seconds and 4 git commands to generate.