Re: [PATCH 32/40] Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching]

Pedro Alves
2017-11-24T16:57:28Z

On 11/24/2017 04:48 PM, Pedro Alves wrote:
> Hey Keith,
>
> So I took your suggestion and ran with it. And in the end
> I like it! See more below.
>

...

> Surprisingly, I didn't have to change much in the tests. But I did
> extend them to cover these new possibilities. I'll show the tests
> delta as a follow up.

Here it is. This covers -qualified with linespecs that have more
components than just then function name, and also explicit locations
with -qualified in different positions.

From c06f24e28a4ae9afbb40b7c4f61db57b3e9c2b7b Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Fri, 24 Nov 2017 16:32:04 +0000
Subject: [PATCH] Fix/extend tests

---
gdb/testsuite/gdb.linespec/cpcompletion.exp | 64 ++++++++++++++----------
gdb/testsuite/gdb.linespec/explicit.exp | 77 ++++++++++++++++++-----------
2 files changed, 85 insertions(+), 56 deletions(-)

diff --git a/gdb/testsuite/gdb.linespec/cpcompletion.exp b/gdb/testsuite/gdb.linespec/cpcompletion.exp
index 5522b19..25f7f81 100644
--- a/gdb/testsuite/gdb.linespec/cpcompletion.exp
+++ b/gdb/testsuite/gdb.linespec/cpcompletion.exp
@@ -190,37 +190,49 @@ proc_with_prefix overload-2 {} {
# Test linespecs / locations using fully-qualified names.

proc_with_prefix fqn {} {
- set cmd_prefix "b -qualified"

- test_gdb_complete_unique \
- "$cmd_prefix overload2_func" \
- "$cmd_prefix overload2_function(overload2_arg1)"
+ # "-qualified" works with both explicit locations and linespecs.
+ # Also test that combining a source file with a function name
+ # still results in a full match, with both linespecs and explicit
+ # locations.
+ foreach cmd_prefix {
+ "b -qualified "
+ "b -qualified -function "
+ "b -qualified cpls.cc:"
+ "b -qualified -source cpls.cc -function "
+ "b -source cpls.cc -qualified -function "
+ } {
+ test_gdb_complete_unique \
+ "${cmd_prefix}overload2_func" \
+ "${cmd_prefix}overload2_function(overload2_arg1)"

- # Drill down until we find a unique completion.
- test_gdb_complete_multiple "$cmd_prefix " "ns_overload2_test::" "" {
- "ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
- "ns_overload2_test::(anonymous namespace)::ns_overload2_test::struct_overload2_test::overload2_function(overload2_arga)"
- "ns_overload2_test::(anonymous namespace)::overload2_function(overload2_arg7)"
- "ns_overload2_test::(anonymous namespace)::struct_overload2_test::overload2_function(overload2_arg8)"
- "ns_overload2_test::overload2_function(overload2_arg5)"
- "ns_overload2_test::struct_overload2_test::overload2_function(overload2_arg6)"
- }
+ # Drill down until we find a unique completion.
+ test_gdb_complete_multiple "${cmd_prefix}" "ns_overload2_test::" "" {
+ "ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
+ "ns_overload2_test::(anonymous namespace)::ns_overload2_test::struct_overload2_test::overload2_function(overload2_arga)"
+ "ns_overload2_test::(anonymous namespace)::overload2_function(overload2_arg7)"
+ "ns_overload2_test::(anonymous namespace)::struct_overload2_test::overload2_function(overload2_arg8)"
+ "ns_overload2_test::overload2_function(overload2_arg5)"
+ "ns_overload2_test::struct_overload2_test::overload2_function(overload2_arg6)"
+ }

- test_gdb_complete_multiple "$cmd_prefix " "ns_overload2_test::(anonymous namespace)::" "" {
- "ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
- "ns_overload2_test::(anonymous namespace)::ns_overload2_test::struct_overload2_test::overload2_function(overload2_arga)"
- "ns_overload2_test::(anonymous namespace)::overload2_function(overload2_arg7)"
- "ns_overload2_test::(anonymous namespace)::struct_overload2_test::overload2_function(overload2_arg8)"
- }
+ test_gdb_complete_multiple "${cmd_prefix}" "ns_overload2_test::(anonymous namespace)::" "" {
+ "ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
+ "ns_overload2_test::(anonymous namespace)::ns_overload2_test::struct_overload2_test::overload2_function(overload2_arga)"
+ "ns_overload2_test::(anonymous namespace)::overload2_function(overload2_arg7)"
+ "ns_overload2_test::(anonymous namespace)::struct_overload2_test::overload2_function(overload2_arg8)"
+ }

- test_gdb_complete_multiple "$cmd_prefix " "ns_overload2_test::(anonymous namespace)::ns_overload2_test::" "" {
- "ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
- "ns_overload2_test::(anonymous namespace)::ns_overload2_test::struct_overload2_test::overload2_function(overload2_arga)"
- }
+ test_gdb_complete_multiple "${cmd_prefix}" "ns_overload2_test::(anonymous namespace)::ns_overload2_test::" "" {
+ "ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
+ "ns_overload2_test::(anonymous namespace)::ns_overload2_test::struct_overload2_test::overload2_function(overload2_arga)"
+ }

- test_gdb_complete_unique \
- "$cmd_prefix ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_func" \
- "$cmd_prefix ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
+ test_gdb_complete_unique \
+ "${cmd_prefix}ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_func" \
+ "${cmd_prefix}ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
+
+ }
}

# Check that a fully-qualified looked name don't match symbols in
diff --git a/gdb/testsuite/gdb.linespec/explicit.exp b/gdb/testsuite/gdb.linespec/explicit.exp
index 8fcdf62..1e7f0dc 100644
--- a/gdb/testsuite/gdb.linespec/explicit.exp
+++ b/gdb/testsuite/gdb.linespec/explicit.exp
@@ -409,40 +409,57 @@ namespace eval $testfile {
"task"
"thread"
}
- foreach what { "-function" "-label" "-line" "-qualified" "-source" } {
- with_test_prefix "complete after $what" {
- if {$what != "-line"} {
- test_gdb_complete_multiple \
- "b $what argument " "" "" $completions_list
- test_gdb_complete_unique \
- "b $what argument thr" \
- "b $what argument thread"
- test_gdb_complete_unique \
- "b $what argument -fun" \
- "b $what argument -function"
- } else {
- # After -line, we expect a number / offset.
- foreach line {"10" "+10" "-10"} {
- test_gdb_complete_multiple \
- "b -line $line " "" "" $completions_list
- test_gdb_complete_unique \
- "b -line $line thr" \
- "b -line $line thread"
- test_gdb_complete_unique \
- "b -line $line -fun" \
- "b -line $line -function"
+ foreach what { "-function" "-label" "-line" "-source" } {
+ # Also test with "-qualified" appearing before the
+ # explicit location.
+ foreach prefix {"" "-qualified "} {
+
+ # ... and with "-qualified" appearing after the
+ # explicit location.
+ foreach suffix {"" " -qualified"} {
+ with_test_prefix "complete after $prefix$what$suffix" {
+ if {$what != "-line"} {
+ set w "$prefix$what argument$suffix "
+ test_gdb_complete_multiple \
+ "b $w" "" "" $completions_list
+ test_gdb_complete_unique \
+ "b $w thr" \
+ "b $w thread"
+ test_gdb_complete_unique \
+ "b $w -fun" \
+ "b $w -function"
+ } else {
+ # After -line, we expect a number / offset.
+ foreach line {"10" "+10" "-10"} {
+ set w "$prefix-line $line$suffix"
+ test_gdb_complete_multiple \
+ "b $w " "" "" $completions_list
+ test_gdb_complete_unique \
+ "b $w thr" \
+ "b $w thread"
+ test_gdb_complete_unique \
+ "b $w -fun" \
+ "b $w -function"
+ }
+
+ # With an invalid -line argument, we don't get any
+ # completions.
+ test_gdb_complete_none "b $prefix-line argument$suffix "
+ }
+
}

- # With an invalid -line argument, we don't get any
- # completions.
- test_gdb_complete_none "b -line argument "
}

- # Don't complete a linespec keyword ("thread") or
- # another option name when expecting an option
- # argument.
- test_gdb_complete_none "b $what thr"
- test_gdb_complete_none "b $what -fun"
+ # These tests don't make sense with "-qualified" after
+ # the location.
+ with_test_prefix "complete after $prefix$what" {
+ # Don't complete a linespec keyword ("thread") or
+ # another option name when expecting an option
+ # argument.
+ test_gdb_complete_none "b $prefix$what thr"
+ test_gdb_complete_none "b $prefix$what -fun"
+ }
}
}

--
2.5.5