Style the "XXX" text in ptype/o
authorTom Tromey <tom@tromey.com>
Sat, 15 May 2021 14:31:42 +0000 (08:31 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 23 Sep 2021 15:19:56 +0000 (09:19 -0600)
This patch changes gdb to use the 'highlight' style on the "XXX" text
in the output of ptype/o.

gdb/testsuite/gdb.base/style.c
gdb/testsuite/gdb.base/style.exp
gdb/typeprint.c

index 59707b3af55f9536d29d929016634e3770a2afa8..6a7934fb9b2ad8cbb475c71a84dbb51fb74bac62 100644 (file)
@@ -34,6 +34,13 @@ struct some_struct
 
 struct some_struct struct_value = { 23, "skidoo", VALUE_TWO };
 
+struct just_bitfield
+{
+  unsigned int field : 3;
+};
+
+struct just_bitfield just_bitfield_value = { 4 };
+
 int some_called_function (void)
 {
   return 0;
index 4a3428bc63feef8907265bf28293962091f6cb55..d804853a504c6687b795c27f557c92cff9fe94ab 100644 (file)
@@ -197,6 +197,24 @@ proc run_style_tests { } {
        gdb_test "print struct_value" \
            "\{$ifield = 23,.*$sfield = .*,.*$efield = $evalue.*"
 
+       set ffield [limited_style field variable]
+       set cstart [string_to_regexp "/* XXX "]
+       set cend [string_to_regexp " */"]
+       set p1field [limited_style "$cstart.*$decimal.*-bit.*padding.*$cend" \
+                        highlight]
+       set p2field [limited_style "$cstart.*$decimal.*-byte.*padding.*$cend" \
+                        highlight]
+
+       gdb_test "ptype/o just_bitfield_value" \
+           [multi_line \
+                ".* type = struct just_bitfield {" \
+                ".* unsigned int $ffield : 3;" \
+                "$p1field" \
+                "$p2field" \
+                "" \
+                ".* total size.*: *$decimal *$cend" \
+                " *}.*"]
+
        set address_style_expr [limited_style ".*\".*address.*\".*style.*" address]
        set color "blue"
        if { $currently_disabled_style == "address" } {
index 0776f634215b99278cd526d52ebb32ce4b03941d..ed391411dfef86a111bc8b8253ad5f4c5dd50bd1 100644 (file)
@@ -104,12 +104,18 @@ print_offset_data::maybe_print_hole (struct ui_file *stream,
       unsigned int hole_bit = hole % TARGET_CHAR_BIT;
 
       if (hole_bit > 0)
-       fprintf_filtered (stream, "/* XXX %2u-bit %-7s    */\n", hole_bit,
-                         for_what);
+       {
+         fprintf_styled (stream, highlight_style.style (),
+                         "/* XXX %2u-bit %-7s    */", hole_bit, for_what);
+         fputs_filtered ("\n", stream);
+       }
 
       if (hole_byte > 0)
-       fprintf_filtered (stream, "/* XXX %2u-byte %-7s   */\n", hole_byte,
-                         for_what);
+       {
+         fprintf_styled (stream, highlight_style.style (),
+                         "/* XXX %2u-byte %-7s   */", hole_byte, for_what);
+         fputs_filtered ("\n", stream);
+       }
     }
 }