From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19905 invoked by alias); 8 Jan 2013 16:42:29 -0000 Received: (qmail 19821 invoked by uid 22791); 8 Jan 2013 16:42:26 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 08 Jan 2013 16:42:17 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r08GgHDG010997 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 8 Jan 2013 11:42:17 -0500 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r08GgFFW027232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 8 Jan 2013 11:42:16 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Subject: RFC: completion for "set cp-abi" Date: Tue, 08 Jan 2013 16:42:00 -0000 Message-ID: <87zk0j39ug.fsf@fleche.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-01/txt/msg00135.txt.bz2 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