]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/hppaobsd-tdep.c
Replace some $ARCH_{get,set}_pc with linux_{get,set}_pc_32bit
[thirdparty/binutils-gdb.git] / gdb / hppaobsd-tdep.c
CommitLineData
af5ca30d
NH
1/* Target-dependent code for OpenBSD/hppa
2
618f726f 3 Copyright (C) 2004-2016 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
5b1ba0e5 9 the Free Software Foundation; either version 3 of the License, or
af5ca30d
NH
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
5b1ba0e5 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
af5ca30d
NH
19
20#include "defs.h"
21#include "osabi.h"
22#include "regcache.h"
23#include "regset.h"
24
af5ca30d 25#include "hppa-tdep.h"
63807e1d 26#include "hppabsd-tdep.h"
af5ca30d
NH
27
28/* Core file support. */
29
30/* Sizeof `struct reg' in <machine/reg.h>. */
cbb6aada
MK
31#define HPPAOBSD_SIZEOF_GREGS (34 * 4) /* OpenBSD 5.1 and earlier. */
32#define HPPANBSD_SIZEOF_GREGS (46 * 4) /* NetBSD and OpenBSD 5.2 and later. */
7c54a108
MK
33
34/* Sizeof `struct fpreg' in <machine/reg.h>. */
35#define HPPAOBSD_SIZEOF_FPREGS (32 * 8)
af5ca30d
NH
36
37/* Supply register REGNUM from the buffer specified by GREGS and LEN
38 in the general-purpose register set REGSET to register cache
39 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
40
41static void
7c54a108
MK
42hppaobsd_supply_gregset (const struct regset *regset,
43 struct regcache *regcache,
44 int regnum, const void *gregs, size_t len)
af5ca30d 45{
cbb6aada 46 gdb_byte zero[4] = { 0 };
9a3c8263 47 const gdb_byte *regs = (const gdb_byte *) gregs;
af5ca30d
NH
48 size_t offset;
49 int i;
50
7c54a108 51 gdb_assert (len >= HPPAOBSD_SIZEOF_GREGS);
af5ca30d 52
cbb6aada
MK
53 if (regnum == -1 || regnum == HPPA_R0_REGNUM)
54 regcache_raw_supply (regcache, HPPA_R0_REGNUM, &zero);
af5ca30d
NH
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
cbb6aada
MK
61 if (len >= HPPANBSD_SIZEOF_GREGS)
62 {
63 if (regnum == -1 || regnum == HPPA_IPSW_REGNUM)
64 regcache_raw_supply (regcache, HPPA_IPSW_REGNUM, regs);
65 if (regnum == -1 || regnum == HPPA_SAR_REGNUM)
66 regcache_raw_supply (regcache, HPPA_SAR_REGNUM, regs + 32 * 4);
67 if (regnum == -1 || regnum == HPPA_PCSQ_HEAD_REGNUM)
68 regcache_raw_supply (regcache, HPPA_PCSQ_HEAD_REGNUM, regs + 33 * 4);
69 if (regnum == -1 || regnum == HPPA_PCSQ_TAIL_REGNUM)
70 regcache_raw_supply (regcache, HPPA_PCSQ_TAIL_REGNUM, regs + 34 * 4);
71 if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM)
72 regcache_raw_supply (regcache, HPPA_PCOQ_HEAD_REGNUM, regs + 35 * 4);
73 if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM)
74 regcache_raw_supply (regcache, HPPA_PCOQ_TAIL_REGNUM, regs + 36 * 4);
75 if (regnum == -1 || regnum == HPPA_SR0_REGNUM)
76 regcache_raw_supply (regcache, HPPA_SR0_REGNUM, regs + 37 * 4);
77 if (regnum == -1 || regnum == HPPA_SR1_REGNUM)
78 regcache_raw_supply (regcache, HPPA_SR1_REGNUM, regs + 38 * 4);
79 if (regnum == -1 || regnum == HPPA_SR2_REGNUM)
80 regcache_raw_supply (regcache, HPPA_SR2_REGNUM, regs + 39 * 4);
81 if (regnum == -1 || regnum == HPPA_SR3_REGNUM)
82 regcache_raw_supply (regcache, HPPA_SR3_REGNUM, regs + 40 * 4);
83 if (regnum == -1 || regnum == HPPA_SR4_REGNUM)
84 regcache_raw_supply (regcache, HPPA_SR4_REGNUM, regs + 41 * 4);
85 if (regnum == -1 || regnum == HPPA_SR5_REGNUM)
86 regcache_raw_supply (regcache, HPPA_SR5_REGNUM, regs + 42 * 4);
87 if (regnum == -1 || regnum == HPPA_SR6_REGNUM)
88 regcache_raw_supply (regcache, HPPA_SR6_REGNUM, regs + 43 * 4);
89 if (regnum == -1 || regnum == HPPA_SR7_REGNUM)
90 regcache_raw_supply (regcache, HPPA_SR7_REGNUM, regs + 44 * 4);
91 if (regnum == -1 || regnum == HPPA_CR26_REGNUM)
92 regcache_raw_supply (regcache, HPPA_CR26_REGNUM, regs + 45 * 4);
93 if (regnum == -1 || regnum == HPPA_CR27_REGNUM)
94 regcache_raw_supply (regcache, HPPA_CR27_REGNUM, regs + 46 * 4);
95 }
96 else
97 {
98 if (regnum == -1 || regnum == HPPA_SAR_REGNUM)
99 regcache_raw_supply (regcache, HPPA_SAR_REGNUM, regs);
100 if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM)
101 regcache_raw_supply (regcache, HPPA_PCOQ_HEAD_REGNUM, regs + 32 * 4);
102 if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM)
103 regcache_raw_supply (regcache, HPPA_PCOQ_TAIL_REGNUM, regs + 33 * 4);
104 }
af5ca30d
NH
105}
106
7c54a108
MK
107/* Supply register REGNUM from the buffer specified by FPREGS and LEN
108 in the floating-point register set REGSET to register cache
109 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
110
111static void
112hppaobsd_supply_fpregset (const struct regset *regset,
113 struct regcache *regcache,
114 int regnum, const void *fpregs, size_t len)
115{
116 struct gdbarch *gdbarch = get_regcache_arch (regcache);
9a3c8263 117 const gdb_byte *regs = (const gdb_byte *) fpregs;
7c54a108
MK
118 int i;
119
120 gdb_assert (len >= HPPAOBSD_SIZEOF_FPREGS);
121
122 for (i = HPPA_FP0_REGNUM; i <= HPPA_FP31R_REGNUM; i++)
123 {
124 if (regnum == i || regnum == -1)
125 regcache_raw_supply (regcache, i, regs + (i - HPPA_FP0_REGNUM) * 4);
126 }
127}
128
129/* OpenBSD/hppa register sets. */
af5ca30d 130
3ca7dae4 131static const struct regset hppaobsd_gregset =
af5ca30d
NH
132{
133 NULL,
f962539a
AA
134 hppaobsd_supply_gregset,
135 NULL,
136 REGSET_VARIABLE_SIZE
7c54a108
MK
137};
138
3ca7dae4 139static const struct regset hppaobsd_fpregset =
7c54a108
MK
140{
141 NULL,
142 hppaobsd_supply_fpregset
af5ca30d
NH
143};
144
50c5eb53 145/* Iterate over supported core file register note sections. */
af5ca30d 146
50c5eb53
AA
147static void
148hppaobsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
149 iterate_over_regset_sections_cb *cb,
150 void *cb_data,
151 const struct regcache *regcache)
af5ca30d 152{
50c5eb53
AA
153 cb (".reg", HPPAOBSD_SIZEOF_GREGS, &hppaobsd_gregset, NULL, cb_data);
154 cb (".reg2", HPPAOBSD_SIZEOF_FPREGS, &hppaobsd_fpregset, NULL, cb_data);
af5ca30d
NH
155}
156\f
157
63807e1d 158static void
af5ca30d
NH
159hppaobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
160{
161 /* Obviously OpenBSD is BSD-based. */
162 hppabsd_init_abi (info, gdbarch);
163
164 /* Core file support. */
50c5eb53
AA
165 set_gdbarch_iterate_over_regset_sections
166 (gdbarch, hppaobsd_iterate_over_regset_sections);
af5ca30d
NH
167}
168\f
169
170/* OpenBSD uses uses the traditional NetBSD core file format, even for
171 ports that use ELF. */
172#define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF
173
174static enum gdb_osabi
175hppaobsd_core_osabi_sniffer (bfd *abfd)
176{
177 if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0)
178 return GDB_OSABI_NETBSD_CORE;
179
180 return GDB_OSABI_UNKNOWN;
181}
182\f
183
184/* Provide a prototype to silence -Wmissing-prototypes. */
185void _initialize_hppabsd_tdep (void);
186
187void
188_initialize_hppabsd_tdep (void)
189{
190 /* BFD doesn't set a flavour for NetBSD style a.out core files. */
191 gdbarch_register_osabi_sniffer (bfd_arch_hppa, bfd_target_unknown_flavour,
192 hppaobsd_core_osabi_sniffer);
193
194 gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_OPENBSD_ELF,
195 hppaobsd_init_abi);
196}