diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2018-11-12 10:38:44 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2018-11-12 10:38:44 -0500 |
commit | 53a89d6e5861d23b2b9ad0c82247daddc117701a (patch) | |
tree | 2fb5a0d022e771bf15e05b0a9c007bc57349a55d /gdb/skip.c | |
parent | 8a758655b3ee39bed245a6ba2fc9f81f77813443 (diff) | |
download | binutils-53a89d6e5861d23b2b9ad0c82247daddc117701a.zip binutils-53a89d6e5861d23b2b9ad0c82247daddc117701a.tar.gz binutils-53a89d6e5861d23b2b9ad0c82247daddc117701a.tar.bz2 |
Add completer for skip numbers
Add completer to various commands that accept skip numbers:
- skip enable
- skip disable
- skip delete
- info skip
These commands also accept ranges, the completer works for that but is
not very smart. It will suggest invalid ranges, for example when doing
"2-<TAB>" it will suggest "1", which would not result in a valid range.
Also, it will keep suggesting when doing "1-2-<TAB>", even though it's
an invalid syntax.
A future idea would be to make a re-usable and well-tested completer for
numbers and ranges. I think it could at least be re-used for breakpoint
and thread numbers (for example with the "enable breakpoints" command).
gdb/ChangeLog:
* skip.c (complete_skip_number): New function.
(_initialize_step_skip): Add completers to some skip commands.
gdb/testsuite/ChangeLog:
* gdb.base/skip.exp: Add standard_testfile. Add "skip delete"
completer tests.
Diffstat (limited to 'gdb/skip.c')
-rw-r--r-- | gdb/skip.c | 35 |
1 files changed, 28 insertions, 7 deletions
@@ -641,6 +641,23 @@ function_name_is_marked_for_skip (const char *function_name, return false; } +/* Completer for skip numbers. */ + +static void +complete_skip_number (cmd_list_element *cmd, + completion_tracker &completer, + const char *text, const char *word) +{ + size_t word_len = strlen (word); + + for (const skiplist_entry &entry : skiplist_entries) + { + gdb::unique_xmalloc_ptr<char> name (xstrprintf ("%d", entry.number ())); + if (strncmp (word, name.get (), word_len) == 0) + completer.add_completion (std::move (name)); + } +} + void _initialize_step_skip (void) { @@ -676,28 +693,31 @@ If no function name is given, skip the current function."), &skiplist); set_cmd_completer (c, location_completer); - add_cmd ("enable", class_breakpoint, skip_enable_command, _("\ + c = add_cmd ("enable", class_breakpoint, skip_enable_command, _("\ Enable skip entries. You can specify numbers (e.g. \"skip enable 1 3\"), \ ranges (e.g. \"skip enable 4-8\"), or both (e.g. \"skip enable 1 3 4-8\").\n\n\ If you don't specify any numbers or ranges, we'll enable all skip entries.\n\n\ Usage: skip enable [NUMBER | RANGE]..."), - &skiplist); + &skiplist); + set_cmd_completer (c, complete_skip_number); - add_cmd ("disable", class_breakpoint, skip_disable_command, _("\ + c = add_cmd ("disable", class_breakpoint, skip_disable_command, _("\ Disable skip entries. You can specify numbers (e.g. \"skip disable 1 3\"), \ ranges (e.g. \"skip disable 4-8\"), or both (e.g. \"skip disable 1 3 4-8\").\n\n\ If you don't specify any numbers or ranges, we'll disable all skip entries.\n\n\ Usage: skip disable [NUMBER | RANGE]..."), - &skiplist); + &skiplist); + set_cmd_completer (c, complete_skip_number); - add_cmd ("delete", class_breakpoint, skip_delete_command, _("\ + c = add_cmd ("delete", class_breakpoint, skip_delete_command, _("\ Delete skip entries. You can specify numbers (e.g. \"skip delete 1 3\"), \ ranges (e.g. \"skip delete 4-8\"), or both (e.g. \"skip delete 1 3 4-8\").\n\n\ If you don't specify any numbers or ranges, we'll delete all skip entries.\n\n\ Usage: skip delete [NUMBER | RANGES]..."), - &skiplist); + &skiplist); + set_cmd_completer (c, complete_skip_number); - add_info ("skip", info_skip_command, _("\ + c = add_info ("skip", info_skip_command, _("\ Display the status of skips. You can specify numbers (e.g. \"skip info 1 3\"), \ ranges (e.g. \"skip info 4-8\"), or both (e.g. \"skip info 1 3 4-8\").\n\n\ If you don't specify any numbers or ranges, we'll show all skips.\n\n\ @@ -705,6 +725,7 @@ Usage: skip info [NUMBER | RANGES]...\n\ The \"Type\" column indicates one of:\n\ \tfile - ignored file\n\ \tfunction - ignored function")); + set_cmd_completer (c, complete_skip_number); add_setshow_boolean_cmd ("skip", class_maintenance, &debug_skip, _("\ |