[PATCH 4/6] gdb/record: make record_full_history more c++-like

Guinevere Larsen
2026-04-15T18:59:52Z

Move some functions to being a method of record_full_history, instead of
floating functions.
---
gdb/record-full.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/gdb/record-full.c b/gdb/record-full.c
index f3737fdbc1f..c9e66fac578 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -325,6 +325,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, gdbarch *gdbarch);
};

/* If true, query if PREC cannot record memory
@@ -835,12 +839,9 @@ record_full_gdb_operation_disable_set (void)
static enum target_stop_reason record_full_stop_reason
= TARGET_STOPPED_BY_NO_REASON;

-static inline void
-record_full_exec_insn (struct regcache *regcache,
- struct gdbarch *gdbarch,
- record_full_instruction &insn)
+void record_full_instruction::exec_insn (regcache *regcache, gdbarch *gdbarch)
{
- for (auto &entry : insn.effects)
+ for (auto &entry : effects)
if (entry.execute (regcache, gdbarch))
record_full_stop_reason = TARGET_STOPPED_BY_WATCHPOINT;
}
@@ -1287,9 +1288,8 @@ 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,
+ gdbarch);

/* step */
if (record_full_resume_step)
@@ -2491,8 +2491,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, gdbarch);

/* Compute the size needed for the extra bfd section. */
save_size = 4; /* magic cookie */
@@ -2565,7 +2564,7 @@ record_full_base_target::save_record (const char *recfilename)
}
/* 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, gdbarch);
}

unlink_file.keep ();
@@ -2593,10 +2592,10 @@ record_full_goto_insn (size_t target_insn,

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, gdbarch);
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, gdbarch);
}

/* Alias for "target record-full". */
--
2.53.0