]>
Commit | Line | Data |
---|---|---|
0e56aeaf MK |
1 | /* Target-dependent code for HP PA-RISC BSD's. |
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_assert.h" | |
29 | #include "gdb_string.h" | |
30 | ||
31 | #include "hppa-tdep.h" | |
32 | #include "solib-svr4.h" | |
33 | ||
34 | /* Core file support. */ | |
35 | ||
36 | /* Sizeof `struct reg' in <machine/reg.h>. */ | |
37 | #define HPPABSD_SIZEOF_GREGS (34 * 4) | |
38 | ||
39 | /* Supply register REGNUM from the buffer specified by GREGS and LEN | |
40 | in the general-purpose register set REGSET to register cache | |
41 | REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ | |
42 | ||
43 | static void | |
44 | hppabsd_supply_gregset (const struct regset *regset, struct regcache *regcache, | |
45 | int regnum, const void *gregs, size_t len) | |
46 | { | |
47 | const char *regs = gregs; | |
48 | size_t offset; | |
49 | int i; | |
50 | ||
51 | gdb_assert (len >= HPPABSD_SIZEOF_GREGS); | |
52 | ||
53 | for (i = HPPA_R1_REGNUM, offset = 4; i <= HPPA_R31_REGNUM; i++, offset += 4) | |
54 | { | |
55 | if (regnum == -1 || regnum == i) | |
56 | regcache_raw_supply (regcache, i, regs + offset); | |
57 | } | |
58 | ||
59 | if (regnum == -1 || regnum == HPPA_SAR_REGNUM) | |
60 | regcache_raw_supply (regcache, HPPA_SAR_REGNUM, regs); | |
61 | if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM) | |
62 | regcache_raw_supply (regcache, HPPA_PCOQ_HEAD_REGNUM, regs + 32 * 4); | |
63 | if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM) | |
64 | regcache_raw_supply (regcache, HPPA_PCOQ_TAIL_REGNUM, regs + 33 * 4); | |
65 | } | |
66 | ||
67 | /* OpenBSD/hppa register set. */ | |
68 | ||
69 | static struct regset hppabsd_gregset = | |
70 | { | |
71 | NULL, | |
72 | hppabsd_supply_gregset | |
73 | }; | |
74 | ||
75 | /* Return the appropriate register set for the core section identified | |
76 | by SECT_NAME and SECT_SIZE. */ | |
77 | ||
78 | static const struct regset * | |
79 | hppabsd_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 >= HPPABSD_SIZEOF_GREGS) | |
83 | return &hppabsd_gregset; | |
84 | ||
85 | return NULL; | |
86 | } | |
87 | \f | |
88 | ||
89 | static void | |
90 | hppabsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | |
91 | { | |
92 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
93 | ||
94 | /* Core file support. */ | |
95 | set_gdbarch_regset_from_core_section | |
96 | (gdbarch, hppabsd_regset_from_core_section); | |
97 | ||
98 | /* OpenBSD and NetBSD use ELF. */ | |
99 | tdep->is_elf = 1; | |
100 | ||
101 | /* OpenBSD and NetBSD uses SVR4-style shared libraries. */ | |
0e56aeaf MK |
102 | set_solib_svr4_fetch_link_map_offsets |
103 | (gdbarch, svr4_ilp32_fetch_link_map_offsets); | |
104 | } | |
105 | \f | |
106 | ||
107 | /* OpenBSD uses uses the traditional NetBSD core file format, even for | |
108 | ports that use ELF. */ | |
109 | #define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF | |
110 | ||
111 | static enum gdb_osabi | |
112 | hppabsd_core_osabi_sniffer (bfd *abfd) | |
113 | { | |
114 | if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0) | |
115 | return GDB_OSABI_NETBSD_CORE; | |
116 | ||
117 | return GDB_OSABI_UNKNOWN; | |
118 | } | |
119 | \f | |
120 | ||
121 | /* Provide a prototype to silence -Wmissing-prototypes. */ | |
122 | void _initialize_hppabsd_tdep (void); | |
123 | ||
124 | void | |
125 | _initialize_hppabsd_tdep (void) | |
126 | { | |
127 | /* BFD doesn't set a flavour for NetBSD style a.out core files. */ | |
128 | gdbarch_register_osabi_sniffer (bfd_arch_hppa, bfd_target_unknown_flavour, | |
129 | hppabsd_core_osabi_sniffer); | |
130 | ||
131 | gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_NETBSD_ELF, | |
132 | hppabsd_init_abi); | |
133 | gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_OPENBSD_ELF, | |
134 | hppabsd_init_abi); | |
135 | } |