aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-12-11 14:57:17 -0700
committerTom Tromey <tom@tromey.com>2021-12-20 09:49:41 -0700
commit6bebf813ac2d4b92facae7b18161aad1b734a894 (patch)
treeaaa28c29f4665e5db0bf87e0167f88122e55b433
parentb0715493df19e5223251c5be0efc7f180aa0a5ff (diff)
downloadgdb-6bebf813ac2d4b92facae7b18161aad1b734a894.zip
gdb-6bebf813ac2d4b92facae7b18161aad1b734a894.tar.gz
gdb-6bebf813ac2d4b92facae7b18161aad1b734a894.tar.bz2
Remove print_spaces
This removes the print_spaces helper function, in favor of using the "*%s" idiom that's already used in many places in gdb. One spot (in symmisc.c) is changed to use print_spaces_filtered, because the rest of that function is using filtered output. (This highlights one way that the printf idiom is better -- this error is harder to make when using that.) Regression tested on x86-64 Fedora 34.
-rw-r--r--gdb/cli-out.c2
-rw-r--r--gdb/compile/compile-loc2c.c2
-rw-r--r--gdb/dwarf2/read.c32
-rw-r--r--gdb/symmisc.c6
-rw-r--r--gdb/utils.c6
-rw-r--r--gdb/utils.h2
6 files changed, 19 insertions, 31 deletions
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index d425990..a3c189e 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -206,7 +206,7 @@ cli_ui_out::do_spaces (int numspaces)
return;
if (test_flags (unfiltered_output))
- print_spaces (numspaces, m_streams.back ());
+ fprintf_unfiltered (m_streams.back (), "%*s", numspaces, "");
else
print_spaces_filtered (numspaces, m_streams.back ());
}
diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c
index fb1a4ff..bc74ca5 100644
--- a/gdb/compile/compile-loc2c.c
+++ b/gdb/compile/compile-loc2c.c
@@ -675,7 +675,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
uint64_t uoffset, reg;
int64_t offset;
- print_spaces (indent - 2, stream);
+ stream->printf ("%*s", indent - 2, "");
if (info[op_ptr - base].label)
{
print_label (stream, scope, op_ptr - base);
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index dd2134b..36b7432 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -22980,31 +22980,28 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
{
unsigned int i;
- print_spaces (indent, f);
- fprintf_unfiltered (f, "Die: %s (abbrev %d, offset %s)\n",
+ fprintf_unfiltered (f, "%*sDie: %s (abbrev %d, offset %s)\n",
+ indent, "",
dwarf_tag_name (die->tag), die->abbrev,
sect_offset_str (die->sect_off));
if (die->parent != NULL)
- {
- print_spaces (indent, f);
- fprintf_unfiltered (f, " parent at offset: %s\n",
- sect_offset_str (die->parent->sect_off));
- }
+ fprintf_unfiltered (f, "%*s parent at offset: %s\n",
+ indent, "",
+ sect_offset_str (die->parent->sect_off));
- print_spaces (indent, f);
- fprintf_unfiltered (f, " has children: %s\n",
- dwarf_bool_name (die->child != NULL));
+ fprintf_unfiltered (f, "%*s has children: %s\n",
+ indent, "",
+ dwarf_bool_name (die->child != NULL));
- print_spaces (indent, f);
- fprintf_unfiltered (f, " attributes:\n");
+ fprintf_unfiltered (f, "%*s attributes:\n", indent, "");
for (i = 0; i < die->num_attrs; ++i)
{
- print_spaces (indent, f);
- fprintf_unfiltered (f, " %s (%s) ",
- dwarf_attr_name (die->attrs[i].name),
- dwarf_form_name (die->attrs[i].form));
+ fprintf_unfiltered (f, "%*s %s (%s) ",
+ indent, "",
+ dwarf_attr_name (die->attrs[i].name),
+ dwarf_form_name (die->attrs[i].form));
switch (die->attrs[i].form)
{
@@ -23120,8 +23117,7 @@ dump_die_1 (struct ui_file *f, int level, int max_level, struct die_info *die)
if (die->child != NULL)
{
- print_spaces (indent, f);
- fprintf_unfiltered (f, " Children:");
+ fprintf_unfiltered (f, "%*s Children:", indent, "");
if (level + 1 < max_level)
{
fprintf_unfiltered (f, "\n");
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 7e21559..ca15ab4 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -286,8 +286,8 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
{
b = BLOCKVECTOR_BLOCK (bv, i);
depth = block_depth (b) * 2;
- print_spaces (depth, outfile);
- fprintf_filtered (outfile, "block #%03d, object at ", i);
+ fprintf_filtered (outfile, "%*sblock #%03d, object at ",
+ depth, "", i);
gdb_print_host_address (b, outfile);
if (BLOCK_SUPERBLOCK (b))
{
@@ -510,7 +510,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
else
section = NULL;
- print_spaces (depth, outfile);
+ print_spaces_filtered (depth, outfile);
if (SYMBOL_DOMAIN (symbol) == LABEL_DOMAIN)
{
fprintf_filtered (outfile, "label %s at ", symbol->print_name ());
diff --git a/gdb/utils.c b/gdb/utils.c
index 7d27f9b..138bd3b 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -779,12 +779,6 @@ uinteger_pow (ULONGEST v1, LONGEST v2)
}
}
-void
-print_spaces (int n, struct ui_file *file)
-{
- fputs_unfiltered (n_spaces (n), file);
-}
-
/* Print a host address. */
void
diff --git a/gdb/utils.h b/gdb/utils.h
index 4d20ebd..03424e6 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -467,8 +467,6 @@ extern void fprintf_unfiltered (struct ui_file *, const char *, ...)
extern void printf_unfiltered (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
-extern void print_spaces (int, struct ui_file *);
-
extern void print_spaces_filtered (int, struct ui_file *);
extern const char *n_spaces (int);