PR mi/18833 gdb.execute ("set param value", to_string=True) will crash gdb if using MI
[deliverable/binutils-gdb.git] / gdb / gdbserver / linux-aarch32-low.c
CommitLineData
bd9e6534
YQ
1/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
2
3 This file is part of GDB.
4
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.
9
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.
14
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/>. */
17
18#include "server.h"
19#include "arch/arm.h"
20#include "linux-low.h"
21#include "linux-aarch32-low.h"
22
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. */
26#ifndef ELFMAG0
27#include <elf.h>
28#endif
29
30/* Collect GP registers from REGCACHE to buffer BUF. */
31
32void
33arm_fill_gregset (struct regcache *regcache, void *buf)
34{
35 int i;
36 uint32_t *regs = buf;
37
38 for (i = ARM_A1_REGNUM; i <= ARM_PC_REGNUM; i++)
39 collect_register (regcache, i, &regs[i]);
40
41 collect_register (regcache, ARM_PS_REGNUM, &regs[16]);
42}
43
44/* Supply GP registers contents, stored in BUF, to REGCACHE. */
45
46void
47arm_store_gregset (struct regcache *regcache, const void *buf)
48{
49 int i;
50 char zerobuf[8];
51 const uint32_t *regs = buf;
52
53 memset (zerobuf, 0, 8);
54 for (i = ARM_A1_REGNUM; i <= ARM_PC_REGNUM; i++)
55 supply_register (regcache, i, &regs[i]);
56
57 for (; i < ARM_PS_REGNUM; i++)
58 supply_register (regcache, i, zerobuf);
59
60 supply_register (regcache, ARM_PS_REGNUM, &regs[16]);
61}
62
63/* Collect NUM number of VFP registers from REGCACHE to buffer BUF. */
64
65void
66arm_fill_vfpregset_num (struct regcache *regcache, void *buf, int num)
67{
68 int i, base;
69
70 gdb_assert (num == 16 || num == 32);
71
72 base = find_regno (regcache->tdesc, "d0");
73 for (i = 0; i < num; i++)
74 collect_register (regcache, base + i, (char *) buf + i * 8);
75
76 collect_register_by_name (regcache, "fpscr", (char *) buf + 32 * 8);
77}
78
79/* Supply NUM number of VFP registers contents, stored in BUF, to
80 REGCACHE. */
81
82void
83arm_store_vfpregset_num (struct regcache *regcache, const void *buf, int num)
84{
85 int i, base;
86
87 gdb_assert (num == 16 || num == 32);
88
89 base = find_regno (regcache->tdesc, "d0");
90 for (i = 0; i < num; i++)
91 supply_register (regcache, base + i, (char *) buf + i * 8);
92
93 supply_register_by_name (regcache, "fpscr", (char *) buf + 32 * 8);
94}
95
96static void
97arm_fill_vfpregset (struct regcache *regcache, void *buf)
98{
99 arm_fill_vfpregset_num (regcache, buf, 32);
100}
101
102static void
103arm_store_vfpregset (struct regcache *regcache, const void *buf)
104{
105 arm_store_vfpregset_num (regcache, buf, 32);
106}
107
108/* Register sets with using PTRACE_GETREGSET. */
109
110static struct regset_info aarch32_regsets[] = {
111 { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS, 18 * 4,
112 GENERAL_REGS,
113 arm_fill_gregset, arm_store_gregset },
114 { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_VFP, 32 * 8 + 4,
115 EXTENDED_REGS,
116 arm_fill_vfpregset, arm_store_vfpregset },
117 { 0, 0, 0, -1, -1, NULL, NULL }
118};
119
120static struct regsets_info aarch32_regsets_info =
121 {
122 aarch32_regsets, /* regsets */
123 0, /* num_regsets */
124 NULL, /* disabled_regsets */
125 };
126
127struct regs_info regs_info_aarch32 =
128 {
129 NULL, /* regset_bitmap */
130 NULL, /* usrregs */
131 &aarch32_regsets_info
132 };
133
134void
135initialize_low_arch_aarch32 (void)
136{
137 init_registers_arm_with_neon ();
138
139 initialize_regsets_info (&aarch32_regsets_info);
140}
This page took 0.034306 seconds and 4 git commands to generate.