1 /* Copyright (C) 1995-2015 Free Software Foundation, Inc.
3 This file is part of GDB.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "linux-low.h"
21 #include "linux-aarch32-low.h"
23 #include <sys/ptrace.h>
24 /* Don't include elf.h if linux/elf.h got included by gdb_proc_service.h.
25 On Bionic elf.h and linux/elf.h have conflicting definitions. */
30 /* Some older versions of GNU/Linux and Android do not define
31 the following macros. */
33 #define NT_ARM_VFP 0x400
36 /* Collect GP registers from REGCACHE to buffer BUF. */
39 arm_fill_gregset (struct regcache
*regcache
, void *buf
)
42 uint32_t *regs
= (uint32_t *) buf
;
44 for (i
= ARM_A1_REGNUM
; i
<= ARM_PC_REGNUM
; i
++)
45 collect_register (regcache
, i
, ®s
[i
]);
47 collect_register (regcache
, ARM_PS_REGNUM
, ®s
[16]);
50 /* Supply GP registers contents, stored in BUF, to REGCACHE. */
53 arm_store_gregset (struct regcache
*regcache
, const void *buf
)
57 const uint32_t *regs
= (const uint32_t *) buf
;
59 memset (zerobuf
, 0, 8);
60 for (i
= ARM_A1_REGNUM
; i
<= ARM_PC_REGNUM
; i
++)
61 supply_register (regcache
, i
, ®s
[i
]);
63 for (; i
< ARM_PS_REGNUM
; i
++)
64 supply_register (regcache
, i
, zerobuf
);
66 supply_register (regcache
, ARM_PS_REGNUM
, ®s
[16]);
69 /* Collect NUM number of VFP registers from REGCACHE to buffer BUF. */
72 arm_fill_vfpregset_num (struct regcache
*regcache
, void *buf
, int num
)
76 gdb_assert (num
== 16 || num
== 32);
78 base
= find_regno (regcache
->tdesc
, "d0");
79 for (i
= 0; i
< num
; i
++)
80 collect_register (regcache
, base
+ i
, (char *) buf
+ i
* 8);
82 collect_register_by_name (regcache
, "fpscr", (char *) buf
+ 32 * 8);
85 /* Supply NUM number of VFP registers contents, stored in BUF, to
89 arm_store_vfpregset_num (struct regcache
*regcache
, const void *buf
, int num
)
93 gdb_assert (num
== 16 || num
== 32);
95 base
= find_regno (regcache
->tdesc
, "d0");
96 for (i
= 0; i
< num
; i
++)
97 supply_register (regcache
, base
+ i
, (char *) buf
+ i
* 8);
99 supply_register_by_name (regcache
, "fpscr", (char *) buf
+ 32 * 8);
103 arm_fill_vfpregset (struct regcache
*regcache
, void *buf
)
105 arm_fill_vfpregset_num (regcache
, buf
, 32);
109 arm_store_vfpregset (struct regcache
*regcache
, const void *buf
)
111 arm_store_vfpregset_num (regcache
, buf
, 32);
114 /* Register sets with using PTRACE_GETREGSET. */
116 static struct regset_info aarch32_regsets
[] = {
117 { PTRACE_GETREGSET
, PTRACE_SETREGSET
, NT_PRSTATUS
, 18 * 4,
119 arm_fill_gregset
, arm_store_gregset
},
120 { PTRACE_GETREGSET
, PTRACE_SETREGSET
, NT_ARM_VFP
, 32 * 8 + 4,
122 arm_fill_vfpregset
, arm_store_vfpregset
},
126 static struct regsets_info aarch32_regsets_info
=
128 aarch32_regsets
, /* regsets */
130 NULL
, /* disabled_regsets */
133 struct regs_info regs_info_aarch32
=
135 NULL
, /* regset_bitmap */
137 &aarch32_regsets_info
141 initialize_low_arch_aarch32 (void)
143 init_registers_arm_with_neon ();
145 initialize_regsets_info (&aarch32_regsets_info
);