From: Luis Machado Date: Fri, 18 Dec 2020 16:33:36 +0000 (-0300) Subject: Add switch to control compact/verbose printing of capabilities X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d833267116b55d67ff1c5d617f8dd2a3a5fdd68;p=thirdparty%2Fbinutils-gdb.git Add switch to control compact/verbose printing of capabilities 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 * 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) : New member variable. --- diff --git a/gdb/valprint.c b/gdb/valprint.c index d7993f39edf..a3a2ba0c58e 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -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; }, diff --git a/gdb/valprint.h b/gdb/valprint.h index f81cabb727d..66a6039ff44 100644 --- a/gdb/valprint.h +++ b/gdb/valprint.h @@ -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;