]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: more address styling throughout
authorAndrew Burgess <aburgess@redhat.com>
Fri, 9 Jan 2026 15:03:40 +0000 (15:03 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 13 Jan 2026 10:38:20 +0000 (10:38 +0000)
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 <tom@tromey.com>
gdb/ada-valprint.c
gdb/c-valprint.c
gdb/f-valprint.c
gdb/go-valprint.c
gdb/infcmd.c
gdb/m2-valprint.c
gdb/p-valprint.c
gdb/rust-lang.c
gdb/symfile.c
gdb/symmisc.c
gdb/valprint.c

index 51320c217009387b0d5fea3774aea10c53491c88..032ffc285875a08ea728da20f75fd0c54e67289a 100644 (file)
@@ -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
        {
index f757d408716c4f5118b78a22f3412609669062bf..522b42497d12e5433637a21f24651f076eae75f7 100644 (file)
@@ -28,6 +28,7 @@
 #include "cp-abi.h"
 #include "target.h"
 #include "objfiles.h"
+#include "cli/cli-style.h"
 \f
 
 /* 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;
     }
 
index 57ad568c2a5c10eeac98c0f77599d3ff9d445a78..e91ae972e3ed3f69036d559b5c3701c06182f8e9 100644 (file)
@@ -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;
            }
 
index 570509315257d1b9a81f940498d723c94bbdecde..877232e1ad56be3d7fc9f0e700b6fe0ae6e50128 100644 (file)
@@ -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);
     }
 
index 0b9ca48b70f02fb236ad2f10da58e0c8142df7a7..1ddb6ad144784dd44c3afd5f7ac19548c27e3642 100644 (file)
@@ -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");
     }
 
index f16f794ac1185698114db839c485096906b6801d..eb2be9d33a84de4066ca34071a7a22c1d608adc8 100644 (file)
@@ -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)
index a6285a286d45b5d77096c3b55377f90dfa13fbbc..3e9b1c259b83ae5302e71ea27a2ebcfd13e8388a 100644 (file)
@@ -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;
        }
 
index 6631d231d640eb2318e071bcdcdc45e8a106b38a..57fe46dd1c9a16d024f11cbdc4061b9305d0a297 100644 (file)
@@ -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);
              }
 
index 8366d27048f4e831f9cd6e5e36c9013c4f1105a6..aadb449153eca716fb829a8c68af6be60501d1eb 100644 (file)
@@ -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++;
index 77e1ca6e6de8e6a3d6b9467c8dc8ad52a491c9ce..edf6a29a0aee818e55f0d278fb1419dea74ef534 100644 (file)
@@ -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));
index c95e23aa4327a093c9a64e4faf4d2a1f8a51b317..b37b494dec67d1c30a1712f984166690b4bd45f4 100644 (file)
@@ -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);