From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 17/24] "backtrace full/no-filters/hide" completer
Date: Wed, 22 May 2019 21:00:00 -0000 [thread overview]
Message-ID: <20190522205327.2568-18-palves@redhat.com> (raw)
In-Reply-To: <20190522205327.2568-1-palves@redhat.com>
"backtrace"'s completer now completes on command options:
(gdb) bt -[TAB]
-entry-values -full -no-filters -past-main
-frame-arguments -hide -past-entry -raw-frame-arguments
But it doesn't know how to complete on qualifiers:
(gdb) bt fu[TAB]
funlockfile futimens futimes.c
funlockfile.c futimens.c futimesat
futex-internal.h futimes futimesat.c
This commit fixes that:
(gdb) bt fu[TAB]ll
(gdb) bt n[TAB]o-filters
(gdb) bt h[TAB]ide
I considered teaching the gdb::option framework to handle non-'-'
options, but decided it wasn't worth it for this special case, and I'd
rather not make it easy to add new qualifier-like options.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* stack.c (parse_backtrace_qualifiers): New.
(backtrace_command): Use it.
(backtrace_command_completer): Complete on qualifiers.
gdb/testsuite/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* gdb.base/options.exp (test-backtrace): Test completing qualifiers.
---
gdb/stack.c | 84 ++++++++++++++++++++++++++++----------
gdb/testsuite/gdb.base/options.exp | 11 +++++
2 files changed, 73 insertions(+), 22 deletions(-)
diff --git a/gdb/stack.c b/gdb/stack.c
index 3054c797c74..c53d39b1be0 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -2027,6 +2027,45 @@ make_backtrace_options_def_group (frame_print_options *fp_opts,
}};
}
+/* Parse the backtrace command's qualifiers. Returns ARG advanced
+ past the qualifiers, if any. BT_CMD_OPTS, if not null, is used to
+ store the parsed qualifiers. */
+
+static const char *
+parse_backtrace_qualifiers (const char *arg,
+ backtrace_cmd_options *bt_cmd_opts = nullptr)
+{
+ while (true)
+ {
+ const char *save_arg = arg;
+ std::string this_arg = extract_arg (&arg);
+
+ if (this_arg.empty ())
+ return arg;
+
+ if (subset_compare (this_arg.c_str (), "no-filters"))
+ {
+ if (bt_cmd_opts != nullptr)
+ bt_cmd_opts->no_filters = true;
+ }
+ else if (subset_compare (this_arg.c_str (), "full"))
+ {
+ if (bt_cmd_opts != nullptr)
+ bt_cmd_opts->full = true;
+ }
+ else if (subset_compare (this_arg.c_str (), "hide"))
+ {
+ if (bt_cmd_opts != nullptr)
+ bt_cmd_opts->hide = true;
+ }
+ else
+ {
+ /* Not a recognized qualifier, so stop. */
+ return save_arg;
+ }
+ }
+}
+
static void
backtrace_command (const char *arg, int from_tty)
{
@@ -2043,28 +2082,7 @@ backtrace_command (const char *arg, int from_tty)
compatibility. */
if (arg != NULL)
{
- while (true)
- {
- const char *save_arg = arg;
- std::string this_arg = extract_arg (&arg);
-
- if (this_arg.empty ())
- break;
-
- if (subset_compare (this_arg.c_str (), "no-filters"))
- bt_cmd_opts.no_filters = true;
- else if (subset_compare (this_arg.c_str (), "full"))
- bt_cmd_opts.full = true;
- else if (subset_compare (this_arg.c_str (), "hide"))
- bt_cmd_opts.hide = true;
- else
- {
- /* Not a recognized argument, so stop. */
- arg = save_arg;
- break;
- }
- }
-
+ arg = parse_backtrace_qualifiers (arg, &bt_cmd_opts);
if (*arg == '\0')
arg = NULL;
}
@@ -2090,6 +2108,28 @@ backtrace_command_completer (struct cmd_list_element *ignore,
(tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, group))
return;
+ if (*text != '\0')
+ {
+ const char *p = skip_to_space (text);
+ if (*p == '\0')
+ {
+ static const char *const backtrace_cmd_qualifier_choices[] = {
+ "full", "no-filters", "hide", nullptr,
+ };
+ complete_on_enum (tracker, backtrace_cmd_qualifier_choices,
+ text, text);
+
+ if (tracker.have_completions ())
+ return;
+ }
+ else
+ {
+ const char *cmd = parse_backtrace_qualifiers (text);
+ tracker.advance_custom_word_point_by (cmd - text);
+ text = cmd;
+ }
+ }
+
const char *word = advance_to_expression_complete_word_point (tracker, text);
expression_completer (ignore, tracker, text, word);
}
diff --git a/gdb/testsuite/gdb.base/options.exp b/gdb/testsuite/gdb.base/options.exp
index 6132b1470a4..a4bd686fe5f 100644
--- a/gdb/testsuite/gdb.base/options.exp
+++ b/gdb/testsuite/gdb.base/options.exp
@@ -256,6 +256,17 @@ proc_with_prefix test-backtrace {} {
"-raw-frame-arguments"
}
+ # Test that we complete the qualifiers, if there's any.
+ test_gdb_complete_unique \
+ "backtrace ful" \
+ "backtrace full"
+ test_gdb_complete_unique \
+ "backtrace hid" \
+ "backtrace hide"
+ test_gdb_complete_unique \
+ "backtrace no-fil" \
+ "backtrace no-filters"
+
global binfile
clean_restart $binfile
--
2.14.5
next prev parent reply other threads:[~2019-05-22 21:00 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-22 20:53 [PATCH 00/24] gdb::option framework, "print -OPT", other cmd options Pedro Alves
2019-05-22 20:53 ` [PATCH 15/24] Introduce rename_cmd Pedro Alves
2019-05-25 19:58 ` Philippe Waroquiers
2019-05-29 16:03 ` Pedro Alves
2019-05-29 18:30 ` Pedro Alves
2019-05-30 10:22 ` Philippe Waroquiers
2019-05-30 20:01 ` Pedro Alves
2019-05-22 20:53 ` [PATCH 19/24] Introduce complete_command Pedro Alves
2019-05-22 20:53 ` [PATCH 18/24] lib/completion-support.exp: Add test_gdb_completion_offers_commands Pedro Alves
2019-05-22 20:53 ` [PATCH 04/24] Make check_for_argument skip whitespace after arg itself Pedro Alves
2019-05-22 20:53 ` [PATCH 11/24] number_or_range_parser::get_number, don't treat "1 -" as a range Pedro Alves
2019-05-22 20:53 ` [PATCH 07/24] Remove "show" command completers Pedro Alves
2019-05-23 19:28 ` Sergio Durigan Junior
2019-05-24 11:25 ` Pedro Alves
2019-05-24 14:21 ` Sergio Durigan Junior
2019-05-22 20:53 ` [PATCH 03/24] Fix TID parser bug Pedro Alves
2019-05-22 20:53 ` [PATCH 08/24] gdb.base/settings.exp: Fix comment typo Pedro Alves
2019-05-24 11:40 ` Pedro Alves
2019-05-22 20:54 ` [PATCH 05/24] Allow "unlimited" abbreviations Pedro Alves
2019-05-22 20:54 ` [PATCH 06/24] Fix "set enum-command value garbage" Pedro Alves
2019-05-23 19:13 ` Sergio Durigan Junior
2019-05-24 11:39 ` Pedro Alves
2019-05-22 20:54 ` [PATCH 21/24] "thread apply 1 -- -" vs "frame apply level 0 -- -" Pedro Alves
2019-05-22 20:54 ` [PATCH 12/24] Introduce generic command options framework Pedro Alves
2019-05-25 7:43 ` Philippe Waroquiers
2019-05-25 10:31 ` Pedro Alves
2019-05-22 20:54 ` [PATCH 09/24] New set/show testing framework (gdb.base/settings.exp) Pedro Alves
2019-05-23 4:15 ` Eli Zaretskii
2019-05-22 20:54 ` [PATCH 02/24] Fix latent bug with custom word point completers Pedro Alves
2019-05-22 20:54 ` [PATCH 10/24] boolean/auto-boolean commands, make "o" ambiguous Pedro Alves
2019-05-22 20:54 ` [PATCH 22/24] Make "thread apply" use the gdb::option framework Pedro Alves
2019-05-25 20:24 ` Philippe Waroquiers
2019-05-29 15:38 ` Pedro Alves
2019-05-22 20:54 ` [PATCH 01/24] Fix latent bug in custom word point completion handling Pedro Alves
2019-05-22 20:54 ` [PATCH 14/24] Migrate rest of compile commands to new options framework Pedro Alves
2019-05-22 20:54 ` [PATCH 20/24] Make "frame apply" support -OPT options Pedro Alves
2019-05-25 20:12 ` Philippe Waroquiers
2019-05-29 15:13 ` Pedro Alves
2019-05-29 15:25 ` Pedro Alves
2019-05-22 20:58 ` [PATCH 16/24] Make "backtrace" " Pedro Alves
2019-05-22 20:58 ` [PATCH 13/24] Make "print" and "compile print" " Pedro Alves
2019-05-24 19:49 ` Sergio Durigan Junior
2019-05-25 10:10 ` Pedro Alves
2019-05-25 10:37 ` Andreas Schwab
2019-05-22 21:00 ` [PATCH 24/24] NEWS and manual changes for command options changes Pedro Alves
2019-05-23 4:31 ` Eli Zaretskii
2019-05-23 15:01 ` Pedro Alves
2019-05-23 15:07 ` Eli Zaretskii
2019-05-23 15:31 ` Pedro Alves
2019-05-25 20:40 ` Philippe Waroquiers
2019-05-29 16:03 ` Pedro Alves
2019-05-22 21:00 ` Pedro Alves [this message]
2019-05-22 21:03 ` [PATCH 23/24] Delete parse_flags/parse_flags_qcs Pedro Alves
2019-05-22 21:46 ` [PATCH 00/24] gdb::option framework, "print -OPT", other cmd options Pedro Alves
2019-05-24 19:58 ` Sergio Durigan Junior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190522205327.2568-18-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox