diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-07-11 21:02:59 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-07-22 10:43:00 +0100 |
commit | a8eab7c6d529ddd248ff5243bb22e9346196e376 (patch) | |
tree | 00960f66becd428c1f7ceb20b862e14de0a37b86 /gdb/symtab.c | |
parent | b4603c34644847e2113e8c29408db09049c5c30f (diff) | |
download | gdb-a8eab7c6d529ddd248ff5243bb22e9346196e376.zip gdb-a8eab7c6d529ddd248ff5243bb22e9346196e376.tar.gz gdb-a8eab7c6d529ddd248ff5243bb22e9346196e376.tar.bz2 |
gdb: Switch "info types" over to use the gdb::options framework
Adds a new -q flag to "info types" using the gdb::option framework.
This -q flag is similar to the -q flag already present for "info
variables" and "info functions".
gdb/ChangeLog:
* NEWS: Mention adding -q option to "info types".
* symtab.c (struct info_types_options): New struct.
(info_types_options_defs): New variable.
(make_info_types_options_def_group): New function.
(info_types_command): Use gdb::option framework to parse options.
(info_types_command_completer): New function.
(_initialize_symtab): Extend the help text on "info types" and
register command completer.
gdb/doc/ChangeLog:
* gdb.texinfo (Symbols): Add information about -q flag to "info
types".
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r-- | gdb/symtab.c | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index ce1cdcf..ea2b813 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4773,11 +4773,62 @@ info_functions_command (const char *args, int from_tty) opts.type_regexp, from_tty); } +/* Holds the -q option for the 'info types' command. */ + +struct info_types_options +{ + int quiet = false; +}; + +/* The options used by the 'info types' command. */ + +static const gdb::option::option_def info_types_options_defs[] = { + gdb::option::boolean_option_def<info_types_options> { + "q", + [] (info_types_options *opt) { return &opt->quiet; }, + nullptr, /* show_cmd_cb */ + nullptr /* set_doc */ + } +}; + +/* Returns the option group used by 'info types'. */ + +static gdb::option::option_def_group +make_info_types_options_def_group (info_types_options *opts) +{ + return {{info_types_options_defs}, opts}; +} + +/* Implement the 'info types' command. */ static void -info_types_command (const char *regexp, int from_tty) +info_types_command (const char *args, int from_tty) { - symtab_symbol_info (false, regexp, TYPES_DOMAIN, NULL, from_tty); + info_types_options opts; + + auto grp = make_info_types_options_def_group (&opts); + gdb::option::process_options + (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp); + if (args != nullptr && *args == '\0') + args = nullptr; + symtab_symbol_info (opts.quiet, args, TYPES_DOMAIN, NULL, from_tty); +} + +/* Command completer for 'info types' command. */ + +static void +info_types_command_completer (struct cmd_list_element *ignore, + completion_tracker &tracker, + const char *text, const char * /* word */) +{ + const auto group + = make_info_types_options_def_group (nullptr); + if (gdb::option::complete_options + (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, group)) + return; + + const char *word = advance_to_expression_complete_word_point (tracker, text); + symbol_completer (ignore, tracker, text, word); } /* Breakpoint all functions matching regular expression. */ @@ -6041,8 +6092,12 @@ Prints the functions.\n"), print "struct foo *". I also think "ptype" or "whatis" is more likely to be useful (but if there is much disagreement "info types" can be fixed). */ - add_info ("types", info_types_command, - _("All type names, or those matching REGEXP.")); + c = add_info ("types", info_types_command, _("\ +All type names, or those matching REGEXP.\n\ +Usage: info types [-q] [REGEXP]\n\ +Print information about all types matching REGEXP, or all types if no\n\ +REGEXP is given. The optional flag -q disables printing of headers.")); + set_cmd_completer_handle_brkchars (c, info_types_command_completer); add_info ("sources", info_sources_command, _("Source files in the program.")); |