/* Process record and replay target for GDB, the GNU debugger.
- Copyright (C) 2013-2021 Free Software Foundation, Inc.
+ Copyright (C) 2013-2022 Free Software Foundation, Inc.
This file is part of GDB.
record_full_arch_list_add (struct record_full_entry *rec)
{
if (record_debug > 1)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: record_full_arch_list_add %s.\n",
- host_address_to_string (rec));
+ gdb_printf (gdb_stdlog,
+ "Process record: record_full_arch_list_add %s.\n",
+ host_address_to_string (rec));
if (record_full_arch_list_tail)
{
struct record_full_entry *rec;
if (record_debug > 1)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: add register num = %d to "
- "record list.\n",
- regnum);
+ gdb_printf (gdb_stdlog,
+ "Process record: add register num = %d to "
+ "record list.\n",
+ regnum);
rec = record_full_reg_alloc (regcache, regnum);
struct record_full_entry *rec;
if (record_debug > 1)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: add mem addr = %s len = %d to "
- "record list.\n",
- paddress (target_gdbarch (), addr), len);
+ gdb_printf (gdb_stdlog,
+ "Process record: add mem addr = %s len = %d to "
+ "record list.\n",
+ paddress (target_gdbarch (), addr), len);
if (!addr) /* FIXME: Why? Some arch must permit it... */
return 0;
struct record_full_entry *rec;
if (record_debug > 1)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: add end to arch list.\n");
+ gdb_printf (gdb_stdlog,
+ "Process record: add end to arch list.\n");
rec = record_full_end_alloc ();
rec->u.end.sigval = GDB_SIGNAL_0;
gdb::byte_vector reg (entry->u.reg.len);
if (record_debug > 1)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: record_full_reg %s to "
- "inferior num = %d.\n",
- host_address_to_string (entry),
- entry->u.reg.num);
+ gdb_printf (gdb_stdlog,
+ "Process record: record_full_reg %s to "
+ "inferior num = %d.\n",
+ host_address_to_string (entry),
+ entry->u.reg.num);
regcache->cooked_read (entry->u.reg.num, reg.data ());
regcache->cooked_write (entry->u.reg.num, record_full_get_loc (entry));
gdb::byte_vector mem (entry->u.mem.len);
if (record_debug > 1)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: record_full_mem %s to "
- "inferior addr = %s len = %d.\n",
- host_address_to_string (entry),
- paddress (gdbarch, entry->u.mem.addr),
- entry->u.mem.len);
+ gdb_printf (gdb_stdlog,
+ "Process record: record_full_mem %s to "
+ "inferior addr = %s len = %d.\n",
+ host_address_to_string (entry),
+ paddress (gdbarch, entry->u.mem.addr),
+ entry->u.mem.len);
if (record_read_memory (gdbarch,
entry->u.mem.addr, mem.data (),
record_full_open_1 (const char *name, int from_tty)
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog, "Process record: record_full_open_1\n");
+ gdb_printf (gdb_stdlog, "Process record: record_full_open_1\n");
/* check exec */
if (!target_has_execution ())
record_full_open (const char *name, int from_tty)
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog, "Process record: record_full_open\n");
+ gdb_printf (gdb_stdlog, "Process record: record_full_open\n");
record_preopen ();
struct record_full_core_buf_entry *entry;
if (record_debug)
- fprintf_unfiltered (gdb_stdlog, "Process record: record_full_close\n");
+ gdb_printf (gdb_stdlog, "Process record: record_full_close\n");
record_full_list_release (record_full_list);
this->beneath ()->resume (ptid, step, signal);
}
-
- /* We are about to start executing the inferior (or simulate it),
- let's register it with the event loop. */
- if (target_can_async_p ())
- target_async (1);
}
static int record_full_get_sig = 0;
record_full_sig_handler (int signo)
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog, "Process record: get a signal\n");
+ gdb_printf (gdb_stdlog, "Process record: get a signal\n");
/* It will break the running inferior in replay mode. */
record_full_resume_step = 1;
= record_full_gdb_operation_disable_set ();
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: record_full_wait "
- "record_full_resume_step = %d, "
- "record_full_resumed = %d, direction=%s\n",
- record_full_resume_step, record_full_resumed,
- record_full_execution_dir == EXEC_FORWARD
- ? "forward" : "reverse");
+ gdb_printf (gdb_stdlog,
+ "Process record: record_full_wait "
+ "record_full_resume_step = %d, "
+ "record_full_resumed = %d, direction=%s\n",
+ record_full_resume_step, record_full_resumed,
+ record_full_execution_dir == EXEC_FORWARD
+ ? "forward" : "reverse");
if (!record_full_resumed)
{
gdb_assert ((options & TARGET_WNOHANG) != 0);
/* No interesting event. */
- status->kind = TARGET_WAITKIND_IGNORE;
+ status->set_ignore ();
return minus_one_ptid;
}
while (1)
{
ret = ops->beneath ()->wait (ptid, status, options);
- if (status->kind == TARGET_WAITKIND_IGNORE)
+ if (status->kind () == TARGET_WAITKIND_IGNORE)
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: record_full_wait "
- "target beneath not done yet\n");
+ gdb_printf (gdb_stdlog,
+ "Process record: record_full_wait "
+ "target beneath not done yet\n");
return ret;
}
return ret;
/* Is this a SIGTRAP? */
- if (status->kind == TARGET_WAITKIND_STOPPED
- && status->value.sig == GDB_SIGNAL_TRAP)
+ if (status->kind () == TARGET_WAITKIND_STOPPED
+ && status->sig () == GDB_SIGNAL_TRAP)
{
struct regcache *regcache;
enum target_stop_reason *stop_reason_p
if (!record_full_message_wrapper_safe (regcache,
GDB_SIGNAL_0))
{
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = GDB_SIGNAL_0;
+ status->set_stopped (GDB_SIGNAL_0);
break;
}
/* Try to insert the software single step breakpoint.
If insert success, set step to 0. */
set_executing (proc_target, inferior_ptid, false);
- reinit_frame_cache ();
+ SCOPE_EXIT
+ {
+ set_executing (proc_target, inferior_ptid, true);
+ };
+ reinit_frame_cache ();
step = !insert_single_step_breakpoints (gdbarch);
-
- set_executing (proc_target, inferior_ptid, true);
}
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: record_full_wait "
- "issuing one more step in the "
- "target beneath\n");
+ gdb_printf (gdb_stdlog,
+ "Process record: record_full_wait "
+ "issuing one more step in the "
+ "target beneath\n");
ops->beneath ()->resume (ptid, step, GDB_SIGNAL_0);
proc_target->commit_resumed_state = true;
proc_target->commit_resumed ();
CORE_ADDR tmp_pc;
record_full_stop_reason = TARGET_STOPPED_BY_NO_REASON;
- status->kind = TARGET_WAITKIND_STOPPED;
+ status->set_stopped (GDB_SIGNAL_0);
/* Check breakpoint when forward execute. */
if (execution_direction == EXEC_FORWARD)
&record_full_stop_reason))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: break at %s.\n",
- paddress (gdbarch, tmp_pc));
+ gdb_printf (gdb_stdlog,
+ "Process record: break at %s.\n",
+ paddress (gdbarch, tmp_pc));
goto replay_out;
}
}
&& record_full_list == &record_full_first)
{
/* Hit beginning of record log in reverse. */
- status->kind = TARGET_WAITKIND_NO_HISTORY;
+ status->set_no_history ();
break;
}
if (execution_direction != EXEC_REVERSE
&& !record_full_list->next)
{
/* Hit end of record log going forward. */
- status->kind = TARGET_WAITKIND_NO_HISTORY;
+ status->set_no_history ();
break;
}
if (record_full_list->type == record_full_end)
{
if (record_debug > 1)
- fprintf_unfiltered
+ gdb_printf
(gdb_stdlog,
"Process record: record_full_end %s to "
"inferior.\n",
if (record_full_resume_step)
{
if (record_debug > 1)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: step.\n");
+ gdb_printf (gdb_stdlog,
+ "Process record: step.\n");
continue_flag = 0;
}
(aspace, tmp_pc, &record_full_stop_reason))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: break "
- "at %s.\n",
- paddress (gdbarch, tmp_pc));
+ gdb_printf (gdb_stdlog,
+ "Process record: break "
+ "at %s.\n",
+ paddress (gdbarch, tmp_pc));
continue_flag = 0;
}
== TARGET_STOPPED_BY_WATCHPOINT)
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: hit hw "
- "watchpoint.\n");
+ gdb_printf (gdb_stdlog,
+ "Process record: hit hw "
+ "watchpoint.\n");
continue_flag = 0;
}
/* Check target signal */
while (continue_flag);
replay_out:
- if (record_full_get_sig)
- status->value.sig = GDB_SIGNAL_INT;
- else if (record_full_list->u.end.sigval != GDB_SIGNAL_0)
- /* FIXME: better way to check */
- status->value.sig = record_full_list->u.end.sigval;
- else
- status->value.sig = GDB_SIGNAL_TRAP;
+ if (status->kind () == TARGET_WAITKIND_STOPPED)
+ {
+ if (record_full_get_sig)
+ status->set_stopped (GDB_SIGNAL_INT);
+ else if (record_full_list->u.end.sigval != GDB_SIGNAL_0)
+ /* FIXME: better way to check */
+ status->set_stopped (record_full_list->u.end.sigval);
+ else
+ status->set_stopped (GDB_SIGNAL_TRAP);
+ }
}
catch (const gdb_exception &ex)
{
clear_async_event_handler (record_full_async_inferior_event_token);
return_ptid = record_full_wait_1 (this, ptid, status, options);
- if (status->kind != TARGET_WAITKIND_IGNORE)
+ if (status->kind () != TARGET_WAITKIND_IGNORE)
{
/* We're reporting a stop. Make sure any spurious
target_wait(WNOHANG) doesn't advance the target until the
{
record_full_list_release (record_full_arch_list_tail);
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: failed to record "
- "execution log.");
+ gdb_printf (gdb_stdlog,
+ "Process record: failed to record "
+ "execution log.");
return TARGET_XFER_E_IO;
}
if (record_full_arch_list_add_end ())
{
record_full_list_release (record_full_arch_list_tail);
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: failed to record "
- "execution log.");
+ gdb_printf (gdb_stdlog,
+ "Process record: failed to record "
+ "execution log.");
return TARGET_XFER_E_IO;
}
record_full_list->next = record_full_arch_list_head;
if (record_debug)
{
if (ret)
- fprintf_unfiltered (gdb_stdlog,
- "record_full_get_bookmark returns %s\n", ret);
+ gdb_printf (gdb_stdlog,
+ "record_full_get_bookmark returns %s\n", ret);
else
- fprintf_unfiltered (gdb_stdlog,
- "record_full_get_bookmark returns NULL\n");
+ gdb_printf (gdb_stdlog,
+ "record_full_get_bookmark returns NULL\n");
}
return (gdb_byte *) ret;
}
const char *bookmark = (const char *) raw_bookmark;
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "record_full_goto_bookmark receives %s\n", bookmark);
+ gdb_printf (gdb_stdlog,
+ "record_full_goto_bookmark receives %s\n", bookmark);
std::string name_holder;
if (bookmark[0] == '\'' || bookmark[0] == '\"')
struct record_full_entry *p;
if (RECORD_FULL_IS_REPLAY)
- printf_filtered (_("Replay mode:\n"));
+ gdb_printf (_("Replay mode:\n"));
else
- printf_filtered (_("Record mode:\n"));
+ gdb_printf (_("Record mode:\n"));
/* Find entry for first actual instruction in the log. */
for (p = record_full_first.next;
if (p != NULL && p->type == record_full_end)
{
/* Display instruction number for first instruction in the log. */
- printf_filtered (_("Lowest recorded instruction number is %s.\n"),
- pulongest (p->u.end.insn_num));
+ gdb_printf (_("Lowest recorded instruction number is %s.\n"),
+ pulongest (p->u.end.insn_num));
/* If in replay mode, display where we are in the log. */
if (RECORD_FULL_IS_REPLAY)
- printf_filtered (_("Current instruction number is %s.\n"),
- pulongest (record_full_list->u.end.insn_num));
+ gdb_printf (_("Current instruction number is %s.\n"),
+ pulongest (record_full_list->u.end.insn_num));
/* Display instruction number for last instruction in the log. */
- printf_filtered (_("Highest recorded instruction number is %s.\n"),
- pulongest (record_full_insn_count));
+ gdb_printf (_("Highest recorded instruction number is %s.\n"),
+ pulongest (record_full_insn_count));
/* Display log count. */
- printf_filtered (_("Log contains %u instructions.\n"),
- record_full_insn_num);
+ gdb_printf (_("Log contains %u instructions.\n"),
+ record_full_insn_num);
}
else
- printf_filtered (_("No instructions have been logged.\n"));
+ gdb_printf (_("No instructions have been logged.\n"));
/* Display max log size. */
- printf_filtered (_("Max logged instructions is %u.\n"),
- record_full_insn_max_num);
+ gdb_printf (_("Max logged instructions is %u.\n"),
+ record_full_insn_max_num);
}
bool
error (_("Already at target insn."));
else if (p->u.end.insn_num > record_full_list->u.end.insn_num)
{
- printf_filtered (_("Go forward to insn number %s\n"),
- pulongest (p->u.end.insn_num));
+ gdb_printf (_("Go forward to insn number %s\n"),
+ pulongest (p->u.end.insn_num));
record_full_goto_insn (p, EXEC_FORWARD);
}
else
{
- printf_filtered (_("Go backward to insn number %s\n"),
- pulongest (p->u.end.insn_num));
+ gdb_printf (_("Go backward to insn number %s\n"),
+ pulongest (p->u.end.insn_num));
record_full_goto_insn (p, EXEC_REVERSE);
}
registers_changed ();
reinit_frame_cache ();
- inferior_thread ()->suspend.stop_pc
- = regcache_read_pc (get_current_regcache ());
+ inferior_thread ()->set_stop_pc (regcache_read_pc (get_current_regcache ()));
print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
record_full_resume_step = step;
record_full_resumed = 1;
record_full_execution_dir = ::execution_direction;
-
- /* We are about to start executing the inferior (or simulate it),
- let's register it with the event loop. */
- if (target_can_async_p ())
- target_async (1);
}
/* "kill" method for prec over corefile. */
record_full_core_target::kill ()
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog, "Process record: record_full_core_kill\n");
+ gdb_printf (gdb_stdlog, "Process record: record_full_core_kill\n");
current_inferior ()->unpush_target (this);
}
gdb_assert (record_full_first.next == NULL);
if (record_debug)
- fprintf_unfiltered (gdb_stdlog, "Restoring recording from core file.\n");
+ gdb_printf (gdb_stdlog, "Restoring recording from core file.\n");
/* Now need to find our special note section. */
osec = bfd_get_section_by_name (core_bfd, "null0");
if (record_debug)
- fprintf_unfiltered (gdb_stdlog, "Find precord section %s.\n",
- osec ? "succeeded" : "failed");
+ gdb_printf (gdb_stdlog, "Find precord section %s.\n",
+ osec ? "succeeded" : "failed");
if (osec == NULL)
return;
osec_size = bfd_section_size (osec);
if (record_debug)
- fprintf_unfiltered (gdb_stdlog, "%s", bfd_section_name (osec));
+ gdb_printf (gdb_stdlog, "%s", bfd_section_name (osec));
/* Check the magic code. */
bfdcore_read (core_bfd, osec, &magic, sizeof (magic), &bfd_offset);
error (_("Version mis-match or file format error in core file %s."),
bfd_get_filename (core_bfd));
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- " Reading 4-byte magic cookie "
- "RECORD_FULL_FILE_MAGIC (0x%s)\n",
- phex_nz (netorder32 (magic), 4));
+ gdb_printf (gdb_stdlog,
+ " Reading 4-byte magic cookie "
+ "RECORD_FULL_FILE_MAGIC (0x%s)\n",
+ phex_nz (netorder32 (magic), 4));
/* Restore the entries in recfd into record_full_arch_list_head and
record_full_arch_list_tail. */
rec->u.reg.len, &bfd_offset);
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- " Reading register %d (1 "
- "plus %lu plus %d bytes)\n",
- rec->u.reg.num,
- (unsigned long) sizeof (regnum),
- rec->u.reg.len);
+ gdb_printf (gdb_stdlog,
+ " Reading register %d (1 "
+ "plus %lu plus %d bytes)\n",
+ rec->u.reg.num,
+ (unsigned long) sizeof (regnum),
+ rec->u.reg.len);
break;
case record_full_mem: /* mem */
rec->u.mem.len, &bfd_offset);
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- " Reading memory %s (1 plus "
- "%lu plus %lu plus %d bytes)\n",
- paddress (get_current_arch (),
- rec->u.mem.addr),
- (unsigned long) sizeof (addr),
- (unsigned long) sizeof (len),
- rec->u.mem.len);
+ gdb_printf (gdb_stdlog,
+ " Reading memory %s (1 plus "
+ "%lu plus %lu plus %d bytes)\n",
+ paddress (get_current_arch (),
+ rec->u.mem.addr),
+ (unsigned long) sizeof (addr),
+ (unsigned long) sizeof (len),
+ rec->u.mem.len);
break;
case record_full_end: /* end */
rec->u.end.insn_num = count;
record_full_insn_count = count + 1;
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- " Reading record_full_end (1 + "
- "%lu + %lu bytes), offset == %s\n",
- (unsigned long) sizeof (signal),
- (unsigned long) sizeof (count),
- paddress (get_current_arch (),
- bfd_offset));
+ gdb_printf (gdb_stdlog,
+ " Reading record_full_end (1 + "
+ "%lu + %lu bytes), offset == %s\n",
+ (unsigned long) sizeof (signal),
+ (unsigned long) sizeof (count),
+ paddress (get_current_arch (),
+ bfd_offset));
break;
default:
}
/* Succeeded. */
- printf_filtered (_("Restored records from core file %s.\n"),
- bfd_get_filename (core_bfd));
+ gdb_printf (_("Restored records from core file %s.\n"),
+ bfd_get_filename (core_bfd));
print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
/* Open the save file. */
if (record_debug)
- fprintf_unfiltered (gdb_stdlog, "Saving execution log to core file '%s'\n",
- recfilename);
+ gdb_printf (gdb_stdlog, "Saving execution log to core file '%s'\n",
+ recfilename);
/* Open the output file. */
gdb_bfd_ref_ptr obfd (create_gcore_bfd (recfilename));
/* Write the magic code. */
magic = RECORD_FULL_FILE_MAGIC;
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- " Writing 4-byte magic cookie "
- "RECORD_FULL_FILE_MAGIC (0x%s)\n",
- phex_nz (magic, 4));
+ gdb_printf (gdb_stdlog,
+ " Writing 4-byte magic cookie "
+ "RECORD_FULL_FILE_MAGIC (0x%s)\n",
+ phex_nz (magic, 4));
bfdcore_write (obfd.get (), osec, &magic, sizeof (magic), &bfd_offset);
/* Save the entries to recfd and forward execute to the end of
{
case record_full_reg: /* reg */
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- " Writing register %d (1 "
- "plus %lu plus %d bytes)\n",
- record_full_list->u.reg.num,
- (unsigned long) sizeof (regnum),
- record_full_list->u.reg.len);
+ gdb_printf (gdb_stdlog,
+ " Writing register %d (1 "
+ "plus %lu plus %d bytes)\n",
+ record_full_list->u.reg.num,
+ (unsigned long) sizeof (regnum),
+ record_full_list->u.reg.len);
/* Write regnum. */
regnum = netorder32 (record_full_list->u.reg.num);
case record_full_mem: /* mem */
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- " Writing memory %s (1 plus "
- "%lu plus %lu plus %d bytes)\n",
- paddress (gdbarch,
- record_full_list->u.mem.addr),
- (unsigned long) sizeof (addr),
- (unsigned long) sizeof (len),
- record_full_list->u.mem.len);
+ gdb_printf (gdb_stdlog,
+ " Writing memory %s (1 plus "
+ "%lu plus %lu plus %d bytes)\n",
+ paddress (gdbarch,
+ record_full_list->u.mem.addr),
+ (unsigned long) sizeof (addr),
+ (unsigned long) sizeof (len),
+ record_full_list->u.mem.len);
/* Write memlen. */
len = netorder32 (record_full_list->u.mem.len);
case record_full_end:
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- " Writing record_full_end (1 + "
- "%lu + %lu bytes)\n",
- (unsigned long) sizeof (signal),
- (unsigned long) sizeof (count));
+ gdb_printf (gdb_stdlog,
+ " Writing record_full_end (1 + "
+ "%lu + %lu bytes)\n",
+ (unsigned long) sizeof (signal),
+ (unsigned long) sizeof (count));
/* Write signal value. */
signal = netorder32 (record_full_list->u.end.sigval);
bfdcore_write (obfd.get (), osec, &signal,
unlink_file.keep ();
/* Succeeded. */
- printf_filtered (_("Saved core file %s with execution log.\n"),
- recfilename);
+ gdb_printf (_("Saved core file %s with execution log.\n"),
+ recfilename);
}
/* record_full_goto_insn -- rewind the record log (forward or backward,
set_cmd_completer (c, filename_completer);
deprecate_cmd (c, "record full restore");
- add_basic_prefix_cmd ("full", class_support,
- _("Set record options."), &set_record_full_cmdlist,
- 0, &set_record_cmdlist);
-
- add_show_prefix_cmd ("full", class_support,
- _("Show record options."), &show_record_full_cmdlist,
- 0, &show_record_cmdlist);
+ add_setshow_prefix_cmd ("full", class_support,
+ _("Set record options."),
+ _("Show record options."),
+ &set_record_full_cmdlist,
+ &show_record_full_cmdlist,
+ &set_record_cmdlist,
+ &show_record_cmdlist);
/* Record instructions number limit command. */
set_show_commands set_record_full_stop_at_limit_cmds