From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18703 invoked by alias); 18 Aug 2009 23:39:52 -0000 Received: (qmail 18694 invoked by uid 22791); 18 Aug 2009 23:39:51 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 18 Aug 2009 23:39:42 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7INdefh026416 for ; Tue, 18 Aug 2009 19:39:40 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n7INddpm004162 for ; Tue, 18 Aug 2009 19:39:40 -0400 Received: from [IPv6:::1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n7INdbY8023684 for ; Tue, 18 Aug 2009 19:39:38 -0400 Message-ID: <4A8B3BB9.2070105@redhat.com> Date: Wed, 19 Aug 2009 01:14:00 -0000 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [RFA] Limit qualified completions Content-Type: multipart/mixed; boundary="------------070600090306080507050301" X-IsSubscribed: yes 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: 2009-08/txt/msg00297.txt.bz2 This is a multi-part message in MIME format. --------------070600090306080507050301 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 714 Hi, If the user attempts to complete symbols in a class or namespace, i.e., "complete break foo::", default_make_symbol_completion_list will return every single known global symbol in the executable. This simplistic patch (and test case) "fixes" the problem, limiting the matches to the appropriate symbols. Ok? Keith ChangeLog 2009-08-18 Keith Seitz * symtab.c (default_make_symbol_completion_list): Keep ':', too, so that we can limit searches in namespaces and classes. testsuite/ChangeLog 2009-08-18 Keith Seitz * gdb.cp/cpcompletion.exp (test_class_complete): New procedure. Add two new C++ completer tests which limit the output to a given class. --------------070600090306080507050301 Content-Type: text/plain; name="cpcompletion.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cpcompletion.patch" Content-length: 2308 Index: symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.214 diff -u -p -r1.214 symtab.c --- symtab.c 23 Jul 2009 16:03:13 -0000 1.214 +++ symtab.c 18 Aug 2009 22:38:24 -0000 @@ -3836,7 +3836,8 @@ default_make_symbol_completion_list (cha which are in symbols. */ while (p > text) { - if (isalnum (p[-1]) || p[-1] == '_' || p[-1] == '\0') + if (isalnum (p[-1]) || p[-1] == '_' || p[-1] == '\0' + || p[-1] == ':') --p; else break; Index: testsuite/gdb.cp/cpcompletion.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/cpcompletion.exp,v retrieving revision 1.3 diff -u -p -r1.3 cpcompletion.exp --- testsuite/gdb.cp/cpcompletion.exp 13 Jul 2009 19:24:18 -0000 1.3 +++ testsuite/gdb.cp/cpcompletion.exp 18 Aug 2009 22:38:24 -0000 @@ -15,6 +15,40 @@ # This file is part of the gdb testsuite. +# A helper procedure to test location completions restricted by +# class. +proc test_class_complete {class expr name matches} { + global gdb_prompt + + set matches [lsort $matches] + set cmd "complete break ${class}::$expr" + set seen {} + gdb_test_multiple $cmd $name { + "break ${class}::main" { fail "$name (saw global symbol)" } + $cmd { exp_continue } + -re "break ${class}::\[A-Za-z0-9_~\]+" { + set str $expect_out(0,string) + scan $str "break ${class}::%\[^(\]" method + lappend seen $method + exp_continue + } + -re "$gdb_prompt $" { + set failed "" + foreach got [lsort $seen] have $matches { + if {![string equal $got $have]} { + set failed $have + break + } + } + if {[string length $failed] != 0} { + fail "$name ($failed not found)" + } else { + pass $name + } + } + } +} + if $tracelevel then { strace $tracelevel } @@ -58,3 +92,11 @@ gdb_test "complete p foo1.Fo" "p foo1\\. # Test completion with an anonymous struct. gdb_test "complete p a.g" "p a\\.get" + +# Test that completion is restricted by class name (all methods) +test_class_complete Foo "" "complete class methods" \ + [list Foo Foofoo get_foo set_foo ~Foo] + +test_class_complete Foo F "complete class methods beginning with F" \ + [list Foo Foofoo] + --------------070600090306080507050301--