GDB (xrefs)
Loading...
Searching...
No Matches
hppa-obsd-tdep.c
Go to the documentation of this file.
1/* Target-dependent code for OpenBSD/hppa
2
3 Copyright (C) 2004-2023 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#include "gdbarch.h"
28
29/* Core file support. */
30
31/* Sizeof `struct reg' in <machine/reg.h>. */
32#define HPPAOBSD_SIZEOF_GREGS (34 * 4) /* OpenBSD 5.1 and earlier. */
33#define HPPANBSD_SIZEOF_GREGS (46 * 4) /* NetBSD and OpenBSD 5.2 and later. */
34
35/* Sizeof `struct fpreg' in <machine/reg.h>. */
36#define HPPAOBSD_SIZEOF_FPREGS (32 * 8)
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
42static void
44 struct regcache *regcache,
45 int regnum, const void *gregs, size_t len)
46{
47 gdb_byte zero[4] = { 0 };
48 const gdb_byte *regs = (const gdb_byte *) gregs;
49 size_t offset;
50 int i;
51
52 gdb_assert (len >= HPPAOBSD_SIZEOF_GREGS);
53
54 if (regnum == -1 || regnum == HPPA_R0_REGNUM)
56 for (i = HPPA_R1_REGNUM, offset = 4; i <= HPPA_R31_REGNUM; i++, offset += 4)
57 {
58 if (regnum == -1 || regnum == i)
59 regcache->raw_supply (i, regs + offset);
60 }
61
62 if (len >= HPPANBSD_SIZEOF_GREGS)
63 {
64 if (regnum == -1 || regnum == HPPA_IPSW_REGNUM)
66 if (regnum == -1 || regnum == HPPA_SAR_REGNUM)
67 regcache->raw_supply (HPPA_SAR_REGNUM, regs + 32 * 4);
68 if (regnum == -1 || regnum == HPPA_PCSQ_HEAD_REGNUM)
70 if (regnum == -1 || regnum == HPPA_PCSQ_TAIL_REGNUM)
72 if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM)
74 if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM)
76 if (regnum == -1 || regnum == HPPA_SR0_REGNUM)
77 regcache->raw_supply (HPPA_SR0_REGNUM, regs + 37 * 4);
78 if (regnum == -1 || regnum == HPPA_SR1_REGNUM)
79 regcache->raw_supply (HPPA_SR1_REGNUM, regs + 38 * 4);
80 if (regnum == -1 || regnum == HPPA_SR2_REGNUM)
81 regcache->raw_supply (HPPA_SR2_REGNUM, regs + 39 * 4);
82 if (regnum == -1 || regnum == HPPA_SR3_REGNUM)
83 regcache->raw_supply (HPPA_SR3_REGNUM, regs + 40 * 4);
84 if (regnum == -1 || regnum == HPPA_SR4_REGNUM)
85 regcache->raw_supply (HPPA_SR4_REGNUM, regs + 41 * 4);
86 if (regnum == -1 || regnum == HPPA_SR5_REGNUM)
87 regcache->raw_supply (HPPA_SR5_REGNUM, regs + 42 * 4);
88 if (regnum == -1 || regnum == HPPA_SR6_REGNUM)
89 regcache->raw_supply (HPPA_SR6_REGNUM, regs + 43 * 4);
90 if (regnum == -1 || regnum == HPPA_SR7_REGNUM)
91 regcache->raw_supply (HPPA_SR7_REGNUM, regs + 44 * 4);
92 if (regnum == -1 || regnum == HPPA_CR26_REGNUM)
93 regcache->raw_supply (HPPA_CR26_REGNUM, regs + 45 * 4);
94 if (regnum == -1 || regnum == HPPA_CR27_REGNUM)
95 regcache->raw_supply (HPPA_CR27_REGNUM, regs + 46 * 4);
96 }
97 else
98 {
99 if (regnum == -1 || regnum == HPPA_SAR_REGNUM)
101 if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM)
102 regcache->raw_supply (HPPA_PCOQ_HEAD_REGNUM, regs + 32 * 4);
103 if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM)
104 regcache->raw_supply (HPPA_PCOQ_TAIL_REGNUM, regs + 33 * 4);
105 }
106}
107
108/* Supply register REGNUM from the buffer specified by FPREGS and LEN
109 in the floating-point register set REGSET to register cache
110 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
111
112static void
114 struct regcache *regcache,
115 int regnum, const void *fpregs, size_t len)
116{
117 const gdb_byte *regs = (const gdb_byte *) fpregs;
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 (i, regs + (i - HPPA_FP0_REGNUM) * 4);
126 }
127}
128
129/* OpenBSD/hppa register sets. */
130
131static const struct regset hppaobsd_gregset =
132{
133 NULL,
135 NULL,
137};
138
139static const struct regset hppaobsd_fpregset =
140{
141 NULL,
143};
144
145/* Iterate over supported core file register note sections. */
146
147static void
150 void *cb_data,
151 const struct regcache *regcache)
152{
154 NULL, cb_data);
156 &hppaobsd_fpregset, NULL, cb_data);
157}
158
159
160static void
162{
163 /* Obviously OpenBSD is BSD-based. */
165
166 /* Core file support. */
169}
170
172void
int regnum
void raw_supply(int regnum, const void *buf) override
Definition regcache.c:1062
void set_gdbarch_iterate_over_regset_sections(struct gdbarch *gdbarch, gdbarch_iterate_over_regset_sections_ftype *iterate_over_regset_sections)
void iterate_over_regset_sections_cb(const char *sect_name, int supply_size, int collect_size, const struct regset *regset, const char *human_name, void *cb_data)
Definition gdbarch.h:104
void hppabsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
static void hppaobsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
void _initialize_hppabsd_tdep()
#define HPPAOBSD_SIZEOF_GREGS
static void hppaobsd_supply_gregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len)
static const struct regset hppaobsd_fpregset
static const struct regset hppaobsd_gregset
static void hppaobsd_iterate_over_regset_sections(struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache)
static void hppaobsd_supply_fpregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *fpregs, size_t len)
#define HPPAOBSD_SIZEOF_FPREGS
#define HPPANBSD_SIZEOF_GREGS
@ HPPA_R31_REGNUM
Definition hppa-tdep.h:43
@ HPPA_R1_REGNUM
Definition hppa-tdep.h:35
@ HPPA_PCSQ_HEAD_REGNUM
Definition hppa-tdep.h:47
@ HPPA_SR2_REGNUM
Definition hppa-tdep.h:57
@ HPPA_SAR_REGNUM
Definition hppa-tdep.h:44
@ HPPA_IPSW_REGNUM
Definition hppa-tdep.h:45
@ HPPA_SR5_REGNUM
Definition hppa-tdep.h:59
@ HPPA_SR1_REGNUM
Definition hppa-tdep.h:56
@ HPPA_FP31R_REGNUM
Definition hppa-tdep.h:75
@ HPPA_CR26_REGNUM
Definition hppa-tdep.h:69
@ HPPA_SR7_REGNUM
Definition hppa-tdep.h:61
@ HPPA_PCOQ_HEAD_REGNUM
Definition hppa-tdep.h:46
@ HPPA_SR6_REGNUM
Definition hppa-tdep.h:60
@ HPPA_PCSQ_TAIL_REGNUM
Definition hppa-tdep.h:49
@ HPPA_PCOQ_TAIL_REGNUM
Definition hppa-tdep.h:48
@ HPPA_CR27_REGNUM
Definition hppa-tdep.h:70
@ HPPA_FP0_REGNUM
Definition hppa-tdep.h:72
@ HPPA_SR0_REGNUM
Definition hppa-tdep.h:55
@ HPPA_SR4_REGNUM
Definition hppa-tdep.h:54
@ HPPA_SR3_REGNUM
Definition hppa-tdep.h:58
@ HPPA_R0_REGNUM
Definition hppa-tdep.h:33
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:146
@ GDB_OSABI_OPENBSD
Definition osabi.h:35
#define REGSET_VARIABLE_SIZE
Definition regset.h:52