public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/8] [PowerPC] Consolidate linux vector regset sizes
Date: Thu, 10 May 2018 19:59:00 -0000	[thread overview]
Message-ID: <20180510195840.17734-5-pedromfc@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180510195840.17734-1-pedromfc@linux.vnet.ibm.com>

This patch defines constants for the sizes of the two vector
regsets (vector-scalar registers and regular vector registers).

The native, gdbserver and core file targets are changed to use these
constants.

The Linux ptrace calls return (or read) a smaller regset than the one
found in core files for vector registers, because ptrace uses a single
4-byte quantity for vrsave at the end of the regset, while the
core-file regset uses a full 16-byte field for vrsave. For simplicity,
the larger size is used in both cases, and so a buffer with 12 unused
additional bytes is passed to ptrace in the native target.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

	* arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_VRREGSET)
	(PPC_LINUX_SIZEOF_VSXREGSET): Define.
	* ppc-linux-nat.c (SIZEOF_VSXREGS, SIZEOF_VRREGS): Remove.
	(gdb_vrregset_t): Change array type size to
	PPC_LINUX_SIZEOF_VRREGSET.
	(gdb_vsxregset_t): Change array type size to
	PPC_LINUX_SIZEOF_VSXREGSET.
	* ppc-linux-tdep.c (ppc_linux_iterate_over_regset_sections):
	Change integer literals to PPC_LINUX_SIZEOF_VRREGSET and
	PPC_LINUX_SIZEOF_VSXREGSET.

gdb/gdbserver/ChangeLog:
yyyy-mm-dd  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

	* linux-ppc-low.c (SIZEOF_VSXREGS, SIZEOF_VRREGS): Remove.
	(ppc_arch_setup): Change SIZEOF_VRREGS and SIZEOF_VSXREGS to
	PPC_LINUX_SIZEOF_VRREGSET and PPC_LINUX_SIZEOF_VSXREGSET.
---
 gdb/arch/ppc-linux-common.h   | 9 +++++++++
 gdb/gdbserver/linux-ppc-low.c | 8 ++------
 gdb/ppc-linux-nat.c           | 8 ++------
 gdb/ppc-linux-tdep.c          | 6 ++++--
 4 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/gdb/arch/ppc-linux-common.h b/gdb/arch/ppc-linux-common.h
index a25f74f7f7..d0849e7c04 100644
--- a/gdb/arch/ppc-linux-common.h
+++ b/gdb/arch/ppc-linux-common.h
@@ -22,6 +22,15 @@
 
 struct target_desc;
 
+/* The core file VMX regset has 34 16-byte fields (32 16-byte vector
+   registers, plus two fields containing 4-byte registers, VSCR and
+   VRSAVE), while the ptrace calls return or read 33 16-byte fields
+   plus a 4-byte field for VRSAVE. For simplicity we use the longer
+   length for both cases.  */
+#define PPC_LINUX_SIZEOF_VRREGSET 544
+
+#define PPC_LINUX_SIZEOF_VSXREGSET 256
+
 /* Check if the hwcap auxv entry indicates that isa205 is supported.  */
 bool ppc_linux_has_isa205 (unsigned long hwcap);
 
diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c
index 825b46219c..ed48fa7850 100644
--- a/gdb/gdbserver/linux-ppc-low.c
+++ b/gdb/gdbserver/linux-ppc-low.c
@@ -459,8 +459,6 @@ static void ppc_fill_gregset (struct regcache *regcache, void *buf)
     ppc_collect_ptrace_register (regcache, i, (char *) buf + ppc_regmap[i]);
 }
 
-#define SIZEOF_VSXREGS 32*8
-
 static void
 ppc_fill_vsxregset (struct regcache *regcache, void *buf)
 {
@@ -483,8 +481,6 @@ ppc_store_vsxregset (struct regcache *regcache, const void *buf)
     supply_register (regcache, base + i, &regset[i * 8]);
 }
 
