Commit | Line | Data |
---|---|---|
af5ca30d NH |
1 | /* Target-dependent code for OpenBSD/hppa |
2 | ||
0fb0cc75 | 3 | Copyright (C) 2004, 2005, 2006, 2008, 2009 Free Software Foundation, Inc. |
af5ca30d NH |
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., 51 Franklin Street, Fifth Floor, | |
20 | Boston, MA 02110-1301, USA. */ | |
21 | ||
22 | #include "defs.h" | |
23 | #include "osabi.h" | |
24 | #include "regcache.h" | |
25 | #include "regset.h" | |
26 | ||
27 | #include "gdb_assert.h" | |
28 | #include "gdb_string.h" | |
29 | ||
30 | #include "hppa-tdep.h" | |
63807e1d | 31 | #include "hppabsd-tdep.h" |
af5ca30d NH |
32 | |
33 | /* Core file support. */ | |
34 | ||
35 | /* Sizeof `struct reg' in <machine/reg.h>. */ | |
36 | #define HPPABSD_SIZEOF_GREGS (34 * 4) | |
37 | ||
38 | /* Supply register REGNUM from the buffer specified by GREGS and LEN | |
39 | in the general-purpose register set REGSET to register cache | |
40 | REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ | |
41 | ||
42 | static void | |
43 | hppabsd_supply_gregset (const struct regset *regset, struct regcache *regcache, | |
44 | int regnum, const void *gregs, size_t len) | |
45 | { | |
46 | const gdb_byte *regs = gregs; | |
47 | size_t offset; | |
48 | int i; | |
49 | ||
50 | gdb_assert (len >= HPPABSD_SIZEOF_GREGS); | |
51 | ||
52 | for (i = HPPA_R1_REGNUM, offset = 4; i <= HPPA_R31_REGNUM; i++, offset += 4) | |
53 | { | |
54 | if (regnum == -1 || regnum == i) | |
55 | regcache_raw_supply (regcache, i, regs + offset); | |
56 | } | |
57 | ||
58 | if (regnum == -1 || regnum == HPPA_SAR_REGNUM) | |
59 | regcache_raw_supply (regcache, HPPA_SAR_REGNUM, regs); | |
60 | if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM) | |
61 | regcache_raw_supply (regcache, HPPA_PCOQ_HEAD_REGNUM, regs + 32 * 4); | |
62 | if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM) | |
63 | regcache_raw_supply (regcache, HPPA_PCOQ_TAIL_REGNUM, regs + 33 * 4); | |
64 | } | |
65 | ||
66 | /* OpenBSD/hppa register set. */ | |
67 | ||
68 | static struct regset hppabsd_gregset = | |
69 | { | |
70 | NULL, | |
71 | hppabsd_supply_gregset | |
72 | }; | |
73 | ||
74 | /* Return the appropriate register set for the core section identified | |
75 | by SECT_NAME and SECT_SIZE. */ | |
76 | ||
77 | static const struct regset * | |
78 | hppaobsd_regset_from_core_section (struct gdbarch *gdbarch, | |
79 | const char *sect_name, size_t sect_size) | |
80 | { | |
81 | if (strcmp (sect_name, ".reg") == 0 && sect_size >= HPPABSD_SIZEOF_GREGS) | |
82 | return &hppabsd_gregset; | |
83 | ||
84 | return NULL; | |
85 | } | |
86 | \f | |
87 | ||
63807e1d | 88 | static void |
af5ca30d NH |
89 | hppaobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
90 | { | |
91 | /* Obviously OpenBSD is BSD-based. */ | |
92 | hppabsd_init_abi (info, gdbarch); | |
93 | ||
94 | /* Core file support. */ | |
95 | set_gdbarch_regset_from_core_section | |
96 | (gdbarch, hppaobsd_regset_from_core_section); | |
97 | ||
98 | } | |
99 | \f | |
100 | ||
101 | /* OpenBSD uses uses the traditional NetBSD core file format, even for | |
102 | ports that use ELF. */ | |
103 | #define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF | |
104 | ||
105 | static enum gdb_osabi | |
106 | hppaobsd_core_osabi_sniffer (bfd *abfd) | |
107 | { | |
108 | if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0) | |
109 | return GDB_OSABI_NETBSD_CORE; | |
110 | ||
111 | return GDB_OSABI_UNKNOWN; | |
112 | } | |
113 | \f | |
114 | ||
115 | /* Provide a prototype to silence -Wmissing-prototypes. */ | |
116 | void _initialize_hppabsd_tdep (void); | |
117 | ||
118 | void | |
119 | _initialize_hppabsd_tdep (void) | |
120 | { | |
121 | /* BFD doesn't set a flavour for NetBSD style a.out core files. */ | |
122 | gdbarch_register_osabi_sniffer (bfd_arch_hppa, bfd_target_unknown_flavour, | |
123 | hppaobsd_core_osabi_sniffer); | |
124 | ||
125 | gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_OPENBSD_ELF, | |
126 | hppaobsd_init_abi); | |
127 | } |