gdb/testsuite/
[deliverable/binutils-gdb.git] / gdb / hppaobsd-tdep.c
... / ...
CommitLineData
1/* Target-dependent code for OpenBSD/hppa
2
3 Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010
4 Free Software Foundation, Inc.
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21#include "defs.h"
22#include "osabi.h"
23#include "regcache.h"
24#include "regset.h"
25
26#include "gdb_assert.h"
27#include "gdb_string.h"
28
29#include "hppa-tdep.h"
30#include "hppabsd-tdep.h"
31
32/* Core file support. */
33
34/* Sizeof `struct reg' in <machine/reg.h>. */
35#define HPPAOBSD_SIZEOF_GREGS (34 * 4)
36
37/* Sizeof `struct fpreg' in <machine/reg.h>. */
38#define HPPAOBSD_SIZEOF_FPREGS (32 * 8)
39
40/* Supply register REGNUM from the buffer specified by GREGS and LEN
41 in the general-purpose register set REGSET to register cache
42 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
43
44static void
45hppaobsd_supply_gregset (const struct regset *regset,
46 struct regcache *regcache,
47 int regnum, const void *gregs, size_t len)
48{
49 const gdb_byte *regs = gregs;
50 size_t offset;
51 int i;
52
53 gdb_assert (len >= HPPAOBSD_SIZEOF_GREGS);
54
55 for (i = HPPA_R1_REGNUM, offset = 4; i <= HPPA_R31_REGNUM; i++, offset += 4)
56 {
57 if (regnum == -1 || regnum == i)
58 regcache_raw_supply (regcache, i, regs + offset);
59 }
60
61 if (regnum == -1 || regnum == HPPA_SAR_REGNUM)
62 regcache_raw_supply (regcache, HPPA_SAR_REGNUM, regs);
63 if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM)
64 regcache_raw_supply (regcache, HPPA_PCOQ_HEAD_REGNUM, regs + 32 * 4);
65 if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM)
66 regcache_raw_supply (regcache, HPPA_PCOQ_TAIL_REGNUM, regs + 33 * 4);
67}
68
69/* Supply register REGNUM from the buffer specified by FPREGS and LEN
70 in the floating-point register set REGSET to register cache
71 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
72
73static void
74hppaobsd_supply_fpregset (const struct regset *regset,
75 struct regcache *regcache,
76 int regnum, const void *fpregs, size_t len)
77{
78 struct gdbarch *gdbarch = get_regcache_arch (regcache);
79 const gdb_byte *regs = fpregs;
80 int i;
81
82 gdb_assert (len >= HPPAOBSD_SIZEOF_FPREGS);
83
84 for (i = HPPA_FP0_REGNUM; i <= HPPA_FP31R_REGNUM; i++)
85 {
86 if (regnum == i || regnum == -1)
87 regcache_raw_supply (regcache, i, regs + (i - HPPA_FP0_REGNUM) * 4);
88 }
89}
90
91/* OpenBSD/hppa register sets. */
92
93static struct regset hppaobsd_gregset =
94{
95 NULL,
96 hppaobsd_supply_gregset
97};
98
99static struct regset hppaobsd_fpregset =
100{
101 NULL,
102 hppaobsd_supply_fpregset
103};
104
105/* Return the appropriate register set for the core section identified
106 by SECT_NAME and SECT_SIZE. */
107
108static const struct regset *
109hppaobsd_regset_from_core_section (struct gdbarch *gdbarch,
110 const char *sect_name, size_t sect_size)
111{
112 if (strcmp (sect_name, ".reg") == 0 && sect_size >= HPPAOBSD_SIZEOF_GREGS)
113 return &hppaobsd_gregset;
114
115 if (strcmp (sect_name, ".reg2") == 0 && sect_size >= HPPAOBSD_SIZEOF_FPREGS)
116 return &hppaobsd_fpregset;
117
118 return NULL;
119}
120\f
121
122static void
123hppaobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
124{
125 /* Obviously OpenBSD is BSD-based. */
126 hppabsd_init_abi (info, gdbarch);
127
128 /* Core file support. */
129 set_gdbarch_regset_from_core_section
130 (gdbarch, hppaobsd_regset_from_core_section);
131}
132\f
133
134/* OpenBSD uses uses the traditional NetBSD core file format, even for
135 ports that use ELF. */
136#define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF
137
138static enum gdb_osabi
139hppaobsd_core_osabi_sniffer (bfd *abfd)
140{
141 if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
142 return GDB_OSABI_NETBSD_CORE;
143
144 return GDB_OSABI_UNKNOWN;
145}
146\f
147
148/* Provide a prototype to silence -Wmissing-prototypes. */
149void _initialize_hppabsd_tdep (void);
150
151void
152_initialize_hppabsd_tdep (void)
153{
154 /* BFD doesn't set a flavour for NetBSD style a.out core files. */
155 gdbarch_register_osabi_sniffer (bfd_arch_hppa, bfd_target_unknown_flavour,
156 hppaobsd_core_osabi_sniffer);
157
158 gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_OPENBSD_ELF,
159 hppaobsd_init_abi);
160}
This page took 0.029349 seconds and 4 git commands to generate.