Remove gdb_print_host_address

gdb_print_host_address is just a simple wrapper around
fprintf_filtered.  However, it is readily replaced in all callers by a
combination of %s and call to host_address_to_string.  This also
simplifies the code, so I think it's worthwhile to remove this
function.

Regression tested on x86-64 Fedora 64.
This commit is contained in:
Tom Tromey 2021-12-22 10:28:37 -07:00
parent 34b965f7c0
commit 64b7cc507b
6 changed files with 107 additions and 175 deletions

View File

@ -405,14 +405,10 @@ fprint_dummy_frames (struct ui_file *file)
struct dummy_frame *s;
for (s = dummy_frame_stack; s != NULL; s = s->next)
{
gdb_print_host_address (s, file);
fprintf_unfiltered (file, ":");
fprintf_unfiltered (file, " id=%s", s->id.id.to_string ().c_str ());
fprintf_unfiltered (file, ", ptid=%s",
target_pid_to_str (s->id.thread->ptid).c_str ());
fprintf_unfiltered (file, "\n");
}
fprintf_unfiltered (file, "%s: id=%s, ptid=%s\n",
host_address_to_string (s),
s->id.id.to_string ().c_str (),
target_pid_to_str (s->id.thread->ptid).c_str ());
}
static void

View File

@ -4901,48 +4901,44 @@ dump_fn_fieldlists (struct type *type, int spaces)
int overload_idx;
struct fn_field *f;
printf_filtered ("%*sfn_fieldlists ", spaces, "");
gdb_print_host_address (TYPE_FN_FIELDLISTS (type), gdb_stdout);
printf_filtered ("\n");
printf_filtered ("%*sfn_fieldlists %s\n", spaces, "",
host_address_to_string (TYPE_FN_FIELDLISTS (type)));
for (method_idx = 0; method_idx < TYPE_NFN_FIELDS (type); method_idx++)
{
f = TYPE_FN_FIELDLIST1 (type, method_idx);
printf_filtered ("%*s[%d] name '%s' (", spaces + 2, "",
method_idx,
TYPE_FN_FIELDLIST_NAME (type, method_idx));
gdb_print_host_address (TYPE_FN_FIELDLIST_NAME (type, method_idx),
gdb_stdout);
printf_filtered (_(") length %d\n"),
TYPE_FN_FIELDLIST_LENGTH (type, method_idx));
printf_filtered
("%*s[%d] name '%s' (%s) length %d\n", spaces + 2, "",
method_idx,
TYPE_FN_FIELDLIST_NAME (type, method_idx),
host_address_to_string (TYPE_FN_FIELDLIST_NAME (type, method_idx)),
TYPE_FN_FIELDLIST_LENGTH (type, method_idx));
for (overload_idx = 0;
overload_idx < TYPE_FN_FIELDLIST_LENGTH (type, method_idx);
overload_idx++)
{
printf_filtered ("%*s[%d] physname '%s' (",
spaces + 4, "", overload_idx,
TYPE_FN_FIELD_PHYSNAME (f, overload_idx));
gdb_print_host_address (TYPE_FN_FIELD_PHYSNAME (f, overload_idx),
gdb_stdout);
printf_filtered (")\n");
printf_filtered ("%*stype ", spaces + 8, "");
gdb_print_host_address (TYPE_FN_FIELD_TYPE (f, overload_idx),
gdb_stdout);
printf_filtered ("\n");
printf_filtered
("%*s[%d] physname '%s' (%s)\n",
spaces + 4, "", overload_idx,
TYPE_FN_FIELD_PHYSNAME (f, overload_idx),
host_address_to_string (TYPE_FN_FIELD_PHYSNAME (f,
overload_idx)));
printf_filtered
("%*stype %s\n", spaces + 8, "",
host_address_to_string (TYPE_FN_FIELD_TYPE (f, overload_idx)));
recursive_dump_type (TYPE_FN_FIELD_TYPE (f, overload_idx),
spaces + 8 + 2);
printf_filtered ("%*sargs ", spaces + 8, "");
gdb_print_host_address (TYPE_FN_FIELD_ARGS (f, overload_idx),
gdb_stdout);
printf_filtered ("\n");
printf_filtered
("%*sargs %s\n", spaces + 8, "",
host_address_to_string (TYPE_FN_FIELD_ARGS (f, overload_idx)));
print_args (TYPE_FN_FIELD_ARGS (f, overload_idx),
TYPE_FN_FIELD_TYPE (f, overload_idx)->num_fields (),
spaces + 8 + 2);
printf_filtered ("%*sfcontext ", spaces + 8, "");
gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx),
gdb_stdout);
printf_filtered ("\n");
printf_filtered
("%*sfcontext %s\n", spaces + 8, "",
host_address_to_string (TYPE_FN_FIELD_FCONTEXT (f,
overload_idx)));
printf_filtered ("%*sis_const %d\n", spaces + 8, "",
TYPE_FN_FIELD_CONST (f, overload_idx));
@ -4969,9 +4965,8 @@ print_cplus_stuff (struct type *type, int spaces)
{
printf_filtered ("%*svptr_fieldno %d\n", spaces, "",
TYPE_VPTR_FIELDNO (type));
printf_filtered ("%*svptr_basetype ", spaces, "");
gdb_print_host_address (TYPE_VPTR_BASETYPE (type), gdb_stdout);
puts_filtered ("\n");
printf_filtered ("%*svptr_basetype %s\n", spaces, "",
host_address_to_string (TYPE_VPTR_BASETYPE (type)));
if (TYPE_VPTR_BASETYPE (type) != NULL)
recursive_dump_type (TYPE_VPTR_BASETYPE (type), spaces + 2);
@ -4981,11 +4976,10 @@ print_cplus_stuff (struct type *type, int spaces)
TYPE_NFN_FIELDS (type));
if (TYPE_N_BASECLASSES (type) > 0)
{
printf_filtered ("%*svirtual_field_bits (%d bits at *",
spaces, "", TYPE_N_BASECLASSES (type));
gdb_print_host_address (TYPE_FIELD_VIRTUAL_BITS (type),
gdb_stdout);
printf_filtered (")");
printf_filtered
("%*svirtual_field_bits (%d bits at *%s)",
spaces, "", TYPE_N_BASECLASSES (type),
host_address_to_string (TYPE_FIELD_VIRTUAL_BITS (type)));
print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type),
TYPE_N_BASECLASSES (type));
@ -4995,22 +4989,20 @@ print_cplus_stuff (struct type *type, int spaces)
{
if (TYPE_FIELD_PRIVATE_BITS (type) != NULL)
{
printf_filtered ("%*sprivate_field_bits (%d bits at *",
spaces, "", type->num_fields ());
gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type),
gdb_stdout);
printf_filtered (")");
printf_filtered
("%*sprivate_field_bits (%d bits at *%s)",
spaces, "", type->num_fields (),
host_address_to_string (TYPE_FIELD_PRIVATE_BITS (type)));
print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type),
type->num_fields ());
puts_filtered ("\n");
}
if (TYPE_FIELD_PROTECTED_BITS (type) != NULL)
{
printf_filtered ("%*sprotected_field_bits (%d bits at *",
spaces, "", type->num_fields ());
gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type),
gdb_stdout);
printf_filtered (")");
printf_filtered
("%*sprotected_field_bits (%d bits at *%s",
spaces, "", type->num_fields (),
host_address_to_string (TYPE_FIELD_PROTECTED_BITS (type)));
print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type),
type->num_fields ());
puts_filtered ("\n");
@ -5098,8 +5090,8 @@ recursive_dump_type (struct type *type, int spaces)
{
if (type == first_dont_print[i])
{
printf_filtered ("%*stype node ", spaces, "");
gdb_print_host_address (type, gdb_stdout);
printf_filtered ("%*stype node %s", spaces, "",
host_address_to_string (type));
printf_filtered (_(" <same as already seen type>\n"));
return;
}
@ -5108,13 +5100,11 @@ recursive_dump_type (struct type *type, int spaces)
obstack_ptr_grow (&dont_print_type_obstack, type);
}
printf_filtered ("%*stype node ", spaces, "");
gdb_print_host_address (type, gdb_stdout);
printf_filtered ("\n");
printf_filtered ("%*sname '%s' (", spaces, "",
type->name () ? type->name () : "<NULL>");
gdb_print_host_address (type->name (), gdb_stdout);
printf_filtered (")\n");
printf_filtered ("%*stype node %s\n", spaces, "",
host_address_to_string (type));
printf_filtered ("%*sname '%s' (%s)\n", spaces, "",
type->name () ? type->name () : "<NULL>",
host_address_to_string (type->name ()));
printf_filtered ("%*scode 0x%x ", spaces, "", type->code ());
switch (type->code ())
{
@ -5201,32 +5191,23 @@ recursive_dump_type (struct type *type, int spaces)
printf_filtered ("%*slength %s\n", spaces, "",
pulongest (TYPE_LENGTH (type)));
if (type->is_objfile_owned ())
{
printf_filtered ("%*sobjfile ", spaces, "");
gdb_print_host_address (type->objfile_owner (), gdb_stdout);
}
printf_filtered ("%*sobjfile %s\n", spaces, "",
host_address_to_string (type->objfile_owner ()));
else
{
printf_filtered ("%*sgdbarch ", spaces, "");
gdb_print_host_address (type->arch_owner (), gdb_stdout);
}
printf_filtered ("\n");
printf_filtered ("%*starget_type ", spaces, "");
gdb_print_host_address (TYPE_TARGET_TYPE (type), gdb_stdout);
printf_filtered ("\n");
printf_filtered ("%*sgdbarch %s\n", spaces, "",
host_address_to_string (type->arch_owner ()));
printf_filtered ("%*starget_type %s\n", spaces, "",
host_address_to_string (TYPE_TARGET_TYPE (type)));
if (TYPE_TARGET_TYPE (type) != NULL)
{
recursive_dump_type (TYPE_TARGET_TYPE (type), spaces + 2);
}
printf_filtered ("%*spointer_type ", spaces, "");
gdb_print_host_address (TYPE_POINTER_TYPE (type), gdb_stdout);
printf_filtered ("\n");
printf_filtered ("%*sreference_type ", spaces, "");
gdb_print_host_address (TYPE_REFERENCE_TYPE (type), gdb_stdout);
printf_filtered ("\n");
printf_filtered ("%*stype_chain ", spaces, "");
gdb_print_host_address (TYPE_CHAIN (type), gdb_stdout);
printf_filtered ("\n");
printf_filtered ("%*spointer_type %s\n", spaces, "",
host_address_to_string (TYPE_POINTER_TYPE (type)));
printf_filtered ("%*sreference_type %s\n", spaces, "",
host_address_to_string (TYPE_REFERENCE_TYPE (type)));
printf_filtered ("%*stype_chain %s\n", spaces, "",
host_address_to_string (TYPE_CHAIN (type)));
printf_filtered ("%*sinstance_flags 0x%x", spaces, "",
(unsigned) type->instance_flags ());
if (TYPE_CONST (type))
@ -5331,8 +5312,7 @@ recursive_dump_type (struct type *type, int spaces)
}
printf_filtered ("\n");
}
gdb_print_host_address (type->fields (), gdb_stdout);
puts_filtered ("\n");
printf ("%s\n", host_address_to_string (type->fields ()));
for (idx = 0; idx < type->num_fields (); idx++)
{
if (type->code () == TYPE_CODE_ENUM)
@ -5342,13 +5322,12 @@ recursive_dump_type (struct type *type, int spaces)
printf_filtered ("%*s[%d] bitpos %s bitsize %d type ", spaces + 2, "",
idx, plongest (type->field (idx).loc_bitpos ()),
TYPE_FIELD_BITSIZE (type, idx));
gdb_print_host_address (type->field (idx).type (), gdb_stdout);
printf_filtered (" name '%s' (",
printf_filtered ("%s name '%s' (%s)\n",
host_address_to_string (type->field (idx).type ()),
type->field (idx).name () != NULL
? type->field (idx).name ()
: "<NULL>");
gdb_print_host_address (type->field (idx).name (), gdb_stdout);
printf_filtered (")\n");
: "<NULL>",
host_address_to_string (type->field (idx).name ()));
if (type->field (idx).type () != NULL)
{
recursive_dump_type (type->field (idx).type (), spaces + 4);
@ -5366,17 +5345,14 @@ recursive_dump_type (struct type *type, int spaces)
switch (TYPE_SPECIFIC_FIELD (type))
{
case TYPE_SPECIFIC_CPLUS_STUFF:
printf_filtered ("%*scplus_stuff ", spaces, "");
gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type),
gdb_stdout);
puts_filtered ("\n");
printf_filtered ("%*scplus_stuff %s\n", spaces, "",
host_address_to_string (TYPE_CPLUS_SPECIFIC (type)));
print_cplus_stuff (type, spaces);
break;
case TYPE_SPECIFIC_GNAT_STUFF:
printf_filtered ("%*sgnat_stuff ", spaces, "");
gdb_print_host_address (TYPE_GNAT_SPECIFIC (type), gdb_stdout);
puts_filtered ("\n");
printf_filtered ("%*sgnat_stuff %s\n", spaces, "",
host_address_to_string (TYPE_GNAT_SPECIFIC (type)));
print_gnat_stuff (type, spaces);
break;
@ -5397,9 +5373,8 @@ recursive_dump_type (struct type *type, int spaces)
break;
case TYPE_SPECIFIC_SELF_TYPE:
printf_filtered ("%*sself_type ", spaces, "");
gdb_print_host_address (TYPE_SELF_TYPE (type), gdb_stdout);
puts_filtered ("\n");
printf_filtered ("%*sself_type %s\n", spaces, "",
host_address_to_string (TYPE_SELF_TYPE (type)));
break;
case TYPE_SPECIFIC_FIXED_POINT:

View File

@ -766,21 +766,17 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
fprintf_filtered (outfile, "\nPartial symtab for source file %s ",
psymtab->filename);
}
fprintf_filtered (outfile, "(object ");
gdb_print_host_address (psymtab, outfile);
fprintf_filtered (outfile, ")\n\n");
fprintf_filtered (outfile, " Read from object file %s (",
objfile_name (objfile));
gdb_print_host_address (objfile, outfile);
fprintf_filtered (outfile, ")\n");
fprintf_filtered (outfile, "(object %s)\n\n",
host_address_to_string (psymtab));
fprintf_filtered (outfile, " Read from object file %s (%s)\n",
objfile_name (objfile),
host_address_to_string (objfile));
if (psymtab->readin_p (objfile))
{
fprintf_filtered (outfile,
" Full symtab was read (at ");
gdb_print_host_address (psymtab->get_compunit_symtab (objfile), outfile);
fprintf_filtered (outfile, ")\n");
}
fprintf_filtered
(outfile,
" Full symtab was read (at %s)\n",
host_address_to_string (psymtab->get_compunit_symtab (objfile)));
fprintf_filtered (outfile, " Symbols cover text addresses ");
fputs_filtered (paddress (gdbarch, psymtab->text_low (objfile)), outfile);
@ -792,18 +788,11 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n",
psymtab->number_of_dependencies);
for (i = 0; i < psymtab->number_of_dependencies; i++)
{
fprintf_filtered (outfile, " %d ", i);
gdb_print_host_address (psymtab->dependencies[i], outfile);
fprintf_filtered (outfile, " %s\n",
psymtab->dependencies[i]->filename);
}
fprintf_filtered (outfile, " %d %s\n", i,
host_address_to_string (psymtab->dependencies[i]));
if (psymtab->user != NULL)
{
fprintf_filtered (outfile, " Shared partial symtab with user ");
gdb_print_host_address (psymtab->user, outfile);
fprintf_filtered (outfile, "\n");
}
fprintf_filtered (outfile, " Shared partial symtab with user %s\n",
host_address_to_string (psymtab->user));
if (!psymtab->global_psymbols.empty ())
{
print_partial_symbols
@ -881,12 +870,9 @@ psymbol_functions::dump (struct objfile *objfile)
for (psymtab = m_partial_symtabs->psymtabs;
psymtab != NULL;
psymtab = psymtab->next)
{
printf_filtered ("%s at ",
psymtab->filename);
gdb_print_host_address (psymtab, gdb_stdout);
printf_filtered ("\n");
}
printf_filtered ("%s at %s\n",
psymtab->filename,
host_address_to_string (psymtab));
printf_filtered ("\n\n");
}
}

