GDB (xrefs)

/tmp/gdb-8.1/gdb/aarch32-linux-nat.c
Go to the documentation of this file.
1 /* Copyright (C) 1999-2018 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 "defs.h"
19
20 #include "regcache.h"
21 #include "arm-tdep.h"
22 #include "arm-linux-tdep.h"
23 #include "arch/arm-linux.h"
24
25 #include "aarch32-linux-nat.h"
26
27 /* Supply GP registers contents, stored in REGS, to REGCACHE. ARM_APCS_32
28 is true if the 32-bit mode is in use, otherwise, it is false. */
29
30 void
31 aarch32_gp_regcache_supply (struct regcache *regcache, uint32_t *regs,
32 int arm_apcs_32)
33 {
34 int regno;
35
36 for (regno = ARM_A1_REGNUM; regno < ARM_PC_REGNUM; regno++)
37 regcache_raw_supply (regcache, regno, &regs[regno]);
38
39 if (arm_apcs_32)
40 {
41 /* Clear reserved bits bit 20 to bit 23. */
42 regs[ARM_CPSR_GREGNUM] &= 0xff0fffff;
43 regcache_raw_supply (regcache, ARM_PS_REGNUM, &regs[ARM_CPSR_GREGNUM]);
44 }
45 else
46 regcache_raw_supply (regcache, ARM_PS_REGNUM, &regs[ARM_PC_REGNUM]);
47
48 regs[ARM_PC_REGNUM] = gdbarch_addr_bits_remove
49 (regcache->arch (), regs[ARM_PC_REGNUM]);
50 regcache_raw_supply (regcache, ARM_PC_REGNUM, &regs[ARM_PC_REGNUM]);
51 }
52
53 /* Collect GP registers from REGCACHE to buffer REGS. ARM_APCS_32 is
54 true if the 32-bit mode is in use, otherwise, it is false. */
55
56 void
57 aarch32_gp_regcache_collect (const struct regcache *regcache, uint32_t *regs,
58 int arm_apcs_32)
59 {
60 int regno;
61
62 for (regno = ARM_A1_REGNUM; regno <= ARM_PC_REGNUM; regno++)
63 {
64 if (REG_VALID == regcache_register_status (regcache, regno))
65 regcache_raw_collect (regcache, regno, &regs[regno]);
66 }
67
68 if (arm_apcs_32
69 && REG_VALID == regcache_register_status (regcache, ARM_PS_REGNUM))
70 {
71 uint32_t cpsr = regs[ARM_CPSR_GREGNUM];
72
73 regcache_raw_collect (regcache, ARM_PS_REGNUM,
74 &regs[ARM_CPSR_GREGNUM]);
75 /* Keep reserved bits bit 20 to bit 23. */
76 regs[ARM_CPSR_GREGNUM] = ((regs[ARM_CPSR_GREGNUM] & 0xff0fffff)
77 | (cpsr & 0x00f00000));
78 }
79 }
80
81 /* Supply VFP registers contents, stored in REGS, to REGCACHE.
82 VFP_REGISTER_COUNT is the number of VFP registers. */
83
84 void
85 aarch32_vfp_regcache_supply (struct regcache *regcache, gdb_byte *regs,
86 const int vfp_register_count)
87 {
88 int regno;
89
90 for (regno = 0; regno < vfp_register_count; regno++)
91 regcache_raw_supply (regcache, regno + ARM_D0_REGNUM,
92 regs + regno * 8);
93
94 regcache_raw_supply (regcache, ARM_FPSCR_REGNUM,
95 regs + 32 * 8);
96 }
97
98 /* Collect VFP registers from REGCACHE to buffer REGS.
99 VFP_REGISTER_COUNT is the number VFP registers. */
100
101 void
102 aarch32_vfp_regcache_collect (const struct regcache *regcache, gdb_byte *regs,
103 const int vfp_register_count)
104 {
105 int regno;
106
107 for (regno = 0; regno < vfp_register_count; regno++)
108 regcache_raw_collect (regcache, regno + ARM_D0_REGNUM, regs + regno * 8);
109
110 regcache_raw_collect (regcache, ARM_FPSCR_REGNUM, regs + 32 * 8);
111 }
REG_VALID
Definition: common-regcache.h:32
ARM_D0_REGNUM
Definition: arm.h:46
aarch32_gp_regcache_collect
void aarch32_gp_regcache_collect(const struct regcache *regcache, uint32_t *regs, int arm_apcs_32)
Definition: aarch32-linux-nat.c:57
arm-linux-tdep.h
arm_apcs_32
int arm_apcs_32
Definition: arm-tdep.c:281
defs.h
arm-tdep.h
gdbarch_addr_bits_remove
CORE_ADDR gdbarch_addr_bits_remove(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: gdbarch.c:3208
aarch32_vfp_regcache_supply
void aarch32_vfp_regcache_supply(struct regcache *regcache, gdb_byte *regs, const int vfp_register_count)
Definition: aarch32-linux-nat.c:85
regcache.h
arm-linux.h
ARM_A1_REGNUM
Definition: arm.h:25
ARM_FPSCR_REGNUM
Definition: arm.h:48
gdb_byte
bfd_byte gdb_byte
Definition: common-types.h:38
regcache_register_status
enum register_status regcache_register_status(const struct regcache *regcache, int regnum)
Definition: regcache.c:359
ARM_PS_REGNUM
Definition: arm.h:36
regcache::arch
gdbarch * arch() const
Definition: regcache.c:221
aarch32-linux-nat.h
regcache_raw_supply
void regcache_raw_supply(struct regcache *regcache, int regnum, const void *buf)
Definition: regcache.c:1004
regcache
Definition: regcache.h:232
aarch32_vfp_regcache_collect
void aarch32_vfp_regcache_collect(const struct regcache *regcache, gdb_byte *regs, const int vfp_register_count)
Definition: aarch32-linux-nat.c:102
aarch32_gp_regcache_supply
void aarch32_gp_regcache_supply(struct regcache *regcache, uint32_t *regs, int arm_apcs_32)
Definition: aarch32-linux-nat.c:31
regcache_raw_collect
void regcache_raw_collect(const struct regcache *regcache, int regnum, void *buf)
Definition: regcache.c:1085
ARM_CPSR_GREGNUM
#define ARM_CPSR_GREGNUM
Definition: arm-linux.h:24
ARM_PC_REGNUM
Definition: arm.h:31