]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add switch to control compact/verbose printing of capabilities
authorLuis Machado <luis.machado@linaro.org>
Fri, 18 Dec 2020 16:33:36 +0000 (13:33 -0300)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 1 Sep 2022 22:53:23 +0000 (15:53 -0700)
Add a new option set/show "print compact-capabilities" that default to "on".

This makes GDB default to printing capabilities in compact format, the CHERI
format.

gdb/ChangeLog:

2020-12-30  Luis Machado  <luis.machado@arm.com>

* valprint.c (user_print_options): Initialize compact_capabilities.
(show_print_compact_capabilities): New function.
(generic_value_print_capability): Use compact_capabilities option.
(value_print_option_defs): New compact_capabilities option.
* valprint.h (value_print_options) <compact_capabilities>: New member
variable.

gdb/valprint.c
gdb/valprint.h

index d7993f39edf8d0426ad65b2fe681346c28a887f8..a3a2ba0c58ed981126e22c9fb38df7219a8475bb 100644 (file)
@@ -118,6 +118,7 @@ struct value_print_options user_print_options =
   1,                           /* memory_tag_violations */
   0,                           /* stop_print_at_null */
   0,                           /* print_array_indexes */
+  1,                           /* compact_capabilities */
   0,                           /* deref_ref */
   1,                           /* static_field_print */
   1,                           /* pascal_static_field_print */
@@ -197,6 +198,18 @@ show_print_array_indexes (struct ui_file *file, int from_tty,
   fprintf_filtered (file, _("Printing of array indexes is %s.\n"), value);
 }
 
+/* By default we print capabilities in compact form.  This may be changed to
+   print them in a more verbose format.  */
+
+static void
+show_print_compact_capabilities (struct ui_file *file, int from_tty,
+                                struct cmd_list_element *c,
+                                const char *value)
+{
+  fprintf_filtered (file, _("Printing of compact capabilities is %s.\n"),
+                           value);
+}
+
 /* Print repeat counts if there are more than this many repetitions of an
    element in an array.  Referenced by the low level language dependent
    print routines.  */
@@ -528,7 +541,8 @@ generic_value_print_capability (struct value *val, struct ui_file *stream,
       uint128_t dummy_cap;
       memcpy (&dummy_cap, contents, length);
       capability cap (dummy_cap, tag);
-      fprintf_filtered (stream, "%s ", cap.to_str (true).c_str ());
+      fprintf_filtered (stream, "%s ",
+                       cap.to_str (options->compact_capabilities).c_str ());
     }
 
   return;
@@ -3054,6 +3068,15 @@ static const gdb::option::option_def value_print_option_defs[] = {
     NULL, /* help_doc */
   },
 
+  boolean_option_def {
+    "compact-capabilities",
+    [] (value_print_options *opt) { return &opt->compact_capabilities; },
+    show_print_compact_capabilities, /* show_cmd_cb */
+    N_("Set compact printing of capabilities."),
+    N_("Show compact printing of capabilities."),
+    NULL, /* help_doc */
+  },
+
   uinteger_option_def {
     "elements",
     [] (value_print_options *opt) { return &opt->print_max; },
index f81cabb727d8e81afe33791486cdad124d0712e0..66a6039ff44e0273dfe653f5a76a33046de0d684 100644 (file)
@@ -75,6 +75,9 @@ struct value_print_options
      an array.  */
   bool print_array_indexes;
 
+  /* True if capabilities should be displayed in a compact form.  */
+  bool compact_capabilities;
+
   /* If true, then dereference references, otherwise just print
      them like pointers.  */
   bool deref_ref;