* [RFA] Limit qualified completions
@ 2009-08-19 1:14 Keith Seitz
2009-08-19 5:22 ` Daniel Jacobowitz
2009-08-19 22:02 ` Tom Tromey
0 siblings, 2 replies; 4+ messages in thread
From: Keith Seitz @ 2009-08-19 1:14 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 714 bytes --]
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 <keiths@redhat.com>
* 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 <keiths@redhat.com>
* gdb.cp/cpcompletion.exp (test_class_complete): New procedure.
Add two new C++ completer tests which limit the output to a given
class.
[-- Attachment #2: cpcompletion.patch --]
[-- Type: text/plain, Size: 2308 bytes --]
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]
+
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [RFA] Limit qualified completions
2009-08-19 1:14 [RFA] Limit qualified completions Keith Seitz
@ 2009-08-19 5:22 ` Daniel Jacobowitz
2009-08-19 22:02 ` Tom Tromey
1 sibling, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2009-08-19 5:22 UTC (permalink / raw)
To: Keith Seitz; +Cc: gdb-patches
On Tue, Aug 18, 2009 at 04:39:37PM -0700, Keith Seitz wrote:
> 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?
It seems to me like there must be a bigger problem with the character
list; what if foo is a template?
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] Limit qualified completions
2009-08-19 1:14 [RFA] Limit qualified completions Keith Seitz
2009-08-19 5:22 ` Daniel Jacobowitz
@ 2009-08-19 22:02 ` Tom Tromey
2009-08-24 22:27 ` Keith Seitz
1 sibling, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2009-08-19 22:02 UTC (permalink / raw)
To: Keith Seitz; +Cc: gdb-patches
>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
Keith> If the user attempts to complete symbols in a class or namespace,
Keith> i.e., "complete break foo::", default_make_symbol_completion_list will
Keith> return every single known global symbol in the executable.
Keith> This simplistic patch (and test case) "fixes" the problem, limiting
Keith> the matches to the appropriate symbols.
Keith> Ok?
I realize that Daniel already expressed some reservations about this
patch, in that it does not address all the scenarios. However, my view
is that this patch is an improvement over the current situation. I
asked Daniel about this off list and he seemed to be ok with moving
forward.
So, this is ok.
In addition to templates, I wonder what happens in this area if you try
to complete "Foo::~F" or a qualified Java name like "java.lang.Str".
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] Limit qualified completions
2009-08-19 22:02 ` Tom Tromey
@ 2009-08-24 22:27 ` Keith Seitz
0 siblings, 0 replies; 4+ messages in thread
From: Keith Seitz @ 2009-08-24 22:27 UTC (permalink / raw)
To: tromey; +Cc: gdb-patches
On 08/19/2009 02:57 PM, Tom Tromey wrote:
> In addition to templates, I wonder what happens in this area if you try
> to complete "Foo::~F" or a qualified Java name like "java.lang.Str".
All good points, for sure. I've committed the patch, and I have filed
symtab/10556 to document these problems. I'll try to pick them up
while/as my archer plate clears.
Keith
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-08-24 22:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-19 1:14 [RFA] Limit qualified completions Keith Seitz
2009-08-19 5:22 ` Daniel Jacobowitz
2009-08-19 22:02 ` Tom Tromey
2009-08-24 22:27 ` Keith Seitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox