GDB (xrefs)

/tmp/gdb-8.1/gdb/hppa-obsd-tdep.c
Go to the documentation of this file.
1 /* Target-dependent code for OpenBSD/hppa
2
3 Copyright (C) 2004-2018 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 "hppa-tdep.h"
26 #include "hppa-bsd-tdep.h"
27
28 /* Core file support. */
29
30 /* Sizeof `struct reg' in <machine/reg.h>. */
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. */
33
34 /* Sizeof `struct fpreg' in <machine/reg.h>. */
35 #define HPPAOBSD_SIZEOF_FPREGS (32 * 8)
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
41 static void
42 hppaobsd_supply_gregset (const struct regset *regset,
43 struct regcache *regcache,
44 int regnum, const void *gregs, size_t len)
45 {
46 gdb_byte zero[4] = { 0 };
47 const gdb_byte *regs = (const gdb_byte *) gregs;
48 size_t offset;
49 int i;
50
51 gdb_assert (len >= HPPAOBSD_SIZEOF_GREGS);
52
53 if (regnum == -1 || regnum == HPPA_R0_REGNUM)
54 regcache_raw_supply (regcache, HPPA_R0_REGNUM, &zero);
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 (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 }
105 }
106
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
111 static void
112 hppaobsd_supply_fpregset (const struct regset *regset,
113 struct regcache *regcache,
114 int regnum, const void *fpregs, size_t len)
115 {
116 const gdb_byte *regs = (const gdb_byte *) fpregs;
117 int i;
118
119 gdb_assert (len >= HPPAOBSD_SIZEOF_FPREGS);
120
121 for (i = HPPA_FP0_REGNUM; i <= HPPA_FP31R_REGNUM; i++)
122 {
123 if (regnum == i || regnum == -1)
124 regcache_raw_supply (regcache, i, regs + (i - HPPA_FP0_REGNUM) * 4);
125 }
126 }
127
128 /* OpenBSD/hppa register sets. */
129
130 static const struct regset hppaobsd_gregset =
131 {
132 NULL,
133 hppaobsd_supply_gregset,
134 NULL,
135 REGSET_VARIABLE_SIZE
136 };
137
138 static const struct regset hppaobsd_fpregset =
139 {
140 NULL,
141 hppaobsd_supply_fpregset
142 };
143
144 /* Iterate over supported core file register note sections. */
145
146 static void
147 hppaobsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
148 iterate_over_regset_sections_cb *cb,
149 void *cb_data,
150 const struct regcache *regcache)
151 {
152 cb (".reg", HPPAOBSD_SIZEOF_GREGS, &hppaobsd_gregset, NULL, cb_data);
153 cb (".reg2", HPPAOBSD_SIZEOF_FPREGS, &hppaobsd_fpregset, NULL, cb_data);
154 }
155
156
157 static void
158 hppaobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
159 {
160 /* Obviously OpenBSD is BSD-based. */
161 hppabsd_init_abi (info, gdbarch);
162
163 /* Core file support. */
164 set_gdbarch_iterate_over_regset_sections
165 (gdbarch, hppaobsd_iterate_over_regset_sections);
166 }
167
168 void
169 _initialize_hppabsd_tdep (void)
170 {
171 gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_OPENBSD,
172 hppaobsd_init_abi);
173 }
gdbarch
Definition: gdbarch.c:127
HPPA_SR2_REGNUM
Definition: hppa-tdep.h:55
HPPA_SR5_REGNUM
Definition: hppa-tdep.h:57
hppa-tdep.h
hppaobsd_supply_gregset
static void hppaobsd_supply_gregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len)
Definition: hppa-obsd-tdep.c:42
hppaobsd_iterate_over_regset_sections
static void hppaobsd_iterate_over_regset_sections(struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache)
Definition: hppa-obsd-tdep.c:147
iterate_over_regset_sections_cb
void() iterate_over_regset_sections_cb(const char *sect_name, int size, const struct regset *regset, const char *human_name, void *cb_data)
Definition: gdbarch.h:99
_initialize_hppabsd_tdep
void _initialize_hppabsd_tdep(void)
Definition: hppa-obsd-tdep.c:169
HPPA_SR1_REGNUM
Definition: hppa-tdep.h:54
hppaobsd_gregset
static const struct regset hppaobsd_gregset
Definition: hppa-obsd-tdep.c:130
HPPA_SR0_REGNUM
Definition: hppa-tdep.h:53
HPPA_PCOQ_TAIL_REGNUM
Definition: hppa-tdep.h:46
HPPA_PCOQ_HEAD_REGNUM
Definition: hppa-tdep.h:44
hppaobsd_fpregset
static const struct regset hppaobsd_fpregset
Definition: hppa-obsd-tdep.c:138
HPPA_R0_REGNUM
Definition: hppa-tdep.h:31
defs.h
hppabsd_init_abi
void hppabsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: hppa-bsd-tdep.c:120
HPPA_R1_REGNUM
Definition: hppa-tdep.h:33
HPPA_SAR_REGNUM
Definition: hppa-tdep.h:42
HPPANBSD_SIZEOF_GREGS
#define HPPANBSD_SIZEOF_GREGS
Definition: hppa-obsd-tdep.c:32
regset
Definition: regset.h:34
HPPA_PCSQ_HEAD_REGNUM
Definition: hppa-tdep.h:45
HPPA_CR26_REGNUM
Definition: hppa-tdep.h:67
osabi.h
regcache.h
HPPA_IPSW_REGNUM
Definition: hppa-tdep.h:43
HPPA_FP0_REGNUM
Definition: hppa-tdep.h:70
HPPA_SR3_REGNUM
Definition: hppa-tdep.h:56
hppaobsd_supply_fpregset
static void hppaobsd_supply_fpregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *fpregs, size_t len)
Definition: hppa-obsd-tdep.c:112
REGSET_VARIABLE_SIZE
#define REGSET_VARIABLE_SIZE
Definition: regset.h:52
HPPA_SR7_REGNUM
Definition: hppa-tdep.h:59
regnum
int regnum
Definition: aarch64-tdep.c:77
gdbarch_register_osabi
void gdbarch_register_osabi(enum bfd_architecture arch, unsigned long machine, enum gdb_osabi osabi, void(*init_osabi)(struct gdbarch_info, struct gdbarch *))
Definition: osabi.c:143
HPPA_SR4_REGNUM
Definition: hppa-tdep.h:52
HPPA_R31_REGNUM
Definition: hppa-tdep.h:41
hppa-bsd-tdep.h
gdb_assert
#define gdb_assert(expr)
Definition: gdb_assert.h:32
HPPA_CR27_REGNUM
Definition: hppa-tdep.h:68
HPPAOBSD_SIZEOF_GREGS
#define HPPAOBSD_SIZEOF_GREGS
Definition: hppa-obsd-tdep.c:31
gdb_byte
bfd_byte gdb_byte
Definition: common-types.h:38
offset
int offset
Definition: agent.c:65
HPPAOBSD_SIZEOF_FPREGS
#define HPPAOBSD_SIZEOF_FPREGS
Definition: hppa-obsd-tdep.c:35
HPPA_FP31R_REGNUM
Definition: hppa-tdep.h:73
regcache_raw_supply
void regcache_raw_supply(struct regcache *regcache, int regnum, const void *buf)
Definition: regcache.c:1004
regcache
Definition: regcache.h:232
gdbarch_info
Definition: gdbarch.h:1626
HPPA_PCSQ_TAIL_REGNUM
Definition: hppa-tdep.h:47
regset.h
set_gdbarch_iterate_over_regset_sections
void set_gdbarch_iterate_over_regset_sections(struct gdbarch *gdbarch, gdbarch_iterate_over_regset_sections_ftype iterate_over_regset_sections)
Definition: gdbarch.c:3647
GDB_OSABI_OPENBSD
Definition: defs.h:520
HPPA_SR6_REGNUM
Definition: hppa-tdep.h:58
hppaobsd_init_abi
static void hppaobsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: hppa-obsd-tdep.c:158