GDB (xrefs)

/tmp/gdb-8.1/gdb/arm-bsd-tdep.c
Go to the documentation of this file.
1 /* Target-dependent code for ARM BSD's.
2
3 Copyright (C) 2006-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 "arm-tdep.h"
26
27 /* Core file support. */
28
29 /* Sizeof `struct reg' in <machine/reg.h>. */
30 #define ARMBSD_SIZEOF_GREGS (17 * 4)
31
32 /* Sizeof `struct fpreg' in <machine/reg.h. */
33 #define ARMBSD_SIZEOF_FPREGS ((1 + (8 * 3)) * 4)
34
35 static int
36 armbsd_fpreg_offset (int regnum)
37 {
38 if (regnum == ARM_FPS_REGNUM)
39 return 0;
40
41 return 4 + (regnum - ARM_F0_REGNUM) * 12;
42 }
43
44 /* Supply register REGNUM from the buffer specified by FPREGS and LEN
45 in the floating-point register set REGSET to register cache
46 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
47
48 static void
49 armbsd_supply_fpregset (const struct regset *regset,
50 struct regcache *regcache,
51 int regnum, const void *fpregs, size_t len)
52 {
53 const gdb_byte *regs = (const gdb_byte *) fpregs;
54 int i;
55
56 gdb_assert (len >= ARMBSD_SIZEOF_FPREGS);
57
58 for (i = ARM_F0_REGNUM; i <= ARM_FPS_REGNUM; i++)
59 {
60 if (regnum == i || regnum == -1)
61 regcache_raw_supply (regcache, i, regs + armbsd_fpreg_offset (i));
62 }
63 }
64
65 /* Supply register REGNUM from the buffer specified by GREGS and LEN
66 in the general-purpose register set REGSET to register cache
67 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
68
69 static void
70 armbsd_supply_gregset (const struct regset *regset,
71 struct regcache *regcache,
72 int regnum, const void *gregs, size_t len)
73 {
74 const gdb_byte *regs = (const gdb_byte *) gregs;
75 int i;
76
77 gdb_assert (len >= ARMBSD_SIZEOF_GREGS);
78
79 for (i = ARM_A1_REGNUM; i <= ARM_PC_REGNUM; i++)
80 {
81 if (regnum == i || regnum == -1)
82 regcache_raw_supply (regcache, i, regs + i * 4);
83 }
84
85 if (regnum == ARM_PS_REGNUM || regnum == -1)
86 regcache_raw_supply (regcache, i, regs + 16 * 4);
87
88 if (len >= ARMBSD_SIZEOF_GREGS + ARMBSD_SIZEOF_FPREGS)
89 {
90 regs += ARMBSD_SIZEOF_GREGS;
91 len -= ARMBSD_SIZEOF_GREGS;
92 armbsd_supply_fpregset (regset, regcache, regnum, regs, len);
93 }
94 }
95
96 /* ARM register sets. */
97
98 static const struct regset armbsd_gregset =
99 {
100 NULL,
101 armbsd_supply_gregset,
102 NULL,
103 REGSET_VARIABLE_SIZE
104 };
105
106 static const struct regset armbsd_fpregset =
107 {
108 NULL,
109 armbsd_supply_fpregset
110 };
111
112 /* Iterate over supported core file register note sections. */
113
114 void
115 armbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
116 iterate_over_regset_sections_cb *cb,
117 void *cb_data,
118 const struct regcache *regcache)
119 {
120 cb (".reg", ARMBSD_SIZEOF_GREGS, &armbsd_gregset, NULL, cb_data);
121 cb (".reg2", ARMBSD_SIZEOF_FPREGS, &armbsd_fpregset, NULL, cb_data);
122 }
gdbarch
Definition: gdbarch.c:127
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
armbsd_fpreg_offset
static int armbsd_fpreg_offset(int regnum)
Definition: arm-bsd-tdep.c:36
defs.h
ARMBSD_SIZEOF_GREGS
#define ARMBSD_SIZEOF_GREGS
Definition: arm-bsd-tdep.c:30
ARMBSD_SIZEOF_FPREGS
#define ARMBSD_SIZEOF_FPREGS
Definition: arm-bsd-tdep.c:33
regset
Definition: regset.h:34
arm-tdep.h
osabi.h
regcache.h
armbsd_gregset
static const struct regset armbsd_gregset
Definition: arm-bsd-tdep.c:98
REGSET_VARIABLE_SIZE
#define REGSET_VARIABLE_SIZE
Definition: regset.h:52
ARM_A1_REGNUM
Definition: arm.h:25
regnum
int regnum
Definition: aarch64-tdep.c:77
gdb_assert
#define gdb_assert(expr)
Definition: gdb_assert.h:32
gdb_byte
bfd_byte gdb_byte
Definition: common-types.h:38
armbsd_supply_gregset
static void armbsd_supply_gregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len)
Definition: arm-bsd-tdep.c:70
armbsd_fpregset
static const struct regset armbsd_fpregset
Definition: arm-bsd-tdep.c:106
ARM_PS_REGNUM
Definition: arm.h:36
armbsd_supply_fpregset
static void armbsd_supply_fpregset(const struct regset *regset, struct regcache *regcache, int regnum, const void *fpregs, size_t len)
Definition: arm-bsd-tdep.c:49
regcache_raw_supply
void regcache_raw_supply(struct regcache *regcache, int regnum, const void *buf)
Definition: regcache.c:1004
regcache
Definition: regcache.h:232
regset.h
ARM_FPS_REGNUM
Definition: arm.h:35
ARM_PC_REGNUM
Definition: arm.h:31
armbsd_iterate_over_regset_sections
void armbsd_iterate_over_regset_sections(struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache)
Definition: arm-bsd-tdep.c:115
ARM_F0_REGNUM
Definition: arm.h:32