diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-07-10 22:52:38 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-07-11 20:18:17 +0100 |
commit | b16507e0917169555f8bbfcb1d6c9685813ccf6c (patch) | |
tree | 192bf877c552f553987b353e04f15dc710962b46 /gdb/cli/cli-utils.h | |
parent | 021d8588f6ca843a2aada955d00851fbb62f8a62 (diff) | |
download | binutils-b16507e0917169555f8bbfcb1d6c9685813ccf6c.zip binutils-b16507e0917169555f8bbfcb1d6c9685813ccf6c.tar.gz binutils-b16507e0917169555f8bbfcb1d6c9685813ccf6c.tar.bz2 |
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.
Diffstat (limited to 'gdb/cli/cli-utils.h')
-rw-r--r-- | gdb/cli/cli-utils.h | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h index c2a0f37..a3826be 100644 --- a/gdb/cli/cli-utils.h +++ b/gdb/cli/cli-utils.h @@ -43,22 +43,28 @@ extern int get_number (char **); error instead of returning 0. */ extern ULONGEST get_ulongest (const char **pp, int trailer = '\0'); -/* Extract from ARGS the arguments [-q] [-t TYPEREGEXP] [--] NAMEREGEXP. - - The caller is responsible to initialize *QUIET to false, *REGEXP - and *T_REGEXP to "". - extract_info_print_args can then be called iteratively to search - for valid arguments, as part of a 'main parsing loop' searching for - -q/-t/-- arguments together with other flags and options. - - Returns true and updates *ARGS + one of *QUIET, *REGEXP, *T_REGEXP if - it finds a valid argument. - Returns false if no valid argument is found at the beginning of ARGS. */ - -extern bool extract_info_print_args (const char **args, - bool *quiet, - std::string *regexp, - std::string *t_regexp); +/* Structure to hold the values of the options used by the 'info + variables' command and other similar commands. These correspond to the + -q and -t options. */ + +struct info_print_options +{ + int quiet = false; + char *type_regexp = nullptr; + + ~info_print_options () + { + xfree (type_regexp); + } +}; + +/* Extract options from ARGS for commands like 'info variables', placing + the options into OPTS. ARGS is updated to point to the first character + after the options, or, if there is nothing after the options, then ARGS + is set to nullptr. */ + +extern void extract_info_print_options (info_print_options *opts, + const char **args); /* Throws an error telling the user that ARGS starts with an option unrecognized by COMMAND. */ |