gdb, testsuite: Fix return value in gdb.base/foll-fork.exp
[binutils-gdb.git] / gdb / arm-bsd-tdep.c
blob1ccabcb24f06d6cca1402cc27c202d4baabafc4b
1 /* Target-dependent code for ARM BSD's.
3 Copyright (C) 2006-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
20 #include "osabi.h"
21 #include "regcache.h"
22 #include "regset.h"
24 #include "arm-tdep.h"
26 /* Core file support. */
28 /* Sizeof `struct reg' in <machine/reg.h>. */
29 #define ARMBSD_SIZEOF_GREGS (17 * 4)
31 /* Sizeof `struct fpreg' in <machine/reg.h. */
32 #define ARMBSD_SIZEOF_FPREGS ((1 + (8 * 3)) * 4)
34 static int
35 armbsd_fpreg_offset (int regnum)
37 if (regnum == ARM_FPS_REGNUM)
38 return 0;
40 return 4 + (regnum - ARM_F0_REGNUM) * 12;
43 /* Supply register REGNUM from the buffer specified by FPREGS and LEN
44 in the floating-point register set REGSET to register cache
45 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
47 static void
48 armbsd_supply_fpregset (const struct regset *regset,
49 struct regcache *regcache,
50 int regnum, const void *fpregs, size_t len)
52 const gdb_byte *regs = (const gdb_byte *) fpregs;
53 int i;
55 gdb_assert (len >= ARMBSD_SIZEOF_FPREGS);
57 for (i = ARM_F0_REGNUM; i <= ARM_FPS_REGNUM; i++)
59 if (regnum == i || regnum == -1)
60 regcache->raw_supply (i, regs + armbsd_fpreg_offset (i));
64 /* Supply register REGNUM from the buffer specified by GREGS and LEN
65 in the general-purpose register set REGSET to register cache
66 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
68 static void
69 armbsd_supply_gregset (const struct regset *regset,
70 struct regcache *regcache,
71 int regnum, const void *gregs, size_t len)
73 const gdb_byte *regs = (const gdb_byte *) gregs;
74 int i;
76 gdb_assert (len >= ARMBSD_SIZEOF_GREGS);
78 for (i = ARM_A1_REGNUM; i <= ARM_PC_REGNUM; i++)
80 if (regnum == i || regnum == -1)
81 regcache->raw_supply (i, regs + i * 4);
84 if (regnum == ARM_PS_REGNUM || regnum == -1)
85 regcache->raw_supply (i, regs + 16 * 4);
87 if (len >= ARMBSD_SIZEOF_GREGS + ARMBSD_SIZEOF_FPREGS)
89 regs += ARMBSD_SIZEOF_GREGS;
90 len -= ARMBSD_SIZEOF_GREGS;
91 armbsd_supply_fpregset (regset, regcache, regnum, regs, len);
95 /* ARM register sets. */
97 static const struct regset armbsd_gregset =
99 NULL,
100 armbsd_supply_gregset,
101 NULL,
102 REGSET_VARIABLE_SIZE
105 static const struct regset armbsd_fpregset =
107 NULL,
108 armbsd_supply_fpregset
111 /* Iterate over supported core file register note sections. */
113 void
114 armbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
115 iterate_over_regset_sections_cb *cb,
116 void *cb_data,
117 const struct regcache *regcache)
119 cb (".reg", ARMBSD_SIZEOF_GREGS, ARMBSD_SIZEOF_GREGS, &armbsd_gregset, NULL,
120 cb_data);
121 cb (".reg2", ARMBSD_SIZEOF_FPREGS, ARMBSD_SIZEOF_FPREGS, &armbsd_fpregset,
122 NULL, cb_data);