From: Andrew Burgess Date: Fri, 9 Jan 2026 15:03:40 +0000 (+0000) Subject: gdb: more address styling throughout X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a95d4c2167277b3546bf9a51bd01f4fc4d89ab62;p=thirdparty%2Fbinutils-gdb.git gdb: more address styling throughout I looked for the pattern 'gdb_puts (paddress (', these are places in GDB where we are printing a target address without styling. I changed most of what I found to print the address as styled. I did leave a few unchanged in psymtab.c, these are all in maintenance commands 'maint print psymbols', 'maint info psymtabs', and 'maint check psymtabs'. None of these commands appear to print anything for me (do we even use partial symtabs these days? I thought not) so I didn't want to mess with commands that I couldn't test. Other than the additional styling, there should be no user visible changes after this commit. Approved-By: Tom Tromey --- diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 51320c21700..032ffc28587 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -789,7 +789,8 @@ ada_value_print_num (struct value *val, struct ui_file *stream, int recurse, gdb_printf (stream, "("); type_print (type, "", stream, -1); gdb_printf (stream, ") "); - gdb_puts (paddress (gdbarch, addr), stream); + fputs_styled (paddress (gdbarch, addr), address_style.style (), + stream); } else { diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index f757d408716..522b42497d1 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -28,6 +28,7 @@ #include "cp-abi.h" #include "target.h" #include "objfiles.h" +#include "cli/cli-style.h" /* A helper for c_textual_element_type. This checks the name of the @@ -158,7 +159,8 @@ print_unpacked_pointer (struct type *type, struct type *elttype, demangle); else if (options->addressprint) { - gdb_puts (paddress (gdbarch, address), stream); + fputs_styled (paddress (gdbarch, address), address_style.style (), + stream); want_space = 1; } diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 57ad568c2a5..e91ae972e3e 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -509,7 +509,8 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream, stream, demangle); else if (options->addressprint && options->format != 's') { - gdb_puts (paddress (gdbarch, addr), stream); + fputs_styled (paddress (gdbarch, addr), address_style.style (), + stream); want_space = 1; } diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c index 57050931525..877232e1ad5 100644 --- a/gdb/go-valprint.c +++ b/gdb/go-valprint.c @@ -65,7 +65,7 @@ print_go_string (struct type *type, /* TODO(dje): Print address of struct or actual string? */ if (options->addressprint) { - gdb_puts (paddress (gdbarch, addr), stream); + fputs_styled (paddress (gdbarch, addr), address_style.style (), stream); gdb_puts (" ", stream); } diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 0b9ca48b70f..1ddb6ad1447 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1285,7 +1285,8 @@ jump_command (const char *arg, int from_tty) if (from_tty) { gdb_printf (_("Continuing at ")); - gdb_puts (paddress (gdbarch, addr)); + fputs_styled (paddress (gdbarch, addr), address_style.style (), + gdb_stdout); gdb_printf (".\n"); } diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index f16f794ac11..eb2be9d33a8 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -199,7 +199,8 @@ print_unpacked_pointer (struct type *type, if (options->addressprint && options->format != 's') { - gdb_puts (paddress (gdbarch, address), stream); + fputs_styled (paddress (gdbarch, address), address_style.style (), + stream); want_space = 1; } @@ -232,7 +233,7 @@ print_variable_at_address (struct type *type, struct type *elttype = check_typedef (type->target_type ()); gdb_printf (stream, "["); - gdb_puts (paddress (gdbarch, addr), stream); + fputs_styled (paddress (gdbarch, addr), address_style.style (), stream); gdb_printf (stream, "] : "); if (elttype->code () != TYPE_CODE_UNDEF) diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index a6285a286d4..3e9b1c259b8 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -179,7 +179,8 @@ pascal_language::value_print_inner (struct value *val, if (options->addressprint && options->format != 's') { - gdb_puts (paddress (gdbarch, addr), stream); + fputs_styled (paddress (gdbarch, addr), address_style.style (), + stream); want_space = 1; } diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 6631d231d64..57fe46dd1c9 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -680,7 +680,8 @@ rust_language::value_print_inner if (opts.addressprint) { - gdb_puts (paddress (arch, addr), stream); + fputs_styled (paddress (arch, addr), address_style.style (), + stream); gdb_puts (" ", stream); } diff --git a/gdb/symfile.c b/gdb/symfile.c index 8366d27048f..aadb449153e 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3180,13 +3180,17 @@ list_overlays_command (const char *args, int from_tty) name = bfd_section_name (osect.the_bfd_section); gdb_printf ("Section %s, loaded at ", name); - gdb_puts (paddress (gdbarch, lma)); + fputs_styled (paddress (gdbarch, lma), address_style.style (), + gdb_stdout); gdb_puts (" - "); - gdb_puts (paddress (gdbarch, lma + size)); + fputs_styled (paddress (gdbarch, lma + size), + address_style.style (), gdb_stdout); gdb_printf (", mapped at "); - gdb_puts (paddress (gdbarch, vma)); + fputs_styled (paddress (gdbarch, vma), address_style.style (), + gdb_stdout); gdb_puts (" - "); - gdb_puts (paddress (gdbarch, vma + size)); + fputs_styled (paddress (gdbarch, vma + size), + address_style.style (), gdb_stdout); gdb_puts ("\n"); nmapped++; diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 77e1ca6e6de..edf6a29a0ae 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -214,7 +214,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile) not try to respect copy relocations. */ CORE_ADDR addr = (CORE_ADDR (msymbol->unrelocated_address ()) + objfile->section_offsets[msymbol->section_index ()]); - gdb_puts (paddress (gdbarch, addr), outfile); + fputs_styled (paddress (gdbarch, addr), address_style.style (), outfile); gdb_printf (outfile, " %s", msymbol->linkage_name ()); if (section) { @@ -277,7 +277,8 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) for (int i = 0; i < len; i++) { gdb_printf (outfile, _(" line %d at "), l->item[i].line); - gdb_puts (paddress (gdbarch, l->item[i].pc (objfile)), outfile); + fputs_styled (paddress (gdbarch, l->item[i].pc (objfile)), + address_style.style (), outfile); if (l->item[i].is_stmt) gdb_printf (outfile, _("\t(stmt)")); gdb_printf (outfile, "\n"); @@ -304,9 +305,11 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) wants it. */ gdb_printf (outfile, _(", %d symbols in "), mdict_size (b->multidict ())); - gdb_puts (paddress (gdbarch, b->start ()), outfile); + fputs_styled (paddress (gdbarch, b->start ()), + address_style.style (), outfile); gdb_printf (outfile, ".."); - gdb_puts (paddress (gdbarch, b->end ()), outfile); + fputs_styled (paddress (gdbarch, b->end ()), + address_style.style (), outfile); if (b->function ()) { gdb_printf (outfile, _(", function %ps"), @@ -522,8 +525,8 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol, if (symbol->domain () == LABEL_DOMAIN) { gdb_printf (outfile, _("label %s at "), symbol->print_name ()); - gdb_puts (paddress (gdbarch, symbol->value_address ()), - outfile); + fputs_styled (paddress (gdbarch, symbol->value_address ()), + address_style.style (), outfile); if (section) gdb_printf (outfile, _(" section %s\n"), bfd_section_name (section->the_bfd_section)); @@ -592,7 +595,8 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol, case LOC_STATIC: gdb_printf (outfile, _("static at ")); - gdb_puts (paddress (gdbarch, symbol->value_address ()), outfile); + fputs_styled (paddress (gdbarch, symbol->value_address ()), + address_style.style (), outfile); if (section) gdb_printf (outfile, _(" section %s"), bfd_section_name (section->the_bfd_section)); @@ -632,7 +636,8 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol, case LOC_LABEL: gdb_printf (outfile, _("label at ")); - gdb_puts (paddress (gdbarch, symbol->value_address ()), outfile); + fputs_styled (paddress (gdbarch, symbol->value_address ()), + address_style.style (), outfile); if (section) gdb_printf (outfile, _(" section %s"), bfd_section_name (section->the_bfd_section)); diff --git a/gdb/valprint.c b/gdb/valprint.c index c95e23aa432..b37b494dec6 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -463,7 +463,8 @@ print_unpacked_pointer (struct type *type, struct type *elttype, if (options->symbol_print) print_address_demangle (options, gdbarch, address, stream, demangle); else if (options->addressprint) - gdb_puts (paddress (gdbarch, address), stream); + fputs_styled (paddress (gdbarch, address), address_style.style (), + stream); } /* generic_val_print helper for TYPE_CODE_ARRAY. */ @@ -604,7 +605,8 @@ print_ref_address (struct type *type, const gdb_byte *address_buffer, = extract_typed_address (address_buffer + embedded_offset, type); gdb_printf (stream, "@"); - gdb_puts (paddress (gdbarch, address), stream); + fputs_styled (paddress (gdbarch, address), address_style.style (), + stream); } /* Else: we have a non-addressable value, such as a DW_AT_const_value. */ } @@ -1982,7 +1984,8 @@ print_function_pointer_address (const struct value_print_options *options, if (options->addressprint && func_addr != address) { gdb_puts ("@", stream); - gdb_puts (paddress (gdbarch, address), stream); + fputs_styled (paddress (gdbarch, address), address_style.style (), + stream); gdb_puts (": ", stream); } print_address_demangle (options, gdbarch, func_addr, stream, demangle);