diff options
author | Marco Barisione <mbarisione@undo.io> | 2021-05-07 15:43:30 +0100 |
---|---|---|
committer | Marco Barisione <mbarisione@undo.io> | 2021-05-07 15:43:30 +0100 |
commit | a9b49cbcd5935a713da5715799ea3b24e0a52851 (patch) | |
tree | efd3e48a50d31f4622598915d43f304b38420155 /gdb/command.h | |
parent | 97834047e13bb9f30430331c27b11412a5ed6950 (diff) | |
download | gdb-a9b49cbcd5935a713da5715799ea3b24e0a52851.zip gdb-a9b49cbcd5935a713da5715799ea3b24e0a52851.tar.gz gdb-a9b49cbcd5935a713da5715799ea3b24e0a52851.tar.bz2 |
gdb: add lookup_cmd_exact to simplify a common pattern
In code dealing with commands, there's a pattern repeated a few times of
calling lookup_cmd with some speficic arguments and then using strcmp
on the returned command to check for an exact match.
As a later patch would add a few more similar lines of code, this patch
adds a new lookup_cmd_exact function which simplify this use case.
gdb/ChangeLog:
* cli/cli-decode.c (lookup_cmd_exact): Add.
* cli/cli-script.c (do_define_command): Use lookup_cmd_exact.
(define_prefix_command): Ditto.
* command.h: Add lookup_cmd_exact.
Diffstat (limited to 'gdb/command.h')
-rw-r--r-- | gdb/command.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gdb/command.h b/gdb/command.h index 79e5017..827a196 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -326,6 +326,25 @@ extern struct cmd_list_element *lookup_cmd_1 struct cmd_list_element **result_list, std::string *default_args, int ignore_help_classes, bool lookup_for_completion_p = false); +/* Look up the command called NAME in the command list LIST. + + Unlike LOOKUP_CMD, partial matches are ignored and only exact matches + on NAME are considered. + + LIST is a chain of struct cmd_list_element's. + + If IGNORE_HELP_CLASSES is true (the default), ignore any command list + elements which are actually help classes rather than commands (i.e. + the function field of the struct cmd_list_element is null). + + If found, return the struct cmd_list_element for that command, + otherwise return NULLPTR. */ + +extern struct cmd_list_element *lookup_cmd_exact + (const char *name, + struct cmd_list_element *list, + bool ignore_help_classes = true); + extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *, const char * ); |