[1/3] Add styling to symmisc.c

Message ID 20240927-dwarf-incl-stuff-v1-1-cb925fa76af3@tromey.com
State New
Headers
Series Add more styling to some "maint" output |

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-aarch64 success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed

Commit Message

Tom Tromey Sept. 27, 2024, 7:50 p.m. UTC
  I was looking at some "maint" output and noticed that symmisc.c could
apply styling in a few spots.  This patch is the result.
---
 gdb/symmisc.c | 81 ++++++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 53 insertions(+), 28 deletions(-)
  

Patch

diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 3b004aee1d85385b9222efad9345650de0c2406e..230d6a1639b846274bb4e08c960449930f228f3f 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -58,7 +58,9 @@  print_objfile_statistics (void)
     for (objfile *objfile : pspace->objfiles ())
       {
 	QUIT;
-	gdb_printf (_("Statistics for '%s':\n"), objfile_name (objfile));
+	gdb_printf (_("Statistics for '%ps':\n"),
+		    styled_string (file_name_style.style (),
+				   objfile_name (objfile)));
 	if (OBJSTAT (objfile, n_stabs) > 0)
 	  gdb_printf (_("  Number of \"stab\" symbols read: %d\n"),
 		      OBJSTAT (objfile, n_stabs));
@@ -104,8 +106,9 @@  print_objfile_statistics (void)
 
 	gdb_printf (_("  Total memory used for string cache: %d\n"),
 		    objfile->per_bfd->string_cache.memory_used ());
-	gdb_printf (_("Byte cache statistics for '%s':\n"),
-		    objfile_name (objfile));
+	gdb_printf (_("Byte cache statistics for '%ps':\n"),
+		    styled_string (file_name_style.style (),
+				   objfile_name (objfile)));
 	objfile->per_bfd->string_cache.print_statistics ("string cache");
 	objfile->print_stats (true);
       }
