]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: more file name styling
authorAndrew Burgess <aburgess@redhat.com>
Tue, 1 Oct 2024 15:55:28 +0000 (16:55 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Wed, 2 Oct 2024 09:10:20 +0000 (10:10 +0100)
While looking at the recent line number styling commit I noticed a few
places where we could add more file name styling.  So lets do that.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/ada-lang.c
gdb/cli/cli-cmds.c
gdb/disasm.c
gdb/source.c

index 2ea7fd2a848f828e1d4ee2e13d963d454b29be36..d5ea581d6a3c1e69c678998af76a25a549983b48 100644 (file)
@@ -3698,9 +3698,11 @@ See set/show multiple-symbol."));
              gdb_printf ("[%d] ", i + first_choice);
              ada_print_symbol_signature (gdb_stdout, syms[i].symbol,
                                          &type_print_raw_options);
-             gdb_printf (_(" at %s:%d\n"),
-                         symtab_to_filename_for_display (symtab),
-                         syms[i].symbol->line ());
+             gdb_printf (_(" at %ps:%ps\n"),
+                         styled_string (file_name_style.style (),
+                                        symtab_to_filename_for_display (symtab)),
+                         styled_string (line_number_style.style (),
+                                        pulongest (syms[i].symbol->line ())));
            }
          else if (is_enumeral
                   && syms[i].symbol->type ()->name () != NULL)
@@ -3719,9 +3721,10 @@ See set/show multiple-symbol."));
 
              if (symtab != NULL)
                gdb_printf (is_enumeral
-                           ? _(" in %s (enumeral)\n")
-                           : _(" at %s:?\n"),
-                           symtab_to_filename_for_display (symtab));
+                           ? _(" in %ps (enumeral)\n")
+                           : _(" at %ps:?\n"),
+                           styled_string (file_name_style.style (),
+                                          symtab_to_filename_for_display (symtab)));
              else
                gdb_printf (is_enumeral
                            ? _(" (enumeral)\n")
index 2e57b0d3cb28cbd536008efc291b7b8d655934a2..ea2e156a00ccabf94aa4af98d5dac798662ca98b 100644 (file)
@@ -1016,16 +1016,23 @@ edit_command (const char *arg, int from_tty)
          gdbarch = sal.symtab->compunit ()->objfile ()->arch ();
          sym = find_pc_function (sal.pc);
          if (sym)
-           gdb_printf ("%s is in %s (%s:%d).\n",
-                       paddress (gdbarch, sal.pc),
-                       sym->print_name (),
-                       symtab_to_filename_for_display (sal.symtab),
-                       sal.line);
+           gdb_printf ("%ps is in %ps (%ps:%ps).\n",
+                       styled_string (address_style.style (),
+                                      paddress (gdbarch, sal.pc)),
+                       styled_string (function_name_style.style (),
+                                      sym->print_name ()),
+                       styled_string (file_name_style.style (),
+                                      symtab_to_filename_for_display (sal.symtab)),
+                       styled_string (line_number_style.style (),
+                                      pulongest (sal.line)));
          else
-           gdb_printf ("%s is at %s:%d.\n",
-                       paddress (gdbarch, sal.pc),
-                       symtab_to_filename_for_display (sal.symtab),
-                       sal.line);
+           gdb_printf ("%ps is at %ps:%ps.\n",
+                       styled_string (address_style.style (),
+                                      paddress (gdbarch, sal.pc)),
+                       styled_string (file_name_style.style (),
+                                      symtab_to_filename_for_display (sal.symtab)),
+                       styled_string (line_number_style.style (),
+                                      pulongest (sal.line)));
        }
 
       /* If what was given does not imply a symtab, it must be an
index 7209cfc227b6e2da66ed7814291a625eac7a8401..541293ac4fcd021dd2b22879f6572cef0f79d99c 100644 (file)
@@ -899,7 +899,10 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch,
                 output includes the source specs for each line.  */
              if (sal.symtab != NULL)
                {
-                 uiout->text (symtab_to_filename_for_display (sal.symtab));
+                 auto filename = symtab_to_filename_for_display (sal.symtab);
+                 uiout->message ("%ps",
+                                 styled_string (file_name_style.style (),
+                                                filename));
                }
              else
                uiout->text ("unknown");
index 61ed088ba696ceeef32520d6afed3c3ce681c98c..292d2bf71c5cac55677f80792fae2b8eeb147dae 100644 (file)
@@ -1386,7 +1386,9 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
       last_line_listed = loc->line ();
       if (flags & PRINT_SOURCE_LINES_FILENAME)
        {
-         uiout->text (symtab_to_filename_for_display (s));
+         uiout->message ("%ps",
+                         styled_string (file_name_style.style (),
+                                        symtab_to_filename_for_display (s)));
          uiout->text (":");
        }
 
@@ -1553,10 +1555,11 @@ info_line_command (const char *arg, int from_tty)
 
          if (start_pc == end_pc)
            {
-             gdb_printf ("Line %ps of \"%s\"",
+             gdb_printf ("Line %ps of \"%ps\"",
                          styled_string (line_number_style.style (),
                                         pulongest (sal.line)),
-                         symtab_to_filename_for_display (sal.symtab));
+                         styled_string (file_name_style.style (),
+                                        symtab_to_filename_for_display (sal.symtab)));
              gdb_stdout->wrap_here (2);
              gdb_printf (" is at address ");
              print_address (gdbarch, start_pc, gdb_stdout);
@@ -1565,10 +1568,11 @@ info_line_command (const char *arg, int from_tty)
            }
          else
            {
-             gdb_printf ("Line %ps of \"%s\"",
+             gdb_printf ("Line %ps of \"%ps\"",
                          styled_string (line_number_style.style (),
                                         pulongest (sal.line)),
-                         symtab_to_filename_for_display (sal.symtab));
+                         styled_string (file_name_style.style (),
+                                        symtab_to_filename_for_display (sal.symtab)));
              gdb_stdout->wrap_here (2);
              gdb_printf (" starts at address ");
              print_address (gdbarch, start_pc, gdb_stdout);
@@ -1593,10 +1597,11 @@ info_line_command (const char *arg, int from_tty)
        /* Is there any case in which we get here, and have an address
           which the user would want to see?  If we have debugging symbols
           and no line numbers?  */
-       gdb_printf (_("Line number %ps is out of range for \"%s\".\n"),
+       gdb_printf (_("Line number %ps is out of range for \"%ps\".\n"),
                    styled_string (line_number_style.style (),
                                   pulongest (sal.line)),
-                   symtab_to_filename_for_display (sal.symtab));
+                   styled_string (file_name_style.style (),
+                                  symtab_to_filename_for_display (sal.symtab)));
     }
 }
 \f