gdb/record: Refactor record history

This is the first step in a large refactor in how GDB keeps execution
history.  Rather than using a linked list where multiple entries can
describe a single instruction, the history will now be stored in an
std::deque, each instruction being one entry in the deque.

The choice was initially to use an std::vector, but it would become
unwieldy because it needs all the memory to be consecutive, which is
hard for 200 thousand entries. Deque was picked because it was a nice
midpoint between vector (maximum cache cohesion) and linked list
(maximum ease of finding space to store more).

Each instruction in memory will be now one record_full_instruction
entry, which for this commit just contains a vector of
record_full_entry for the effects of the instruction, and the data that
was stored in the record_full_end entry (that is, the instruction number
and the signal, if any).

This change introduced a minimal performance improvement (what's
important is that it isn't a degradation) and a  reduction in the total
memory footprint of roughly 20% if the entire history is used.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>
Approved-By: Guinevere Larsen <guinevere@redhat.com>
This commit is contained in:
Guinevere Larsen 2026-05-28 15:36:33 -03:00
parent ddebf91709
commit caa9d8df0f
14 changed files with 440 additions and 679 deletions

View file

@ -6319,8 +6319,6 @@ aarch64_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
aarch64_record.aarch64_mems[rec_no].len))
ret = -1;
if (record_full_arch_list_add_end ())
ret = -1;
}
deallocate_reg_mem (&aarch64_record);

View file

@ -1591,9 +1591,6 @@ amd64_linux_record_signal (struct gdbarch *gdbarch,
+ AMD64_LINUX_frame_size))
return -1;
if (record_full_arch_list_add_end ())
return -1;
return 0;
}

View file

@ -14911,8 +14911,6 @@ arm_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
}
}
if (record_full_arch_list_add_end ())
ret = -1;
}

View file

@ -949,9 +949,6 @@ i386_linux_record_signal (struct gdbarch *gdbarch,
I386_LINUX_xstate + I386_LINUX_frame_size))
return -1;
if (record_full_arch_list_add_end ())
return -1;
return 0;
}

View file

@ -5201,8 +5201,6 @@ i386_record_vex (struct i386_record_s *ir, uint8_t vex_w, uint8_t vex_r,
}
record_full_arch_list_add_reg (ir->regcache, ir->regmap[X86_RECORD_REIP_REGNUM]);
if (record_full_arch_list_add_end ())
return -1;
return 0;
}
@ -8361,8 +8359,6 @@ reswitch_prefix_add:
/* In the future, maybe still need to deal with need_dasm. */
I386_RECORD_FULL_ARCH_LIST_ADD_REG (X86_RECORD_REIP_REGNUM);
if (record_full_arch_list_add_end ())
return -1;
return 0;

View file

@ -2789,8 +2789,6 @@ loongarch_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
LOONGARCH_PC_REGNUM))
return -1;
if (record_full_arch_list_add_end ())
return -1;
}
return ret;

View file

@ -1040,8 +1040,6 @@ moxie_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
if (record_full_arch_list_add_reg (regcache, MOXIE_PC_REGNUM))
return -1;
if (record_full_arch_list_add_end ())
return -1;
return 0;
}

View file

@ -1565,9 +1565,6 @@ ppc_linux_record_signal (struct gdbarch *gdbarch, struct regcache *regcache,
if (record_full_arch_list_add_mem (sp, SIGNAL_FRAMESIZE + sizeof_rt_sigframe))
return -1;
if (record_full_arch_list_add_end ())
return -1;
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -41,7 +41,6 @@ enum record_result
extern int record_full_arch_list_add_reg (struct regcache *regcache, int num);
extern int record_full_arch_list_add_mem (CORE_ADDR addr, int len);
extern int record_full_arch_list_add_end (void);
/* Returns true if the process record target is open. */
extern int record_full_is_used (void);

View file

@ -5468,8 +5468,5 @@ riscv_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
if (res != RECORD_SUCCESS)
return res;
if (record_full_arch_list_add_end ())
return -1;
return 0;
}

View file

@ -7138,8 +7138,6 @@ UNKNOWN_PREFIX_OP:
if (record_full_arch_list_add_reg (regcache, PPC_PC_REGNUM))
return -1;
if (record_full_arch_list_add_end ())
return -1;
return 0;
}
@ -7447,8 +7445,6 @@ UNKNOWN_OP:
if (record_full_arch_list_add_reg (regcache, PPC_PC_REGNUM))
return -1;
if (record_full_arch_list_add_end ())
return -1;
return 0;
}

View file

@ -912,9 +912,6 @@ s390_linux_record_signal (struct gdbarch *gdbarch, struct regcache *regcache,
if (record_full_arch_list_add_mem (sp, sizeof_rt_sigframe))
return -1;
if (record_full_arch_list_add_end ())
return -1;
return 0;
}

View file

@ -7025,8 +7025,6 @@ UNKNOWN_OP:
if (record_full_arch_list_add_reg (regcache, S390_PSWA_REGNUM))
return -1;
if (record_full_arch_list_add_end ())
return -1;
return 0;
}