* [PATCH 3/4] Use regcache->tdesc instead of arm_hwcap
2015-07-28 10:00 [PATCH 0/4] GDBserver linux-arm-low.c cleanup Yao Qi
@ 2015-07-28 10:00 ` Yao Qi
2015-07-28 10:00 ` [PATCH 2/4] Don't use arm_regmap and arm_num_regs in arm_fill_gregset and arm_store_gregset Yao Qi
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Yao Qi @ 2015-07-28 10:00 UTC (permalink / raw)
To: gdb-patches
arm_hwcap is a global variable, and we should avoid using it as much
as we can. Instead of checking arm_hwcap, we can check whether
regcache->tdesc is a certain kind of target description. This is
what this patch does.
gdb/gdbserver:
2015-07-28 Yao Qi <yao.qi@linaro.org>
* linux-arm-low.c (arm_fill_wmmxregset): Don't use arm_hwcap.
Use regcache->tdesc instead.
(arm_store_wmmxregset): Likewise.
(arm_fill_vfpregset): Likewise.
(arm_store_vfpregset): Likewise.
---
gdb/gdbserver/linux-arm-low.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index 0a34379..02a1c08 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -185,7 +185,7 @@ arm_fill_wmmxregset (struct regcache *regcache, void *buf)
{
int i;
- if (!(arm_hwcap & HWCAP_IWMMXT))
+ if (regcache->tdesc != tdesc_arm_with_iwmmxt)
return;
for (i = 0; i < 16; i++)
@@ -202,7 +202,7 @@ arm_store_wmmxregset (struct regcache *regcache, const void *buf)
{
int i;
- if (!(arm_hwcap & HWCAP_IWMMXT))
+ if (regcache->tdesc != tdesc_arm_with_iwmmxt)
return;
for (i = 0; i < 16; i++)
@@ -219,13 +219,13 @@ arm_fill_vfpregset (struct regcache *regcache, void *buf)
{
int i, num, base;
- if (!(arm_hwcap & HWCAP_VFP))
- return;
-
- if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
+ if (regcache->tdesc == tdesc_arm_with_neon
+ || regcache->tdesc == tdesc_arm_with_vfpv3)
num = 32;
- else
+ else if (regcache->tdesc == tdesc_arm_with_vfpv2)
num = 16;
+ else
+ return;
base = find_regno (regcache->tdesc, "d0");
for (i = 0; i < num; i++)
@@ -239,13 +239,13 @@ arm_store_vfpregset (struct regcache *regcache, const void *buf)
{
int i, num, base;
- if (!(arm_hwcap & HWCAP_VFP))
- return;
-
- if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
+ if (regcache->tdesc == tdesc_arm_with_neon
+ || regcache->tdesc == tdesc_arm_with_vfpv3)
num = 32;
- else
+ else if (regcache->tdesc == tdesc_arm_with_vfpv2)
num = 16;
+ else
+ return;
base = find_regno (regcache->tdesc, "d0");
for (i = 0; i < num; i++)
--
1.9.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/4] Don't use arm_regmap and arm_num_regs in arm_fill_gregset and arm_store_gregset
2015-07-28 10:00 [PATCH 0/4] GDBserver linux-arm-low.c cleanup Yao Qi
2015-07-28 10:00 ` [PATCH 3/4] Use regcache->tdesc instead of arm_hwcap Yao Qi
@ 2015-07-28 10:00 ` Yao Qi
2015-07-28 10:00 ` [PATCH 4/4] Remove global variable arm_hwcap Yao Qi
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Yao Qi @ 2015-07-28 10:00 UTC (permalink / raw)
To: gdb-patches
In order to align with arm-linux-nat.c counterparts, we don't use
arm_num_regs and arm_regmap in functions arm_fill_gregset and
arm_store_gregset. Instead, we use register numbers. With this
patch applied, arm_fill_gregset and arm_store_gregset don't need
arm_num_regs and arm_regmap, and they will be moved to a separate
file shared for both arm and aarch64 in the following patch series.
gdb/gdbserver:
2015-07-28 Yao Qi <yao.qi@linaro.org>
* linux-arm-low.c: Include arch/arm.h.
(arm_fill_gregset): Don't use arm_num_regs and arm_regmap.
(arm_store_gregset): Likewise.
---
gdb/gdbserver/linux-arm-low.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index 14c96a3..0a34379 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -18,6 +18,7 @@
#include "server.h"
#include "linux-low.h"
+#include "arch/arm.h"
/* Don't include elf.h if linux/elf.h got included by gdb_proc_service.h.
On Bionic elf.h and linux/elf.h have conflicting definitions. */
@@ -154,10 +155,12 @@ static void
arm_fill_gregset (struct regcache *regcache, void *buf)
{
int i;
+ uint32_t *regs = buf;
- for (i = 0; i < arm_num_regs; i++)
- if (arm_regmap[i] != -1)
- collect_register (regcache, i, ((char *) buf) + arm_regmap[i]);
+ for (i = ARM_A1_REGNUM; i <= ARM_PC_REGNUM; i++)
+ collect_register (regcache, i, ®s[i]);
+
+ collect_register (regcache, ARM_PS_REGNUM, ®s[16]);
}
static void
@@ -165,13 +168,16 @@ arm_store_gregset (struct regcache *regcache, const void *buf)
{
int i;
char zerobuf[8];
+ const uint32_t *regs = buf;
memset (zerobuf, 0, 8);
- for (i = 0; i < arm_num_regs; i++)
- if (arm_regmap[i] != -1)
- supply_register (regcache, i, ((char *) buf) + arm_regmap[i]);
- else
- supply_register (regcache, i, zerobuf);
+ for (i = ARM_A1_REGNUM; i <= ARM_PC_REGNUM; i++)
+ supply_register (regcache, i, ®s[i]);
+
+ for (; i < ARM_PS_REGNUM; i++)
+ supply_register (regcache, i, zerobuf);
+
+ supply_register (regcache, ARM_PS_REGNUM, ®s[16]);
}
static void
--
1.9.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFC 1/4] Move ARM register numbers enum to arch/arm.h
2015-07-28 10:00 [PATCH 0/4] GDBserver linux-arm-low.c cleanup Yao Qi
` (2 preceding siblings ...)
2015-07-28 10:00 ` [PATCH 4/4] Remove global variable arm_hwcap Yao Qi
@ 2015-07-28 10:00 ` Yao Qi
2015-07-30 14:08 ` [PATCH 0/4] GDBserver linux-arm-low.c cleanup Yao Qi
4 siblings, 0 replies; 6+ messages in thread
From: Yao Qi @ 2015-07-28 10:00 UTC (permalink / raw)
To: gdb-patches
This patch moves ARM register numbers enum to arch/arm.h, so that it
can used by GDBserver too.
This patch is a RFC because it creates a new directory gdb/arch in which
arch-specific or target-specific files are placed.
gdb:
2015-07-28 Yao Qi <yao.qi@linaro.org>
* arm-tdep.h (enum gdb_regnum): Move it to ...
* arch/arm.h: ... here. New file.
* Makefile.in (HFILES_NO_SRCDIR): Add arch/arm.h.
---
gdb/Makefile.in | 2 +-
gdb/arch/arm.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
gdb/arm-tdep.h | 39 +-----------------------------------
3 files changed, 63 insertions(+), 39 deletions(-)
create mode 100644 gdb/arch/arm.h
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index e7fefd9..4080ba4 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -983,7 +983,7 @@ common/common-debug.h common/cleanups.h common/gdb_setjmp.h \
common/common-exceptions.h target/target.h common/symbol.h \
common/common-regcache.h fbsd-tdep.h nat/linux-personality.h \
common/fileio.h nat/x86-linux.h nat/x86-linux-dregs.h \
-nat/linux-namespaces.h
+nat/linux-namespaces.h arch/arm.h
# Header files that already have srcdir in them, or which are in objdir.
diff --git a/gdb/arch/arm.h b/gdb/arch/arm.h
new file mode 100644
index 0000000..e0eed60
--- /dev/null
+++ b/gdb/arch/arm.h
@@ -0,0 +1,61 @@
+/* Common target dependent code for GDB on ARM systems.
+ Copyright (C) 2002-2015 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef ARM_H
+#define ARM_H
+
+/* Register numbers of various important registers. */
+
+enum gdb_regnum {
+ ARM_A1_REGNUM = 0, /* first integer-like argument */
+ ARM_A4_REGNUM = 3, /* last integer-like argument */
+ ARM_AP_REGNUM = 11,
+ ARM_IP_REGNUM = 12,
+ ARM_SP_REGNUM = 13, /* Contains address of top of stack */
+ ARM_LR_REGNUM = 14, /* address to return to from a function call */
+ ARM_PC_REGNUM = 15, /* Contains program counter */
+ ARM_F0_REGNUM = 16, /* first floating point register */
+ ARM_F3_REGNUM = 19, /* last floating point argument register */
+ ARM_F7_REGNUM = 23, /* last floating point register */
+ ARM_FPS_REGNUM = 24, /* floating point status register */
+ ARM_PS_REGNUM = 25, /* Contains processor status */
+ ARM_WR0_REGNUM, /* WMMX data registers. */
+ ARM_WR15_REGNUM = ARM_WR0_REGNUM + 15,
+ ARM_WC0_REGNUM, /* WMMX control registers. */
+ ARM_WCSSF_REGNUM = ARM_WC0_REGNUM + 2,
+ ARM_WCASF_REGNUM = ARM_WC0_REGNUM + 3,
+ ARM_WC7_REGNUM = ARM_WC0_REGNUM + 7,
+ ARM_WCGR0_REGNUM, /* WMMX general purpose registers. */
+ ARM_WCGR3_REGNUM = ARM_WCGR0_REGNUM + 3,
+ ARM_WCGR7_REGNUM = ARM_WCGR0_REGNUM + 7,
+ ARM_D0_REGNUM, /* VFP double-precision registers. */
+ ARM_D31_REGNUM = ARM_D0_REGNUM + 31,
+ ARM_FPSCR_REGNUM,
+
+ ARM_NUM_REGS,
+
+ /* Other useful registers. */
+ ARM_FP_REGNUM = 11, /* Frame register in ARM code, if used. */
+ THUMB_FP_REGNUM = 7, /* Frame register in Thumb code, if used. */
+ ARM_NUM_ARG_REGS = 4,
+ ARM_LAST_ARG_REGNUM = ARM_A4_REGNUM,
+ ARM_NUM_FP_ARG_REGS = 4,
+ ARM_LAST_FP_ARG_REGNUM = ARM_F3_REGNUM
+};
+
+#endif
diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
index f81679a..3e06f79 100644
--- a/gdb/arm-tdep.h
+++ b/gdb/arm-tdep.h
@@ -24,44 +24,7 @@ struct gdbarch;
struct regset;
struct address_space;
-/* Register numbers of various important registers. */
-
-enum gdb_regnum {
- ARM_A1_REGNUM = 0, /* first integer-like argument */
- ARM_A4_REGNUM = 3, /* last integer-like argument */
- ARM_AP_REGNUM = 11,
- ARM_IP_REGNUM = 12,
- ARM_SP_REGNUM = 13, /* Contains address of top of stack */
- ARM_LR_REGNUM = 14, /* address to return to from a function call */
- ARM_PC_REGNUM = 15, /* Contains program counter */
- ARM_F0_REGNUM = 16, /* first floating point register */
- ARM_F3_REGNUM = 19, /* last floating point argument register */
- ARM_F7_REGNUM = 23, /* last floating point register */
- ARM_FPS_REGNUM = 24, /* floating point status register */
- ARM_PS_REGNUM = 25, /* Contains processor status */
- ARM_WR0_REGNUM, /* WMMX data registers. */
- ARM_WR15_REGNUM = ARM_WR0_REGNUM + 15,
- ARM_WC0_REGNUM, /* WMMX control registers. */
- ARM_WCSSF_REGNUM = ARM_WC0_REGNUM + 2,
- ARM_WCASF_REGNUM = ARM_WC0_REGNUM + 3,
- ARM_WC7_REGNUM = ARM_WC0_REGNUM + 7,
- ARM_WCGR0_REGNUM, /* WMMX general purpose registers. */
- ARM_WCGR3_REGNUM = ARM_WCGR0_REGNUM + 3,
- ARM_WCGR7_REGNUM = ARM_WCGR0_REGNUM + 7,
- ARM_D0_REGNUM, /* VFP double-precision registers. */
- ARM_D31_REGNUM = ARM_D0_REGNUM + 31,
- ARM_FPSCR_REGNUM,
-
- ARM_NUM_REGS,
-
- /* Other useful registers. */
- ARM_FP_REGNUM = 11, /* Frame register in ARM code, if used. */
- THUMB_FP_REGNUM = 7, /* Frame register in Thumb code, if used. */
- ARM_NUM_ARG_REGS = 4,
- ARM_LAST_ARG_REGNUM = ARM_A4_REGNUM,
- ARM_NUM_FP_ARG_REGS = 4,
- ARM_LAST_FP_ARG_REGNUM = ARM_F3_REGNUM
-};
+#include "arch/arm.h"
/* Size of integer registers. */
#define INT_REGISTER_SIZE 4
--
1.9.1
^ permalink raw reply [flat|nested] 6+ messages in thread