gdb: Make use of gdb::option framework for some info commands

Update the 'info variables', 'info functions', 'info locals', and
'info args' commands to make use of the gdb::options framework.

There should be no user visible changes after this commit as I have
left the help text generation using the existing mechanism, which
already tries to customise the text for each of the commands.

gdb/ChangeLog:

	* cli/cli-utils.c (extract_info_print_args): Delete.
	(extract_arg_maybe_quoted): Delete.
	(info_print_options_defs): New variable.
	(make_info_print_options_def_group): New function.
	(extract_info_print_options): Define new function.
	* cli/cli-utils.h (extract_info_print_args): Delete.
	(struct info_print_options): New structure.
	(extract_info_print_options): Declare new function.
	* stack.c (info_locals_command): Update to use new
	extract_info_print_options, also add a header comment.
	(info_args_command): Likewise.
	* symtab.c (info_variables_command): Likewise.
	(info_functions_command): Likewise.
This commit is contained in:
Andrew Burgess 2019-07-10 22:52:38 +01:00
parent 021d8588f6
commit b16507e091
5 changed files with 96 additions and 168 deletions

View file

@ -4687,6 +4687,9 @@ symtab_symbol_info (bool quiet,
gdb_assert (kind <= TYPES_DOMAIN);
if (regexp != nullptr && *regexp == '\0')
regexp = nullptr;
/* Must make sure that if we're interrupted, symbols gets freed. */
std::vector<symbol_search> symbols = search_symbols (regexp, kind,
t_regexp, 0, NULL);
@ -4742,47 +4745,28 @@ symtab_symbol_info (bool quiet,
}
}
/* Implement the 'info variables' command. */
static void
info_variables_command (const char *args, int from_tty)
{
std::string regexp;
std::string t_regexp;
bool quiet = false;
info_print_options opts;
extract_info_print_options (&opts, &args);
while (args != NULL
&& extract_info_print_args (&args, &quiet, &regexp, &t_regexp))
;
if (args != NULL)
report_unrecognized_option_error ("info variables", args);
symtab_symbol_info (quiet,
regexp.empty () ? NULL : regexp.c_str (),
VARIABLES_DOMAIN,
t_regexp.empty () ? NULL : t_regexp.c_str (),
from_tty);
symtab_symbol_info (opts.quiet, args, VARIABLES_DOMAIN,
opts.type_regexp, from_tty);
}
/* Implement the 'info functions' command. */
static void
info_functions_command (const char *args, int from_tty)
{
std::string regexp;
std::string t_regexp;
bool quiet = false;
info_print_options opts;
extract_info_print_options (&opts, &args);
while (args != NULL
&& extract_info_print_args (&args, &quiet, &regexp, &t_regexp))
;
if (args != NULL)
report_unrecognized_option_error ("info functions", args);
symtab_symbol_info (quiet,
regexp.empty () ? NULL : regexp.c_str (),
FUNCTIONS_DOMAIN,
t_regexp.empty () ? NULL : t_regexp.c_str (),
from_tty);
symtab_symbol_info (opts.quiet, args, FUNCTIONS_DOMAIN,
opts.type_regexp, from_tty);
}