@@ -114,7 +117,9 @@  print_objfile_statistics (void)
 static void
 dump_objfile (struct objfile *objfile)
 {
-  gdb_printf ("\nObject file %s:  ", objfile_name (objfile));
+  gdb_printf ("\nObject file %ps:  ",
+	      styled_string (file_name_style.style (),
+			     objfile_name (objfile)));
   gdb_printf ("Objfile at %s, bfd at %s, %d minsyms\n\n",
 	      host_address_to_string (objfile),
 	      host_address_to_string (objfile->obfd.get ()),
@@ -129,8 +134,9 @@  dump_objfile (struct objfile *objfile)
 	{
 	  for (symtab *symtab : cu->filetabs ())
 	    {
-	      gdb_printf ("%s at %s",
-			  symtab_to_filename_for_display (symtab),
+	      gdb_printf ("%ps at %s",
+			  styled_string (file_name_style.style (),
+					 symtab_to_filename_for_display (symtab)),
 			  host_address_to_string (symtab));
 	      if (symtab->compunit ()->objfile () != objfile)
 		gdb_printf (", NOT ON CHAIN!");
@@ -150,7 +156,9 @@  dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
   int index;
   char ms_type;
 
-  gdb_printf (outfile, "\nObject file %s:\n\n", objfile_name (objfile));
+  gdb_printf (outfile, "\nObject file %ps:\n\n",
+	      styled_string (file_name_style.style (),
+			     objfile_name (objfile)));
   if (objfile->per_bfd->minimal_symbol_count == 0)
     {
       gdb_printf (outfile, "No minimal symbols found.\n");
@@ -240,15 +248,18 @@  dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
   const struct linetable *l;
   int depth;
 
-  gdb_printf (outfile, "\nSymtab for file %s at %s\n",
-	      symtab_to_filename_for_display (symtab),
+  gdb_printf (outfile, "\nSymtab for file %ps at %s\n",
+	      styled_string (file_name_style.style (),
+			     symtab_to_filename_for_display (symtab)),
 	      host_address_to_string (symtab));
 
   if (symtab->compunit ()->dirname () != NULL)
-    gdb_printf (outfile, "Compilation directory is %s\n",
-		symtab->compunit ()->dirname ());
-  gdb_printf (outfile, "Read from object file %s (%s)\n",
-	      objfile_name (objfile),
+    gdb_printf (outfile, "Compilation directory is %ps\n",
+		styled_string (file_name_style.style (),
+			       symtab->compunit ()->dirname ()));
+  gdb_printf (outfile, "Read from object file %ps (%s)\n",
+	      styled_string (file_name_style.style (),
+			     objfile_name (objfile)),
 	      host_address_to_string (objfile));
   gdb_printf (outfile, "Language: %s\n",
 	      language_str (symtab->language ()));
@@ -294,8 +305,9 @@  dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
 	  gdb_puts (paddress (gdbarch, b->end ()), outfile);
 	  if (b->function ())
 	    {
-	      gdb_printf (outfile, ", function %s",
-			  b->function ()->linkage_name ());
+	      gdb_printf (outfile, ", function %ps",
+			  styled_string (function_name_style.style (),
+					 b->function ()->linkage_name ()));
 	      if (b->function ()->demangled_name () != NULL)
 		{
 		  gdb_printf (outfile, ", %s",
@@ -758,7 +770,9 @@  maintenance_info_symtabs (const char *regexp, int from_tty)
 		  {
 		    if (! printed_objfile_start)
 		      {
-			gdb_printf ("{ objfile %s ", objfile_name (objfile));
+			gdb_printf ("{ objfile %ps ",
+				    styled_string (file_name_style.style (),
+						   objfile_name (objfile)));
 			gdb_stdout->wrap_here (2);
 			gdb_printf ("((struct objfile *) %s)\n",
 				    host_address_to_string (objfile));
@@ -774,9 +788,12 @@  maintenance_info_symtabs (const char *regexp, int from_tty)
 				    (cust->producer () != nullptr
 				     ? cust->producer () : "(null)"));
 			gdb_printf ("    name %s\n", cust->name);
-			gdb_printf ("    dirname %s\n",
-				    (cust->dirname () != NULL
-				     ? cust->dirname () : "(null)"));
+			if (cust->dirname () == nullptr)
+			  gdb_printf ("    dirname (null)\n");
+			else
+			  gdb_printf ("    dirname %ps\n",
+				      styled_string (file_name_style.style (),
+						     cust->dirname ()));
 			gdb_printf ("    blockvector"
 				    " ((struct blockvector *) %s)\n",
 				    host_address_to_string
@@ -806,15 +823,19 @@  maintenance_info_symtabs (const char *regexp, int from_tty)
 			printed_compunit_symtab_start = 1;
 		      }
 
-		    gdb_printf ("\t{ symtab %s ",
-				symtab_to_filename_for_display (symtab));
+		    gdb_printf
+		      ("\t{ symtab %ps ",
+		       styled_string (file_name_style.style (),
+				      symtab_to_filename_for_display (symtab)));
 		    gdb_stdout->wrap_here (4);
 		    gdb_printf ("((struct symtab *) %s)\n",
 				host_address_to_string (symtab));
-		    gdb_printf ("\t  fullname %s\n",
-				symtab->fullname () != nullptr
-				? symtab->fullname ()
-				: "(null)");
+		    if (symtab->fullname () == nullptr)
+		      gdb_printf ("\t  fullname (void)\n");
+		    else
+		      gdb_printf ("\t  fullname %ps\n",
+				  styled_string (file_name_style.style (),
+						 symtab->fullname ()));
 		    gdb_printf ("\t  "
 				"linetable ((struct linetable *) %s)\n",
 				host_address_to_string
@@ -865,14 +886,18 @@  maintenance_check_symtabs (const char *ignore, int from_tty)
 	      {
 		if (! printed_objfile_start)
 		  {
-		    gdb_printf ("{ objfile %s ", objfile_name (objfile));
+		    gdb_printf ("{ objfile %ps ",
+				styled_string (file_name_style.style (),
+					       objfile_name (objfile)));
 		    gdb_stdout->wrap_here (2);
 		    gdb_printf ("((struct objfile *) %s)\n",
 				host_address_to_string (objfile));
 		    printed_objfile_start = 1;
 		  }
-		gdb_printf ("  { symtab %s\n",
-			    symtab_to_filename_for_display (symtab));
+		gdb_printf
+		  ("  { symtab %ps\n",
+		   styled_string (file_name_style.style (),
+				  symtab_to_filename_for_display (symtab)));
 		if (cust->blockvector () == NULL)
 		  gdb_printf ("    NULL blockvector\n");
 		gdb_printf ("  }\n");