Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v2] gdb/record: remove PC member from record_full_instruction
@ 2026-11-26 12:12 Guinevere Larsen
  0 siblings, 0 replies; only message in thread
From: Guinevere Larsen @ 2026-11-26 12:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Guinevere Larsen, Kevin Buettner

The recent commit "4d0a9f412df gdb/record: extract the PC to
record_full_instruction" caused a regression on s390x, because the
recorded register is PSWA, whereas according to gdbarch the PC is a
pseudoregister. This was reported as PR record/34937.

I tried to make s390 record the gdbarch version, but still got
hundreds of regressions in the sigall tests. I then tried to make
record ignore the PC member if the length was 0, but that caused
problems in the precsave functionality, as we were writing 0 bytes but
reading more than 0 as the reading GDB assumed the regnum of 0 was
valid.

Considering the original motivation for that patch is a micro
optimization (a reg_entry is smaller than a generic entry, and the
vector is smaller) and improvement for a possible future fix of PR
record/18059, it doesn't seem worth it to keep this speculatively.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34937
Approved-By: Kevin Buettner <kevinb@redhat.com>
---

Kevin has approved the code changes, but I hadn't added the NEWS file
change to v1 so I need Eli's approval before pushing

---
 gdb/NEWS          |  3 +++
 gdb/record-full.c | 24 +++---------------------
 2 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index 092680aee61..4e94a278945 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -48,6 +48,9 @@
   source is modified.  Source tracking can be enabled with 'set
   breakpoint source-tracking enabled on'.
 
+* The record-full precsave format has been changed, and previous
+  versions will no longer be supported.
+
 * New targets
 
 i386 Windows/MSVC               i[34567]86-*-windows-msvc
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 7b1d64069c7..55fc5987a2e 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -79,8 +79,8 @@
   ((record_full_next_insn != record_full_log.size ()) \
     || ::execution_direction == EXEC_REVERSE)
 
-#define RECORD_FULL_FILE_MAGIC_OLD	netorder32(0x20091016)
-#define RECORD_FULL_FILE_MAGIC	netorder32(0x20260415)
+#define RECORD_FULL_FILE_MAGIC_OLD	netorder32(0x20260415)
+#define RECORD_FULL_FILE_MAGIC	netorder32(0x20261126)
 
 /* These are the core structs of the process record functionality.
 
@@ -418,7 +418,6 @@ class record_full_entry
      this one;
    * sigval: Whether the inferior received a signal while the following
      instruction was being recorded;
-   * pc: The Program Counter at the start of the instruction;
    * effects: A list of record_full_entry structures, each of which
      describing one effect that the instruction has on the inferior.
 
@@ -433,7 +432,6 @@ struct record_full_instruction
   uint32_t insn_num;
   std::optional<gdb_signal> sigval;
   std::vector<record_full_entry> effects;
-  record_full_reg_entry pc;
 
   /* Execute the full instruction.  As a side effect, set
      record_full_stop_reason.  */
@@ -755,10 +753,7 @@ record_full_arch_list_add_reg (struct regcache *regcache, int regnum)
 
   regcache->cooked_read (regnum, rec.get_loc ());
 
-  if (regnum == gdbarch_pc_regnum (regcache->arch ()))
-      record_full_incomplete_instruction.pc = std::move (rec.reg ());
-  else
-      record_full_arch_list_add (std::move (rec));
+  record_full_arch_list_add (std::move (rec));
 
   return 0;
 }
@@ -914,7 +909,6 @@ static enum target_stop_reason record_full_stop_reason
 
 void record_full_instruction::exec_insn (regcache *regcache)
 {
-  pc.execute (regcache);
   for (auto &entry : effects)
     if (entry.execute (regcache))
       record_full_stop_reason = TARGET_STOPPED_BY_WATCHPOINT;
@@ -2413,9 +2407,6 @@ record_full_instruction::from_bfd (bfd *cbfd, asection *osec, int *bfd_offset)
   if (sigval != GDB_SIGNAL_0)
     record_full_incomplete_instruction.sigval = (gdb_signal) sigval;
 
-  record_full_incomplete_instruction.pc
-    = record_full_reg_entry::from_bfd (cbfd, osec, bfd_offset);
-
   eff_count = netorder32 (eff_count);
 
   /* This deals with all the side effects.  */
@@ -2627,8 +2618,6 @@ record_full_instruction::to_bfd (gdb_bfd_ref_ptr &obfd, asection *osec,
   bfdcore_write (obfd.get (), osec, &insn_num, sizeof (uint32_t),
 		 bfd_offset);
 
-  this->pc.to_bfd (obfd, osec, bfd_offset);
-
   for (auto &entry : this->effects)
     {
       entry.to_bfd (obfd, osec, bfd_offset, gdbarch);
@@ -2676,7 +2665,6 @@ record_full_base_target::save_record (const char *recfilename)
     {
       /* Number of effects of an instruction.  */
       save_size += sizeof (uint32_t) + sizeof (uint8_t) + sizeof (uint32_t);
-      save_size += 4 + record_full_log[i].pc.len;
       for (auto &entry : record_full_log[i].effects)
 	switch (entry.type ())
 	  {
@@ -2830,12 +2818,6 @@ maintenance_print_record_instruction (const char *args, int from_tty)
 	    }
 	}
     }
-  type *regtype = gdbarch_register_type (arch, to_print->pc.num);
-  value *val = value_from_contents (regtype, to_print->pc.get_loc ());
-  gdb_printf ("Register %s changed: ",
-	      gdbarch_register_name (arch, to_print->pc.num));
-  value_print (val, gdb_stdout, opts);
-  gdb_printf ("\n");
 }
 
 INIT_GDB_FILE (record_full)

base-commit: 1b92b50d1ca485b090c841b8bc755a6ba6f159ee
-- 
2.56.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-26 12:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 12:12 [PATCH v2] gdb/record: remove PC member from record_full_instruction Guinevere Larsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox