From: Alan Hayward <Alan.Hayward@arm.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: nd <nd@arm.com>, Alan Hayward <Alan.Hayward@arm.com>
Subject: [PATCH 1/7] Arm: Minor style cleanups
Date: Fri, 05 Jul 2019 09:46:00 -0000 [thread overview]
Message-ID: <20190705094525.51536-2-alan.hayward@arm.com> (raw)
In-Reply-To: <20190705094525.51536-1-alan.hayward@arm.com>
*When reading a target description, do the ptrace check before picking the
target description.
*In wmmxregset functions, declare the counter inside the for.
*Call arm_linux_init_hwbp_cap from in arm_arch_setup - it doesn't belong in
arm_read_description.
gdb/ChangeLog:
2019-07-05 Alan Hayward <alan.hayward@arm.com>
* arm-linux-nat.c (arm_linux_nat_target::read_description): Check
ptrace earlier,
gdb/gdbserver/ChangeLog:
2019-07-05 Alan Hayward <alan.hayward@arm.com>
* linux-arm-low.c (arm_fill_wmmxregset, arm_store_wmmxregset):
Move counter inside for.
(arm_read_description): Check ptrace earlier.
(arm_arch_setup): Call arm_linux_init_hwbp_cap here.
---
gdb/arm-linux-nat.c | 27 ++++++++------------
gdb/gdbserver/linux-arm-low.c | 46 +++++++++++++----------------------
2 files changed, 27 insertions(+), 46 deletions(-)
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index a1ad6fe01e..fe8a113a27 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -555,29 +555,22 @@ arm_linux_nat_target::read_description ()
if (arm_hwcap & HWCAP_VFP)
{
- int pid;
- char *buf;
- const struct target_desc * result = NULL;
+ /* Make sure that the kernel supports reading VFP registers. Support was
+ added in 2.6.30. */
+ int pid = inferior_ptid.lwp ();
+ errno = 0;
+ char *buf = (char *) alloca (ARM_VFP3_REGS_SIZE);
+ if (ptrace (PTRACE_GETVFPREGS, pid, 0, buf) < 0 && errno == EIO)
+ return nullptr;
/* NEON implies VFPv3-D32 or no-VFP unit. Say that we only support
Neon with VFPv3-D32. */
if (arm_hwcap & HWCAP_NEON)
- result = tdesc_arm_with_neon;
+ return tdesc_arm_with_neon;
else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
- result = tdesc_arm_with_vfpv3;
+ return tdesc_arm_with_vfpv3;
else
- result = tdesc_arm_with_vfpv2;
-
- /* Now make sure that the kernel supports reading these
- registers. Support was added in 2.6.30. */
- pid = inferior_ptid.lwp ();
- errno = 0;
- buf = (char *) alloca (ARM_VFP3_REGS_SIZE);
- if (ptrace (PTRACE_GETVFPREGS, pid, 0, buf) < 0
- && errno == EIO)
- result = NULL;
-
- return result;
+ return tdesc_arm_with_vfpv2;
}
return this->beneath ()->read_description ();
diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index b323b19078..7d6c9d9dd9 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -175,16 +175,14 @@ arm_cannot_fetch_register (int regno)
static void
arm_fill_wmmxregset (struct regcache *regcache, void *buf)
{
- int i;
-
if (regcache->tdesc != tdesc_arm_with_iwmmxt)
return;
- for (i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++)
collect_register (regcache, arm_num_regs + i, (char *) buf + i * 8);
/* We only have access to wcssf, wcasf, and wcgr0-wcgr3. */
- for (i = 0; i < 6; i++)
+ for (int i = 0; i < 6; i++)
collect_register (regcache, arm_num_regs + i + 16,
(char *) buf + 16 * 8 + i * 4);
}
@@ -192,16 +190,14 @@ arm_fill_wmmxregset (struct regcache *regcache, void *buf)
static void
arm_store_wmmxregset (struct regcache *regcache, const void *buf)
{
- int i;
-
if (regcache->tdesc != tdesc_arm_with_iwmmxt)
return;
- for (i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++)
supply_register (regcache, arm_num_regs + i, (char *) buf + i * 8);
/* We only have access to wcssf, wcasf, and wcgr0-wcgr3. */
- for (i = 0; i < 6; i++)
+ for (int i = 0; i < 6; i++)
supply_register (regcache, arm_num_regs + i + 16,
(char *) buf + 16 * 8 + i * 4);
}
@@ -850,40 +846,29 @@ get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self)
static const struct target_desc *
arm_read_description (void)
{
- int pid = lwpid_of (current_thread);
unsigned long arm_hwcap = linux_get_hwcap (4);
- /* Query hardware watchpoint/breakpoint capabilities. */
- arm_linux_init_hwbp_cap (pid);
-
if (arm_hwcap & HWCAP_IWMMXT)
return tdesc_arm_with_iwmmxt;
if (arm_hwcap & HWCAP_VFP)
{
- const struct target_desc *result;
- char *buf;
+ /* Make sure that the kernel supports reading VFP registers. Support was
+ added in 2.6.30. */
+ int pid = lwpid_of (current_thread);
+ errno = 0;
+ char *buf = (char *) alloca (ARM_VFP3_REGS_SIZE);
+ if (ptrace (PTRACE_GETVFPREGS, pid, 0, buf) < 0 && errno == EIO)
+ return tdesc_arm;
/* NEON implies either no VFP, or VFPv3-D32. We only support
it with VFP. */
if (arm_hwcap & HWCAP_NEON)
- result = tdesc_arm_with_neon;
+ return tdesc_arm_with_neon;
else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
- result = tdesc_arm_with_vfpv3;
+ return tdesc_arm_with_vfpv3;
else
- result = tdesc_arm_with_vfpv2;
-
- /* Now make sure that the kernel supports reading these
- registers. Support was added in 2.6.30. */
- errno = 0;
- buf = (char *) xmalloc (ARM_VFP3_REGS_SIZE);
- if (ptrace (PTRACE_GETVFPREGS, pid, 0, buf) < 0
- && errno == EIO)
- result = tdesc_arm;
-
- free (buf);
-
- return result;
+ return tdesc_arm_with_vfpv2;
}
/* The default configuration uses legacy FPA registers, probably
@@ -898,6 +883,9 @@ arm_arch_setup (void)
int gpregs[18];
struct iovec iov;
+ /* Query hardware watchpoint/breakpoint capabilities. */
+ arm_linux_init_hwbp_cap (tid);
+
current_process ()->tdesc = arm_read_description ();
iov.iov_base = gpregs;
--
2.20.1 (Apple Git-117)
prev parent reply other threads:[~2019-07-05 9:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-05 9:46 [PATCH 0/7] Arm: Use feature target descriptions Alan Hayward
2019-07-05 9:45 ` [PATCH 4/7] " Alan Hayward
2019-07-05 9:45 ` [PATCH 3/7] Arm: Add read_description read funcs and use in GDB Alan Hayward
2019-07-10 3:45 ` Simon Marchi
2019-07-10 13:52 ` Alan Hayward
2019-07-10 14:26 ` Alan Hayward
2019-07-10 16:05 ` Simon Marchi
2019-07-10 16:07 ` Simon Marchi
2019-07-10 16:15 ` Alan Hayward
2019-07-05 9:46 ` [PATCH 2/7] Arm: Create feature files for Arm target descriptions Alan Hayward
2019-07-10 2:56 ` Simon Marchi
2019-07-10 13:22 ` Alan Hayward
2019-07-05 9:46 ` [PATCH 7/7] Arm: Remove unused feature files and tests Alan Hayward
2019-07-05 9:46 ` [PATCH 6/7] Arm: Use read_description funcs in gdbserver Alan Hayward
2019-07-10 4:04 ` Simon Marchi
2019-07-10 15:44 ` Alan Hayward
2019-07-05 9:46 ` [PATCH 5/7] Arm: Add xml unit tests Alan Hayward
2019-07-05 9:46 ` Alan Hayward [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190705094525.51536-2-alan.hayward@arm.com \
--to=alan.hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=nd@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox