public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [OBV/PUSHED][PATCH] AArch64: Ensure regcache is reset between tests
@ 2019-04-11  8:53 Alan Hayward
  2019-04-11 15:19 ` Sergio Durigan Junior
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Hayward @ 2019-04-11  8:53 UTC (permalink / raw)
  To: gdb-patches; +Cc: nd, Alan Hayward

A recent change made the AArch64 self tests resuse the saved regs
cache, rather than creating a new one.  Ensure it is reset to default
values between tests.

Do this by splitting the reset functionality from trad_frame_alloc_saved_regs
into a new function.

Fixes selftest on AArch64.

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_analyze_prologue_test): Reset saved regs.
	* trad-frame.c (trad_frame_reset_saved_regs): New function.
	(trad_frame_alloc_saved_regs): Call trad_frame_reset_saved_regs.
	* trad-frame.h (trad_frame_reset_saved_regs): New declaration.
---
 gdb/ChangeLog      |  7 +++++++
 gdb/aarch64-tdep.c |  2 ++
 gdb/trad-frame.c   | 21 +++++++++++++++------
 gdb/trad-frame.h   |  3 +++
 4 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index cc6762dc78..a5cbc89972 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2019-04-11  Alan Hayward  <alan.hayward@arm.com>
+
+	* aarch64-tdep.c (aarch64_analyze_prologue_test): Reset saved regs.
+	* trad-frame.c (trad_frame_reset_saved_regs): New function.
+	(trad_frame_alloc_saved_regs): Call trad_frame_reset_saved_regs.
+	* trad-frame.h (trad_frame_reset_saved_regs): New declaration.
+
 2019-04-10  Kevin Buettner  <kevinb@redhat.com>
 
 	* amd64-linux-nat.c (amd64_linux_collect_native_gregset): New
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 7eecb52eb1..1b3977bfaf 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -665,6 +665,7 @@ aarch64_analyze_prologue_test (void)
     };
     instruction_reader_test reader (insns);
 
+    trad_frame_reset_saved_regs (gdbarch, cache.saved_regs);
     CORE_ADDR end = aarch64_analyze_prologue (gdbarch, 0, 128, &cache, reader);
 
     SELF_CHECK (end == 4 * 5);
@@ -707,6 +708,7 @@ aarch64_analyze_prologue_test (void)
       };
       instruction_reader_test reader (insns);
 
+      trad_frame_reset_saved_regs (gdbarch, cache.saved_regs);
       CORE_ADDR end = aarch64_analyze_prologue (gdbarch, 0, 128, &cache,
 						reader);
 
diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c
index 3cb295309c..d9114753c5 100644
--- a/gdb/trad-frame.c
+++ b/gdb/trad-frame.c
@@ -44,19 +44,28 @@ trad_frame_cache_zalloc (struct frame_info *this_frame)
   return this_trad_cache;
 }
 
+/* See trad-frame.h.  */
+
+void
+trad_frame_reset_saved_regs (struct gdbarch *gdbarch,
+			     struct trad_frame_saved_reg *regs)
+{
+  int numregs = gdbarch_num_cooked_regs (gdbarch);
+  for (int regnum = 0; regnum < numregs; regnum++)
+    {
+      regs[regnum].realreg = regnum;
+      regs[regnum].addr = -1;
+    }
+}
+
 struct trad_frame_saved_reg *
 trad_frame_alloc_saved_regs (struct gdbarch *gdbarch)
 {
-  int regnum;
   int numregs = gdbarch_num_cooked_regs (gdbarch);
   struct trad_frame_saved_reg *this_saved_regs
     = FRAME_OBSTACK_CALLOC (numregs, struct trad_frame_saved_reg);
 
-  for (regnum = 0; regnum < numregs; regnum++)
-    {
-      this_saved_regs[regnum].realreg = regnum;
-      this_saved_regs[regnum].addr = -1;
-    }      
+  trad_frame_reset_saved_regs (gdbarch, this_saved_regs);
   return this_saved_regs;
 }
 
diff --git a/gdb/trad-frame.h b/gdb/trad-frame.h
index dd80d1b83c..f947e586a1 100644
--- a/gdb/trad-frame.h
+++ b/gdb/trad-frame.h
@@ -113,6 +113,9 @@ int trad_frame_addr_p (struct trad_frame_saved_reg this_saved_regs[],
 int trad_frame_realreg_p (struct trad_frame_saved_reg this_saved_regs[],
 			  int regnum);
 
+/* Reset the save regs cache, setting register values to -1.  */
+void trad_frame_reset_saved_regs (struct gdbarch *gdbarch,
+				  struct trad_frame_saved_reg *regs);
 
 /* Return a freshly allocated (and initialized) trad_frame array.  */
 struct trad_frame_saved_reg *trad_frame_alloc_saved_regs (struct frame_info *);
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [OBV/PUSHED][PATCH] AArch64: Ensure regcache is reset between tests
  2019-04-11  8:53 [OBV/PUSHED][PATCH] AArch64: Ensure regcache is reset between tests Alan Hayward
@ 2019-04-11 15:19 ` Sergio Durigan Junior
  0 siblings, 0 replies; 2+ messages in thread
From: Sergio Durigan Junior @ 2019-04-11 15:19 UTC (permalink / raw)
  To: Alan Hayward; +Cc: gdb-patches, nd

On Thursday, April 11 2019, Alan Hayward wrote:

> A recent change made the AArch64 self tests resuse the saved regs
> cache, rather than creating a new one.  Ensure it is reset to default
> values between tests.
>
> Do this by splitting the reset functionality from trad_frame_alloc_saved_regs
> into a new function.
>
> Fixes selftest on AArch64.

Ah, thanks!  It was on my TODO list to report this regression (caught
while rebasing Fedora Rawhide GDB).  Thanks for fixing it.

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-11 15:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-11  8:53 [OBV/PUSHED][PATCH] AArch64: Ensure regcache is reset between tests Alan Hayward
2019-04-11 15:19 ` Sergio Durigan Junior

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).