aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli/cli-utils.h
diff options
context:
space:
mode:
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>2018-07-01 22:46:41 +0200
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>2018-10-27 13:45:57 +0200
commit0d4cad90ca7c4394a1799efaa79c784f84a18161 (patch)
treed1b0f869265df959bcba8f94b47442eb446520b8 /gdb/cli/cli-utils.h
parent6951e9f3e219cb6867beccb48dde39530e48d582 (diff)
downloadbinutils-0d4cad90ca7c4394a1799efaa79c784f84a18161.zip
binutils-0d4cad90ca7c4394a1799efaa79c784f84a18161.tar.gz
binutils-0d4cad90ca7c4394a1799efaa79c784f84a18161.tar.bz2
New cli-utils.h/.c function extract_info_print_args
New cli-utils.h/.c function extract_info_print_args factorizes the extraction of the args '[-q] [-t TYPEREGEXP] [NAMEREGEXP]'. New cli-utils.h/.c function report_unrecognized_option_error factorizes reporting an unknown option for a command. These functions will be used by the commands info [args|functions|locals|variables] As extract_info_print_args will be used for 'info functions|variables' which already have the NAMEREGEXP arg, it provides a backward compatible behaviour. cli-utils.c has a new static function extract_arg_maybe_quoted that extracts an argument, possibly quoted. The behaviour of this function is similar to the parsing done by gdb_argv. gdb/ChangeLog 2018-10-27 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli-utils.c (extract_arg_maybe_quoted): New function. (extract_info_print_args): New function. (info_print_args_help): New function. (report_unrecognized_option_error): New function. * cli-utils.h (extract_arg_maybe_quoted): New function. (extract_info_print_args): New function. (info_print_args_help): New function. (report_unrecognized_option_error): New function.
Diffstat (limited to 'gdb/cli/cli-utils.h')
-rw-r--r--gdb/cli/cli-utils.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h
index fa7d02d..f591ba1 100644
--- a/gdb/cli/cli-utils.h
+++ b/gdb/cli/cli-utils.h
@@ -39,6 +39,36 @@ extern int get_number (const char **);
extern int get_number (char **);
+/* 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);
+
+/* Throws an error telling the user that ARGS starts with an option
+ unrecognized by COMMAND. */
+
+extern void report_unrecognized_option_error (const char *command,
+ const char *args);
+
+
+/* Builds the help string for a command documented by PREFIX,
+ followed by the extract_info_print_args help for ENTITY_KIND. */
+
+const char *info_print_args_help (const char *prefix,
+ const char *entity_kind);
+
/* Parse a number or a range.
A number will be of the form handled by get_number.
A range will be of the form <number1> - <number2>, and