gdb: more file name styling

Message ID 9d9968d881ad0d5290d8acce5b57ea658d6a5995.1727798443.git.aburgess@redhat.com
State New
Headers
Series gdb: more file name styling |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Andrew Burgess Oct. 1, 2024, 4:01 p.m. UTC
  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.
---
 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(-)


base-commit: c5c85987434f5faee54d05547a47ab7748d1eb0f
  

Comments

Tom Tromey Oct. 1, 2024, 4:35 p.m. UTC | #1
>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:

Andrew> While looking at the recent line number styling commit I noticed a few
Andrew> places where we could add more file name styling.  So lets do that.

Thank you.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  
Andrew Burgess Oct. 2, 2024, 9:24 a.m. UTC | #2
Tom Tromey <tom@tromey.com> writes:

>>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
>
> Andrew> While looking at the recent line number styling commit I noticed a few
> Andrew> places where we could add more file name styling.  So lets do that.
>
> Thank you.
> Approved-By: Tom Tromey <tom@tromey.com>

Pushed.

Thanks,
Andrew
  

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 9b61f19b072..0334df5fb89 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)));
     }
 }