#define RECORD_IS_REPLAY \
(record_list->next || execution_direction == EXEC_REVERSE)
-/* These are the core struct of record function.
+/* These are the core structs of the process record functionality.
- An record_entry is a record of the value change of a register
+ A record_entry is a record of the value change of a register
("record_reg") or a part of memory ("record_mem"). And each
- instruction must has a struct record_entry ("record_end") that points out this
- is the last struct record_entry of this instruction.
+ instruction must have a struct record_entry ("record_end") that
+ indicates that this is the last struct record_entry of this
+ instruction.
- Each struct record_entry is linked to "record_list" by "prev" and "next". */
+ Each struct record_entry is linked to "record_list" by "prev" and
+ "next" pointers. */
struct record_reg_entry
{
{
CORE_ADDR addr;
int len;
+ /* Set this flag if target memory for this entry
+ can no longer be accessed. */
+ int mem_entry_not_accessible;
gdb_byte *val;
};
while (tmp)
{
rec = tmp->next;
- if (tmp->type == record_reg)
+ if (tmp->type == record_end)
record_insn_num--;
else if (tmp->type == record_reg)
xfree (tmp->u.reg.val);
if (record_debug > 1)
fprintf_unfiltered (gdb_stdlog,
- "Process record: add mem addr = 0x%s len = %d to "
+ "Process record: add mem addr = %s len = %d to "
"record list.\n",
- paddr_nz (addr), len);
+ paddress (target_gdbarch, addr), len);
if (!addr)
return 0;
rec->type = record_mem;
rec->u.mem.addr = addr;
rec->u.mem.len = len;
+ rec->u.mem.mem_entry_not_accessible = 0;
if (target_read_memory (addr, rec->u.mem.val, len))
{
if (record_debug)
fprintf_unfiltered (gdb_stdlog,
"Process record: error reading memory at "
- "addr = 0x%s len = %d.\n",
- paddr_nz (addr), len);
+ "addr = %s len = %d.\n",
+ paddress (target_gdbarch, addr), len);
xfree (rec->u.mem.val);
xfree (rec);
return -1;
}
static int record_resume_step = 0;
-static enum target_signal record_resume_siggnal;
static int record_resume_error;
static void
enum target_signal siggnal)
{
record_resume_step = step;
- record_resume_siggnal = siggnal;
if (!RECORD_IS_REPLAY)
{
{
/* This is a single step. */
return record_beneath_to_wait (record_beneath_to_wait_ops,
- ptid, status, 0);
+ ptid, status, options);
}
else
{
while (1)
{
ret = record_beneath_to_wait (record_beneath_to_wait_ops,
- ptid, status, 0);
+ ptid, status, options);
if (status->kind == TARGET_WAITKIND_STOPPED
&& status->value.sig == TARGET_SIGNAL_TRAP)
}
record_beneath_to_resume (record_beneath_to_resume_ops,
ptid, 1,
- record_resume_siggnal);
+ TARGET_SIGNAL_0);
continue;
}
}
else
{
struct regcache *regcache = get_current_regcache ();
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
int continue_flag = 1;
int first_record_end = 1;
struct cleanup *old_cleanups = make_cleanup (record_wait_cleanups, 0);
{
if (record_debug)
fprintf_unfiltered (gdb_stdlog,
- "Process record: break at 0x%s.\n",
- paddr_nz (tmp_pc));
- if (gdbarch_decr_pc_after_break (get_regcache_arch (regcache))
+ "Process record: break at %s.\n",
+ paddress (gdbarch, tmp_pc));
+ if (gdbarch_decr_pc_after_break (gdbarch)
&& !record_resume_step)
regcache_write_pc (regcache,
tmp_pc +
- gdbarch_decr_pc_after_break
- (get_regcache_arch (regcache)));
+ gdbarch_decr_pc_after_break (gdbarch));
goto replay_out;
}
}
else if (record_list->type == record_mem)
{
/* mem */
- gdb_byte *mem = alloca (record_list->u.mem.len);
- if (record_debug > 1)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: record_mem %s to "
- "inferior addr = 0x%s len = %d.\n",
- host_address_to_string (record_list),
- paddr_nz (record_list->u.mem.addr),
- record_list->u.mem.len);
-
- if (target_read_memory
- (record_list->u.mem.addr, mem, record_list->u.mem.len))
- error (_("Process record: error reading memory at "
- "addr = 0x%s len = %d."),
- paddr_nz (record_list->u.mem.addr),
- record_list->u.mem.len);
-
- if (target_write_memory
- (record_list->u.mem.addr, record_list->u.mem.val,
- record_list->u.mem.len))
- error (_
- ("Process record: error writing memory at "
- "addr = 0x%s len = %d."),
- paddr_nz (record_list->u.mem.addr),
- record_list->u.mem.len);
-
- memcpy (record_list->u.mem.val, mem, record_list->u.mem.len);
+ /* Nothing to do if the entry is flagged not_accessible. */
+ if (!record_list->u.mem.mem_entry_not_accessible)
+ {
+ gdb_byte *mem = alloca (record_list->u.mem.len);
+ if (record_debug > 1)
+ fprintf_unfiltered (gdb_stdlog,
+ "Process record: record_mem %s to "
+ "inferior addr = %s len = %d.\n",
+ host_address_to_string (record_list),
+ paddress (gdbarch,
+ record_list->u.mem.addr),
+ record_list->u.mem.len);
+
+ if (target_read_memory (record_list->u.mem.addr, mem,
+ record_list->u.mem.len))
+ {
+ if (execution_direction != EXEC_REVERSE)
+ error (_("Process record: error reading memory at "
+ "addr = %s len = %d."),
+ paddress (gdbarch, record_list->u.mem.addr),
+ record_list->u.mem.len);
+ else
+ /* Read failed --
+ flag entry as not_accessible. */
+ record_list->u.mem.mem_entry_not_accessible = 1;
+ }
+ else
+ {
+ if (target_write_memory (record_list->u.mem.addr,
+ record_list->u.mem.val,
+ record_list->u.mem.len))
+ {
+ if (execution_direction != EXEC_REVERSE)
+ error (_("Process record: error writing memory at "
+ "addr = %s len = %d."),
+ paddress (gdbarch, record_list->u.mem.addr),
+ record_list->u.mem.len);
+ else
+ /* Write failed --
+ flag entry as not_accessible. */
+ record_list->u.mem.mem_entry_not_accessible = 1;
+ }
+ else
+ {
+ memcpy (record_list->u.mem.val, mem,
+ record_list->u.mem.len);
+ }
+ }
+ }
}
else
{
if (record_debug)
fprintf_unfiltered (gdb_stdlog,
"Process record: break "
- "at 0x%s.\n",
- paddr_nz (tmp_pc));
- if (gdbarch_decr_pc_after_break (get_regcache_arch (regcache))
+ "at %s.\n",
+ paddress (gdbarch, tmp_pc));
+ if (gdbarch_decr_pc_after_break (gdbarch)
&& execution_direction == EXEC_FORWARD
&& !record_resume_step)
regcache_write_pc (regcache,
tmp_pc +
- gdbarch_decr_pc_after_break
- (get_regcache_arch (regcache)));
+ gdbarch_decr_pc_after_break (gdbarch));
continue_flag = 0;
}
}
if (RECORD_IS_REPLAY)
{
int n;
- struct cleanup *old_cleanups;
/* Let user choose if he wants to write register or not. */
if (regno < 0)
/* Let user choose if he wants to write memory or not. */
if (!nquery (_("Because GDB is in replay mode, writing to memory "
"will make the execution log unusable from this "
- "point onward. Write memory at address 0x%s?"),
- paddr_nz (offset)))
- return -1;
+ "point onward. Write memory at address %s?"),
+ paddress (target_gdbarch, offset)))
+ error (_("Process record canceled the operation."));
/* Destroy the record from here forward. */
record_list_release_next ();
/* Record instructions number limit command. */
add_setshow_boolean_cmd ("stop-at-limit", no_class,
- &record_stop_at_limit, _("\
+ &record_stop_at_limit, _("\
Set whether record/replay stops when record/replay buffer becomes full."), _("\
Show whether record/replay stops when record/replay buffer becomes full."), _("\
Default is ON.\n\
When ON, if the record/replay buffer becomes full, ask user what to do.\n\
When OFF, if the record/replay buffer becomes full,\n\
delete the oldest recorded instruction to make room for each new one."),
- NULL, NULL,
- &set_record_cmdlist, &show_record_cmdlist);
+ NULL, NULL,
+ &set_record_cmdlist, &show_record_cmdlist);
add_setshow_zinteger_cmd ("insn-number-max", no_class,
&record_insn_max_num,
_("Set record/replay buffer limit."),
set_record_insn_max_num,
NULL, &set_record_cmdlist, &show_record_cmdlist);
add_cmd ("insn-number", class_obscure, show_record_insn_number,
- _("Show the current number of instructions in the "
- "record/replay buffer."), &info_record_cmdlist);
+ _("Show the current number of instructions in the "
+ "record/replay buffer."), &info_record_cmdlist);
}