Unify gdb printf functions

Now that filtered and unfiltered output can be treated identically, we
can unify the printf family of functions.  This is done under the name
"gdb_printf".  Most of this patch was written by script.
This commit is contained in:
Tom Tromey
2022-01-02 11:46:15 -07:00
parent a11ac3b3e8
commit 6cb06a8cda
249 changed files with 8449 additions and 8463 deletions

View File

@ -565,9 +565,9 @@ static void
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)
{
@ -612,10 +612,10 @@ record_full_arch_list_add_reg (struct regcache *regcache, int regnum)
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);
@ -635,10 +635,10 @@ record_full_arch_list_add_mem (CORE_ADDR addr, int len)
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;
@ -666,8 +666,8 @@ record_full_arch_list_add_end (void)
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;
@ -824,11 +824,11 @@ record_full_exec_insn (struct regcache *regcache,
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));
@ -844,12 +844,12 @@ record_full_exec_insn (struct regcache *regcache,
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 (),
@ -934,7 +934,7 @@ static void
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 ())
@ -958,7 +958,7 @@ static void
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 ();
@ -991,7 +991,7 @@ record_full_base_target::close ()
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);
@ -1105,7 +1105,7 @@ static void
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;
@ -1137,13 +1137,13 @@ record_full_wait_1 (struct target_ops *ops,
= 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)
{
@ -1180,9 +1180,9 @@ record_full_wait_1 (struct target_ops *ops,
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;
}
@ -1254,10 +1254,10 @@ record_full_wait_1 (struct target_ops *ops,
}
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 ();
@ -1298,9 +1298,9 @@ record_full_wait_1 (struct target_ops *ops,
&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;
}
}
@ -1342,7 +1342,7 @@ record_full_wait_1 (struct target_ops *ops,
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",
@ -1366,8 +1366,8 @@ record_full_wait_1 (struct target_ops *ops,
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;
}
@ -1377,10 +1377,10 @@ record_full_wait_1 (struct target_ops *ops,
(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;
}
@ -1389,9 +1389,9 @@ record_full_wait_1 (struct target_ops *ops,
== 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 */
@ -1658,18 +1658,18 @@ record_full_target::xfer_partial (enum target_object object,
{
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;
@ -1842,11 +1842,11 @@ record_full_base_target::get_bookmark (const char *args, int from_tty)
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;
}
@ -1860,8 +1860,8 @@ record_full_base_target::goto_bookmark (const gdb_byte *raw_bookmark,
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] == '\"')
@ -1896,9 +1896,9 @@ record_full_base_target::info_record ()
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;
@ -1910,28 +1910,28 @@ record_full_base_target::info_record ()
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
@ -1979,14 +1979,14 @@ record_full_goto_entry (struct record_full_entry *p)
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);
}
@ -2065,7 +2065,7 @@ void
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);
}
@ -2324,18 +2324,18 @@ record_full_restore (void)
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);
@ -2343,10 +2343,10 @@ record_full_restore (void)
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. */
@ -2384,12 +2384,12 @@ record_full_restore (void)
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 */
@ -2410,14 +2410,14 @@ record_full_restore (void)
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 */
@ -2437,13 +2437,13 @@ record_full_restore (void)
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:
@ -2477,8 +2477,8 @@ record_full_restore (void)
}
/* 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);
}
@ -2524,8 +2524,8 @@ record_full_base_target::save_record (const char *recfilename)
/* 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));
@ -2593,10 +2593,10 @@ record_full_base_target::save_record (const char *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
@ -2618,12 +2618,12 @@ record_full_base_target::save_record (const char *recfilename)
{
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);
@ -2638,14 +2638,14 @@ record_full_base_target::save_record (const char *recfilename)
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);
@ -2665,11 +2665,11 @@ record_full_base_target::save_record (const char *recfilename)
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,
@ -2708,8 +2708,8 @@ record_full_base_target::save_record (const char *recfilename)
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,