[binutils-gdb] gdb/record: make record_full_history more c++-like

Guinevere Larsen via Gdb-cvs <[email protected]> Fri, 3 Jul 2026 13:36:06 +0000 (GMT)
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=85d513da29e016a96db983751680cacd4299b3e7

commit 85d513da29e016a96db983751680cacd4299b3e7
Author: Guinevere Larsen <[email protected]>
Date:   Mon Jun 1 16:42:41 2026 -0300

    gdb/record: make record_full_history more c++-like
    
    This commit moves the function record_full_exec_insn to be a method of
    the record_full_instruction class.
    
    Reviewed-by: Thiago Jung Bauermann <[email protected]>
    Reviewed-By: Christina Schimpe <[email protected]>
    Approved-By: Guinevere Larsen <[email protected]>

Diff:
---
 gdb/record-full.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/gdb/record-full.c b/gdb/record-full.c
index dae09b518f2..0f38fada261 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -409,6 +409,10 @@ struct record_full_instruction
   uint32_t insn_num;
   std::optional<gdb_signal> sigval;
   std::vector<record_full_entry> effects;
+
+  /* Execute the full instruction.  As a side effect, set
+     record_full_stop_reason.  */
+  void exec_insn (regcache *regcache);
 };
 
 /* If true, query if PREC cannot record memory
@@ -873,12 +877,9 @@ static enum target_stop_reason record_full_stop_reason
 
 /* Execute one entry in the log by executing all the effects.  */
 
-static inline void
-record_full_exec_insn (regcache *regcache,
-		       gdbarch *gdbarch,
-		       record_full_instruction &insn)
+void record_full_instruction::exec_insn (regcache *regcache)
 {
-  for (auto &entry : insn.effects)
+  for (auto &entry : effects)
     if (entry.execute (regcache))
       record_full_stop_reason = TARGET_STOPPED_BY_WATCHPOINT;
 }
@@ -1339,9 +1340,7 @@ record_full_wait_1 (struct target_ops *ops,
 		  break;
 		}
 
-	      record_full_exec_insn
-		(regcache, gdbarch,
-		 record_full_list[record_full_next_insn]);
+	      record_full_list[record_full_next_insn].exec_insn (regcache);
 
 	      /* step */
 	      if (record_full_resume_step)
@@ -2545,8 +2544,7 @@ record_full_base_target::save_record (const char *recfilename)
 
   /* Reverse execute to the begin of record list.  */
   for (int i = record_full_next_insn - 1; i >= 0; i--)
-    record_full_exec_insn (regcache, gdbarch,
-			   record_full_list[i]);
+    record_full_list[i].exec_insn (regcache);
 
   /* Compute the size needed for the extra bfd section.  */
   save_size = 4;	/* magic cookie */
@@ -2617,8 +2615,9 @@ record_full_base_target::save_record (const char *recfilename)
 					  gdbarch);
 	}
 
+      /* Execute entry.  */
       if (i < record_full_next_insn)
-	record_full_exec_insn (regcache, gdbarch, record_full_list[i]);
+	record_full_list[i].exec_insn (regcache);
     }
 
   unlink_file.keep ();
@@ -2639,17 +2638,16 @@ record_full_goto_insn (size_t target_insn,
   scoped_restore restore_operation_disable
     = record_full_gdb_operation_disable_set ();
   regcache *regcache = get_thread_regcache (inferior_thread ());
-  struct gdbarch *gdbarch = regcache->arch ();
 
   /* Assume everything is valid: we will hit the entry,
      and we will not hit the end of the recording.  */
 
   if (dir == EXEC_REVERSE)
     for (int i = record_full_next_insn; i > target_insn; i--)
-      record_full_exec_insn (regcache, gdbarch, record_full_list[i - 1]);
+      record_full_list[i - 1].exec_insn (regcache);
   else
     for (int i = record_full_next_insn; i < target_insn; i++)
-      record_full_exec_insn (regcache, gdbarch, record_full_list[i]);
+      record_full_list[i].exec_insn (regcache);
 
   record_full_next_insn = target_insn;
 }