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