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