* [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 ` Yao Qi
2015-07-28 10:00 ` [PATCH 4/4] Remove global variable arm_hwcap 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
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
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
2015-07-28 10:00 ` [PATCH 4/4] Remove global variable arm_hwcap Yao Qi
@ 2015-07-28 10:00 ` Yao Qi
2015-07-28 10:00 ` [PATCH 3/4] Use regcache->tdesc instead of arm_hwcap 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
* [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
` (2 preceding siblings ...)
2015-07-28 10:00 ` [RFC 1/4] Move ARM register numbers enum to arch/arm.h 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
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 4/4] Remove global variable arm_hwcap
2015-07-28 10:00 [PATCH 0/4] GDBserver linux-arm-low.c cleanup 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
@ 2015-07-28 10:00 ` Yao Qi
2015-07-28 10:00 ` [RFC 1/4] Move ARM register numbers enum to arch/arm.h 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
After previous patch, we don't need global variable arm_hwcap. This
patch is to remove it.
gdb/gdbserver:
2015-07-28 Yao Qi <yao.qi@linaro.org>
* linux-arm-low.c (arm_hwcap): Remove it.
(arm_read_description): New local variable arm_hwcap. Don't
set arm_hwcap to zero.
---
gdb/gdbserver/linux-arm-low.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index 02a1c08..3c5956b 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -117,8 +117,6 @@ struct arch_lwp_info
CORE_ADDR stopped_data_address;
};
-static unsigned long arm_hwcap;
-
/* These are in <asm/elf.h> in current kernels. */
#define HWCAP_VFP 64
#define HWCAP_IWMMXT 512
@@ -844,11 +842,11 @@ static const struct target_desc *
arm_read_description (void)
{
int pid = lwpid_of (current_thread);
+ unsigned long arm_hwcap = 0;
/* Query hardware watchpoint/breakpoint capabilities. */
arm_linux_init_hwbp_cap (pid);
- arm_hwcap = 0;
if (arm_get_hwcap (&arm_hwcap) == 0)
return tdesc_arm;
@@ -875,10 +873,8 @@ arm_read_description (void)
buf = xmalloc (32 * 8 + 4);
if (ptrace (PTRACE_GETVFPREGS, pid, 0, buf) < 0
&& errno == EIO)
- {
- arm_hwcap = 0;
- result = tdesc_arm;
- }
+ result = tdesc_arm;
+
free (buf);
return result;
--
1.9.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 0/4] GDBserver linux-arm-low.c cleanup
@ 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
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Yao Qi @ 2015-07-28 10:00 UTC (permalink / raw)
To: gdb-patches
This patch series is to clean up gdbserver/linux-arm-low.c, as a
preparation for the aarch64 multi-arch debugging gdbserver patches.
All of them are tested on panda board (vfpv3) and qemu system mode
(vfpv2).
*** BLURB HERE ***
Yao Qi (4):
Move ARM register numbers enum to arch/arm.h
Don't use arm_regmap and arm_num_regs in arm_fill_gregset and
arm_store_gregset
Use regcache->tdesc instead of arm_hwcap
Remove global variable arm_hwcap
gdb/Makefile.in | 2 +-
gdb/arch/arm.h | 61 +++++++++++++++++++++++++++++++++++++++++++
gdb/arm-tdep.h | 39 +--------------------------
gdb/gdbserver/linux-arm-low.c | 56 ++++++++++++++++++++-------------------
4 files changed, 92 insertions(+), 66 deletions(-)
create mode 100644 gdb/arch/arm.h
--
1.9.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] GDBserver linux-arm-low.c cleanup
2015-07-28 10:00 [PATCH 0/4] GDBserver linux-arm-low.c cleanup Yao Qi
` (3 preceding siblings ...)
2015-07-28 10:00 ` [PATCH 3/4] Use regcache->tdesc instead of arm_hwcap Yao Qi
@ 2015-07-30 14:08 ` Yao Qi
4 siblings, 0 replies; 6+ messages in thread
From: Yao Qi @ 2015-07-30 14:08 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
Yao Qi <qiyaoltc@gmail.com> writes:
> This patch series is to clean up gdbserver/linux-arm-low.c, as a
> preparation for the aarch64 multi-arch debugging gdbserver patches.
>
> All of them are tested on panda board (vfpv3) and qemu system mode
> (vfpv2).
I pushed them in.
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-07-30 14:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-28 10:00 [PATCH 0/4] GDBserver linux-arm-low.c cleanup 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
2015-07-28 10:00 ` [PATCH 4/4] Remove global variable arm_hwcap Yao Qi
2015-07-28 10:00 ` [RFC 1/4] Move ARM register numbers enum to arch/arm.h Yao Qi
2015-07-28 10:00 ` [PATCH 3/4] Use regcache->tdesc instead of arm_hwcap Yao Qi
2015-07-30 14:08 ` [PATCH 0/4] GDBserver linux-arm-low.c cleanup Yao Qi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).