[2/3] Add styling to cooked_index::dump

Message ID 20240927-dwarf-incl-stuff-v1-2-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
  This patch adds some styling to cooked_index::dump, making the output
a bit easier to read.
---
 gdb/dwarf2/cooked-index.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
  

Patch

diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 4073c924890d6aec22989aa1c321a4fd00173a33..cf67bb6cef3a41518a41421959bf6b16bab43df0 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -38,6 +38,7 @@ 
 #include <chrono>
 #include <unordered_set>
 #include "cli/cli-cmds.h"
+#include "cli/cli-style.h"
 
 /* We don't want gdb to exit while it is in the process of writing to
    the index cache.  So, all live cooked index vectors are stored
@@ -796,10 +797,20 @@  cooked_index::dump (gdbarch *arch)
     {
       QUIT;
 
+      ui_file_style style;
+      if (entry->matches (SEARCH_FUNCTION_DOMAIN))
+	style = function_name_style.style ();
+      else if (entry->matches (SEARCH_VAR_DOMAIN))
+	style = variable_name_style.style ();
+
       gdb_printf ("    [%zu] ((cooked_index_entry *) %p)\n", i++, entry);
-      gdb_printf ("    name:       %s\n", entry->name);
-      gdb_printf ("    canonical:  %s\n", entry->canonical);
-      gdb_printf ("    qualified:  %s\n", entry->full_name (&temp_storage, false));
+      gdb_printf ("    name:       %ps\n", styled_string (style,
+							  entry->name));
+      gdb_printf ("    canonical:  %ps\n", styled_string (style,
+							 entry->canonical));
+      gdb_printf ("    qualified:  %ps\n",
+		  styled_string (style,
+				 entry->full_name (&temp_storage, false)));
       gdb_printf ("    DWARF tag:  %s\n", dwarf_tag_name (entry->tag));
       gdb_printf ("    flags:      %s\n", to_string (entry->flags).c_str ());
       gdb_printf ("    DIE offset: %s\n", sect_offset_str (entry->die_offset));