From bcb92f7ba7b22ac882c000cabfd7ca8bea47c184 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Tue, 1 Oct 2024 16:55:28 +0100 Subject: [PATCH] gdb: more file name styling 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 --- gdb/ada-lang.c | 15 +++++++++------ gdb/cli/cli-cmds.c | 25 ++++++++++++++++--------- gdb/disasm.c | 5 ++++- gdb/source.c | 19 ++++++++++++------- 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 2ea7fd2a848..d5ea581d6a3 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -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") diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 2e57b0d3cb2..ea2e156a00c 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -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 diff --git a/gdb/disasm.c b/gdb/disasm.c index 7209cfc227b..541293ac4fc 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -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"); diff --git a/gdb/source.c b/gdb/source.c index 61ed088ba69..292d2bf71c5 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -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))); } }