From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: RFC: completion for "set cp-abi"
Date: Tue, 08 Jan 2013 16:42:00 -0000 [thread overview]
Message-ID: <87zk0j39ug.fsf@fleche.redhat.com> (raw)
This patch adds a completion function for "set cp-abi".
Built and regtested on x86-64 Fedora 16.
New test case included.
Tom
* cp-abi.c (cp_abi_completer): New function.
(_initialize_cp_abi): Set completer for "set cp-abi".
* gdb.base/completion.exp: Add "set cp-abi" completion test.
---
gdb/cp-abi.c | 28 ++++++++++++++++++++++++++--
gdb/testsuite/gdb.base/completion.exp | 3 +++
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
index 37cf9c9..39da11a 100644
--- a/gdb/cp-abi.c
+++ b/gdb/cp-abi.c
@@ -314,6 +314,27 @@ set_cp_abi_cmd (char *args, int from_tty)
error (_("Could not find \"%s\" in ABI list"), args);
}
+/* A completion function for "set cp-abi". */
+
+static VEC (char_ptr) *
+cp_abi_completer (struct cmd_list_element *ignore,
+ char *text, char *word)
+{
+ static const char **cp_abi_names;
+
+ if (cp_abi_names == NULL)
+ {
+ int i;
+
+ cp_abi_names = XNEWVEC (const char *, num_cp_abis + 1);
+ for (i = 0; i < num_cp_abis; ++i)
+ cp_abi_names[i] = cp_abis[i]->shortname;
+ cp_abis[i] = NULL;
+ }
+
+ return complete_on_enum (cp_abi_names, text, word);
+}
+
/* Show the currently selected C++ ABI. */
static void
@@ -334,13 +355,16 @@ extern initialize_file_ftype _initialize_cp_abi; /* -Wmissing-prototypes */
void
_initialize_cp_abi (void)
{
+ struct cmd_list_element *c;
+
register_cp_abi (&auto_cp_abi);
switch_to_cp_abi ("auto");
- add_cmd ("cp-abi", class_obscure, set_cp_abi_cmd, _("\
+ c = add_cmd ("cp-abi", class_obscure, set_cp_abi_cmd, _("\
Set the ABI used for inspecting C++ objects.\n\
\"set cp-abi\" with no arguments will list the available ABIs."),
- &setlist);
+ &setlist);
+ set_cmd_completer (c, cp_abi_completer);
add_cmd ("cp-abi", class_obscure, show_cp_abi_cmd,
_("Show the ABI used for inspecting C++ objects."),
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index 566f5e0..2492226 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -707,6 +707,9 @@ gdb_test "complete ptype struct some_" "ptype struct some_struct"
gdb_test "complete ptype enum some_" "ptype enum some_enum"
gdb_test "complete ptype union some_" "ptype union some_union"
+
+gdb_test "complete set cp-abi aut" "set cp-abi auto"
+
# Restore globals modified in this test...
set timeout $oldtimeout1
--
1.7.7.6
next reply other threads:[~2013-01-08 16:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-08 16:42 Tom Tromey [this message]
2013-01-17 16:25 ` Tom Tromey
2013-01-17 20:03 ` Regression for gdb.base/completion.exp [Re: RFC: completion for "set cp-abi"] Jan Kratochvil
2013-01-17 20:23 ` Tom Tromey
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=87zk0j39ug.fsf@fleche.redhat.com \
--to=tromey@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