From: Tom Tromey Date: Sat, 11 Dec 2021 21:57:17 +0000 (-0700) Subject: Remove print_spaces X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6bebf813ac2d4b92facae7b18161aad1b734a894;p=binutils-gdb.git 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. --- diff --git a/gdb/cli-out.c b/gdb/cli-out.c index d4259902657..a3c189e4a8e 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 fb1a4ff02b6..bc74ca5ce9b 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 dd2134b3c63..36b7432803b 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 7e215595cd8..ca15ab41f2d 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 7d27f9ba801..138bd3bb641 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 4d20ebdffc9..03424e6af95 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);