-#define SIZEOF_VRREGS 33*16+4
-
 static void
 ppc_fill_vrregset (struct regcache *regcache, void *buf)
 {
@@ -660,10 +656,10 @@ ppc_arch_setup (void)
     switch (regset->get_request)
       {
       case PTRACE_GETVRREGS:
-	regset->size = features.altivec ? SIZEOF_VRREGS : 0;
+	regset->size = features.altivec ? PPC_LINUX_SIZEOF_VRREGSET : 0;
 	break;
       case PTRACE_GETVSXREGS:
-	regset->size = features.vsx ? SIZEOF_VSXREGS : 0;
+	regset->size = features.vsx ? PPC_LINUX_SIZEOF_VSXREGSET : 0;
 	break;
       case PTRACE_GETEVRREGS:
 	if (ppc_hwcap & PPC_FEATURE_HAS_SPE)
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 07ec53d1ea..554aba662e 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -174,9 +174,7 @@ struct ppc_hw_breakpoint
 */
 /* *INDENT-ON* */
 
-#define SIZEOF_VRREGS 33*16+4
-
-typedef char gdb_vrregset_t[SIZEOF_VRREGS];
+typedef char gdb_vrregset_t[PPC_LINUX_SIZEOF_VRREGSET];
 
 /* This is the layout of the POWER7 VSX registers and the way they overlap
    with the existing FPR and VMX registers.
@@ -210,9 +208,7 @@ typedef char gdb_vrregset_t[SIZEOF_VRREGS];
    the FP registers (doubleword 0) and hence extend them with additional
    64 bits (doubleword 1).  The other 32 regs overlap with the VMX
    registers.  */
-#define SIZEOF_VSXREGS 32*8
-
-typedef char gdb_vsxregset_t[SIZEOF_VSXREGS];
+typedef char gdb_vsxregset_t[PPC_LINUX_SIZEOF_VSXREGSET];
 
 /* On PPC processors that support the Signal Processing Extension
    (SPE) APU, the general-purpose registers are 64 bits long.
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 1d3b019c30..344069d752 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -557,10 +557,12 @@ ppc_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
   cb (".reg2", 264, &ppc32_linux_fpregset, NULL, cb_data);
 
   if (have_altivec)
-    cb (".reg-ppc-vmx", 544, &ppc32_linux_vrregset, "ppc Altivec", cb_data);
+    cb (".reg-ppc-vmx", PPC_LINUX_SIZEOF_VRREGSET, &ppc32_linux_vrregset,
+	"ppc Altivec", cb_data);
 
   if (have_vsx)
-    cb (".reg-ppc-vsx", 256, &ppc32_linux_vsxregset, "POWER7 VSX", cb_data);
+    cb (".reg-ppc-vsx", PPC_LINUX_SIZEOF_VSXREGSET,
+	&ppc32_linux_vsxregset, "POWER7 VSX", cb_data);
 }
 
 static void
-- 
2.13.6

  reply	other threads:[~2018-05-10 19:59 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-10 19:59 [PATCH 0/8] [PowerPC] Miscellaneous fixes for register access Pedro Franco de Carvalho
2018-05-10 19:59 ` Pedro Franco de Carvalho [this message]
2018-05-16 16:35   ` [PATCH 4/8] [PowerPC] Consolidate linux vector regset sizes Ulrich Weigand
2018-05-10 19:59 ` [PATCH 3/8] [PowerPC] Disable regsets using zero sizes in gdbserver Pedro Franco de Carvalho
2018-05-16 16:17   ` Ulrich Weigand
2018-05-10 19:59 ` [PATCH 1/8] [PowerPC] Consolidate linux target description selection Pedro Franco de Carvalho
2018-05-16 14:05   ` Ulrich Weigand
2018-05-16 22:50     ` Pedro Franco de Carvalho
2018-05-17  8:28       ` Ulrich Weigand
2018-05-10 20:00 ` [PATCH 8/8] [PowerPC] Recognize isa205 in linux core files Pedro Franco de Carvalho
2018-05-16 15:53   ` Ulrich Weigand
2018-05-16 23:32     ` Pedro Franco de Carvalho
2018-05-17 10:22       ` Ulrich Weigand
2018-05-21 20:46         ` Pedro Franco de Carvalho
2018-05-22 12:48           ` Ulrich Weigand
2018-05-22 14:33             ` Pedro Franco de Carvalho
2018-05-10 20:33 ` [PATCH 6/8] [PowerPC] Fix VSX registers " Pedro Franco de Carvalho
2018-05-16 14:18   ` Ulrich Weigand
2018-05-10 20:33 ` [PATCH 2/8] [PowerPC] Consolidate wordsize getter between native and gdbserver Pedro Franco de Carvalho
2018-05-16 15:54   ` Ulrich Weigand
2018-05-10 21:46 ` [PATCH 5/8] [PowerPC] Fix access to VSCR in linux targets Pedro Franco de Carvalho
2018-05-16 14:06   ` Ulrich Weigand
2018-05-17 21:25     ` Pedro Franco de Carvalho
2018-05-18 15:37       ` Ulrich Weigand
2018-05-21 20:46     ` Pedro Franco de Carvalho
2018-05-22 12:56       ` Ulrich Weigand
2018-05-10 22:25 ` [PATCH 7/8] [PowerPC] Fix inclusion of dfp pseudoregs in tdep Pedro Franco de Carvalho
2018-05-16 14:18   ` Ulrich Weigand
2018-05-21 20:46 ` [PATCH v2 1/8] [PowerPC] Consolidate linux target description selection Pedro Franco de Carvalho
2018-05-21 20:46   ` [PATCH v2 3/8] [PowerPC] Disable regsets using zero sizes in gdbserver Pedro Franco de Carvalho
2018-05-22 12:48     ` Ulrich Weigand
2018-05-21 20:46   ` [PATCH v2 4/8] [PowerPC] Consolidate linux vector regset sizes Pedro Franco de Carvalho
2018-05-22 12:48     ` Ulrich Weigand
2018-05-21 20:46   ` [PATCH v2 2/8] [PowerPC] Consolidate wordsize getter between native and gdbserver Pedro Franco de Carvalho
2018-05-22 12:56     ` Ulrich Weigand
2018-05-21 23:45   ` [PATCH v2 5/8] [PowerPC] Fix access to VSCR in linux targets Pedro Franco de Carvalho
2018-05-22 12:56     ` Ulrich Weigand
2018-05-21 23:55   ` [PATCH v2 8/8] [PowerPC] Recognize isa205 in linux core files Pedro Franco de Carvalho
2018-05-22 13:34     ` Ulrich Weigand
2018-05-21 23:56   ` [PATCH v2 7/8] [PowerPC] Fix inclusion of dfp pseudoregs in tdep Pedro Franco de Carvalho
2018-05-22 12:56     ` Ulrich Weigand
2018-05-22  0:54   ` [PATCH v2 6/8] [PowerPC] Fix VSX registers in linux core files Pedro Franco de Carvalho
2018-05-22 13:46     ` Ulrich Weigand
2018-05-22 12:48   ` [PATCH v2 1/8] [PowerPC] Consolidate linux target description selection Ulrich Weigand

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=20180510195840.17734-5-pedromfc@linux.vnet.ibm.com \
    --to=pedromfc@linux.vnet.ibm.com \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).