View File

@ -113,11 +113,9 @@ static void
dump_objfile (struct objfile *objfile)
{
printf_filtered ("\nObject file %s: ", objfile_name (objfile));
printf_filtered ("Objfile at ");
gdb_print_host_address (objfile, gdb_stdout);
printf_filtered (", bfd at ");
gdb_print_host_address (objfile->obfd, gdb_stdout);
printf_filtered (", %d minsyms\n\n",
printf_filtered ("Objfile at %s, bfd at %s, %d minsyms\n\n",
host_address_to_string (objfile),
host_address_to_string (objfile->obfd),
objfile->per_bfd->minimal_symbol_count);
objfile->dump ();
@ -129,9 +127,9 @@ dump_objfile (struct objfile *objfile)
{
for (symtab *symtab : compunit_filetabs (cu))
{
printf_filtered ("%s at ",
symtab_to_filename_for_display (symtab));
gdb_print_host_address (symtab, gdb_stdout);
printf_filtered ("%s at %s",
symtab_to_filename_for_display (symtab),
host_address_to_string (symtab));
if (SYMTAB_OBJFILE (symtab) != objfile)
printf_filtered (", NOT ON CHAIN!");
printf_filtered ("\n");
@ -253,10 +251,9 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
if (SYMTAB_DIRNAME (symtab) != NULL)
fprintf_filtered (outfile, "Compilation directory is %s\n",
SYMTAB_DIRNAME (symtab));
fprintf_filtered (outfile, "Read from object file %s (",
objfile_name (objfile));
gdb_print_host_address (objfile, outfile);
fprintf_filtered (outfile, ")\n");
fprintf_filtered (outfile, "Read from object file %s (%s)\n",
objfile_name (objfile),
host_address_to_string (objfile));
fprintf_filtered (outfile, "Language: %s\n",
language_str (symtab->language));
@ -286,14 +283,12 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
{
b = BLOCKVECTOR_BLOCK (bv, i);
depth = block_depth (b) * 2;
fprintf_filtered (outfile, "%*sblock #%03d, object at ",
depth, "", i);
gdb_print_host_address (b, outfile);
fprintf_filtered (outfile, "%*sblock #%03d, object at %s",
depth, "", i,
host_address_to_string (b));
if (BLOCK_SUPERBLOCK (b))
{
fprintf_filtered (outfile, " under ");
gdb_print_host_address (BLOCK_SUPERBLOCK (b), outfile);
}
fprintf_filtered (outfile, " under %s",
host_address_to_string (BLOCK_SUPERBLOCK (b)));
/* drow/2002-07-10: We could save the total symbols count
even if we're using a hashtable, but nothing else but this message
wants it. */
@ -633,16 +628,11 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
break;
case LOC_BLOCK:
fprintf_filtered (outfile, "block object ");
gdb_print_host_address (SYMBOL_BLOCK_VALUE (symbol), outfile);
fprintf_filtered (outfile, ", ");
fputs_filtered (paddress (gdbarch,
BLOCK_START (SYMBOL_BLOCK_VALUE (symbol))),
outfile);
fprintf_filtered (outfile, "..");
fputs_filtered (paddress (gdbarch,
BLOCK_END (SYMBOL_BLOCK_VALUE (symbol))),
outfile);
fprintf_filtered
(outfile, "block object %s, %s..%s",
host_address_to_string (SYMBOL_BLOCK_VALUE (symbol)),
paddress (gdbarch, BLOCK_START (SYMBOL_BLOCK_VALUE (symbol))),
paddress (gdbarch, BLOCK_END (SYMBOL_BLOCK_VALUE (symbol))));
if (section)
fprintf_filtered (outfile, " section %s",
bfd_section_name (section->the_bfd_section));

View File

@ -779,14 +779,6 @@ uinteger_pow (ULONGEST v1, LONGEST v2)
}
}
/* Print a host address. */
void
gdb_print_host_address_1 (const void *addr, struct ui_file *stream)
{
fprintf_filtered (stream, "%s", host_address_to_string (addr));
}
/* An RAII class that sets up to handle input and then tears down

View File

@ -528,13 +528,6 @@ extern void fputs_highlighted (const char *str, const compiled_regex &highlight,
extern void reset_terminal_style (struct ui_file *stream);
/* Display the host ADDR on STREAM formatted as ``0x%x''. */
extern void gdb_print_host_address_1 (const void *addr, struct ui_file *stream);
/* Wrapper that avoids adding a pointless cast to all callers. */
#define gdb_print_host_address(ADDR, STREAM) \
gdb_print_host_address_1 ((const void *) ADDR, STREAM)
/* Return the address only having significant bits. */
extern CORE_ADDR address_significant (gdbarch *gdbarch, CORE_ADDR addr);