2019-01-01 14:01:51 +08:00
|
|
|
# Copyright 2017-2019 Free Software Foundation, Inc.
|
Comprehensive C++ linespec/completer tests
Exercises all sorts of aspects fixed by previous patches, going back a
few months.
- Exercises label completion, linespecs and explicit locations.
- Exercises both quoting vs non-quoting, source filenames, function
names, labels, with both linespecs and explicit locations.
- Tests corner cases around not-quoting function names, and
whitespace and/and completing inside a parameter or template
argument list, anonymous namespace awareness, etc.
E.g.,
"break foo<[TAB]" -> "break foo<int>()"
"break bar ( int[TAB]" -> "break bar ( int)
"break ( anon" -> "break ( anonymous namespace)::func()"
"b cfunc() [tab]" -> "b cfunc() const"
"b rettype templfunc[tab]" -> "b rettype templfunc<bar>()"
... and others.
- Tests the "b source.c[TAB] -> b source.cc:" feature. I.e., colon
auto-appending.
- Exercises corner cases around C++ "operator<" / "operator<<".
(Much more extensive C++ operator completion/linespec handling in a
separate patch.)
- Exercises both tab completion and "complete" command completion,
using routines that handle it automatically, to ensure no test
forgets either mode.
- Many of the completion tests test completion at at prefix of a
given tricky name, to make sure all corner cases are covered.
E.g., completing before, at and after ":", "(", "<".
- Exercises "keyword" completion. I.e., "b function() [TAB]"
displaying "if task thread" as completion match list. Likewise for
display explicit location options matches at the appropriate
points.
- Ensures that the completer finds the same breakpoint locations that
setting a breakpoint finds.
- Tests that linespec/location completion doesn't find data symbols.
- Tests that expression completion still kicks in after a
linespec/location keyword. I.e., this:
"b function () if global1 + global[TAB]"
knows that after "if", you're completing on an expression, and thus
breaks words after "if" as an expression and matches on "global" as
a data symbol.
- Adds common routines to help with all the above, to be used by
multiple completion and linespec/location test cases.
- More...
Grows the gdb.linespec/ tests like this:
-# of expected passes 573
+# of expected passes 3464
gdb/testsuite/ChangeLog:
2017-11-24 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpcompletion.exp: New file.
* gdb.linespec/cpls-hyphen.cc: New file.
* gdb.linespec/cpls.cc: New file.
* gdb.linespec/cpls2.cc: New file.
* gdb.linespec/explicit.exp: Load completion-support.exp. Adjust
test to use test_gdb_complete_unique. Add label completion,
keyword completion and explicit location completion tests.
* lib/completion-support.exp: New file.
2017-11-25 07:41:12 +08:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# This file is part of the gdb testsuite.
|
|
|
|
|
|
|
|
# Any variable or procedure in the namespace whose name starts with
|
|
|
|
# "_" is private to the module. Do not use these.
|
|
|
|
|
|
|
|
namespace eval completion {
|
|
|
|
variable bell_re "\\\x07"
|
|
|
|
|
|
|
|
# List of all quote chars.
|
|
|
|
variable all_quotes_list {"'" "\""}
|
|
|
|
|
|
|
|
# List of all quote chars, including no-quote at all.
|
|
|
|
variable maybe_quoted_list {"" "'" "\""}
|
|
|
|
|
|
|
|
variable keyword_list {"if" "task" "thread"}
|
|
|
|
|
|
|
|
variable explicit_opts_list \
|
Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching]
This patch teaches GDB about setting breakpoints in all scopes
(namespaces and classes) by default.
Here's a contrived example:
(gdb) b func<tab>
(anonymous namespace)::A::function() Bn::(anonymous namespace)::B::function() function(int, int)
(anonymous namespace)::B::function() Bn::(anonymous namespace)::function() gdb::(anonymous namespace)::A::function()
(anonymous namespace)::B::function() const Bn::(anonymous namespace)::function(int, int) gdb::(anonymous namespace)::function()
(anonymous namespace)::function() Bn::B::func() gdb::(anonymous namespace)::function(int, int)
(anonymous namespace)::function(int, int) Bn::B::function() gdb::A::func()
A::func() Bn::func() gdb::A::function()
A::function() Bn::function() gdb::func()
B::func() Bn::function(int, int) gdb::function()
B::function() Bn::function(long) gdb::function(int, int)
B::function() const func() gdb::function(long)
B::function_const() const function()
(gdb) b function
Breakpoint 1 at 0x4005ce: function. (26 locations)
(gdb) b B::function<tab>
(anonymous namespace)::B::function() B::function() const Bn::B::function()
(anonymous namespace)::B::function() const B::function_const() const
B::function() Bn::(anonymous namespace)::B::function()
(gdb) b B::function
Breakpoint 1 at 0x40072c: B::function. (6 locations)
To get back the original behavior of interpreting the function name as
a fully-qualified name, you can use the new "-qualified" (or "-q")
option/flag (added by this commit). For example:
(gdb) b B::function
(anonymous namespace)::B::function() B::function() const Bn::B::function()
(anonymous namespace)::B::function() const B::function_const() const
B::function() Bn::(anonymous namespace)::B::function()
vs:
(gdb) b -qualified B::function
B::function() B::function() const B::function_const() const
I've chosen "-qualified" / "-q" because "-f" (for "full" or
"fully-qualified") is already taken for "-function".
Note: the "-qualified" option works with both linespecs and explicit
locations. I.e., these are equivalent:
(gdb) b -q func
(gdb) b -q -f func
and so are these:
(gdb) b -q filename.cc:func
(gdb) b -q -s filename.cc -f func
(gdb) b -s filename.cc -q -f func
(gdb) b -s filename.cc -f func -q
To better understand why I consider wild matching the better default,
consider what happens when we get to the point when _all_ of GDB is
wrapped under "namespace gdb {}". I have a patch series that does
that, and when I started debugging that GDB, I immediately became
frustrated. You'd have to write "b gdb::internal_error", "b
gdb::foo", "b gdb::bar", etc. etc., which gets annoying pretty
quickly. OTOH, consider how this makes it very easy to set
breakpoints in classes wrapped in anonymous namespaces. You just
don't think of them, GDB finds the symbols for you automatically.
(At the Cauldron a couple months ago, several people told me that they
run into a similar issue when debugging other C++ projects. One
example was when debugging LLVM, which puts all its code under the
"llvm" namespace.)
Implementation-wise, what the patch does is:
- makes C++ symbol name hashing only consider the last component of
a symbol name. (so that we can look up symbol names by
last-component name only).
- adds a C++ symbol name matcher for symbol_name_match_type::WILD,
which ignores missing leading specifiers / components.
- adjusts a few preexisting testsuite tests to use "-qualified" when
they mean it.
- adds new testsuite tests.
- adds unit tests.
Grows the gdb.linespec/ tests like this:
-# of expected passes 7823
+# of expected passes 8977
gdb/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* NEWS: Mention that breakpoints on C++ functions are now set on
on all namespaces/classes by default, and mention "break
-qualified".
* ax-gdb.c (agent_command_1): Adjust to pass a
symbol_name_match_type to new_linespec_location.
* breakpoint.c (parse_breakpoint_sals): Adjust to
get_linespec_location's return type change.
(strace_marker_create_sals_from_location): Adjust to pass a
symbol_name_match_type to new_linespec_location.
(strace_marker_decode_location): Adjust to get_linespec_location's
return type change.
(strace_command): Adjust to pass a symbol_name_match_type to
new_linespec_location.
(LOCATION_HELP_STRING): Add paragraph about wildmatching, and
mention "-qualified".
* c-lang.c (cplus_language_defn): Install cp_search_name_hash.
* completer.c (explicit_location_match_type::MATCH_QUALIFIED): New
enumerator.
(complete_address_and_linespec_locations): New parameter
'match_type'. Pass it down.
(explicit_options): Add "-qualified".
(collect_explicit_location_matches): Pass the requested match type
to the linespec completers. Handle MATCH_QUALIFIED.
(location_completer): Handle "-qualified" combined with linespecs.
* cp-support.c (cp_search_name_hash): New.
(cp_symbol_name_matches_1): Implement wild matching for C++.
(cp_fq_symbol_name_matches): Reimplement.
(cp_get_symbol_name_matcher): Return different matchers depending
on the lookup name's match type.
(selftests::test_cp_symbol_name_matches): Add wild matching tests.
* cp-support.h (cp_search_name_hash): New declaration.
* dwarf2read.c
(selftests::dw2_expand_symtabs_matching::test_symbols): Add
symbols.
(test_dw2_expand_symtabs_matching_symbol): Add wild matching
tests.
* guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Adjust to
pass a symbol_name_match_type to new_linespec_location.
* linespec.c (linespec_parse_basic): Lookup function symbols using
the parser's symbol name match type.
(convert_explicit_location_to_linespec): New
symbol_name_match_type parameter. Pass it down to
find_linespec_symbols.
(convert_explicit_location_to_sals): Pass the location's name
match type to convert_explicit_location_to_linespec.
(parse_linespec): New match_type parameter. Save it in the
parser.
(linespec_parser_new): Default to symbol_name_match_type::WILD.
(linespec_complete_function): New symbol_name_match_type
parameter. Use it.
(complete_linespec_component): Pass down the parser's recorded
name match type.
(linespec_complete_label): New symbol_name_match_type parameter.
Use it.
(linespec_complete): New symbol_name_match_type parameter. Save
it in the parser and pass it down. Adjust to
get_linespec_location's prototype change.
(find_function_symbols, find_linespec_symbols): New
symbol_name_match_type parameter. Pass it down instead of
assuming symbol_name_match_type::WILD.
* linespec.h (linespec_complete, linespec_complete_function)
(linespec_complete_label): New symbol_name_match_type parameter.
* location.c (event_location::linespec_location): Now a struct
linespec_location.
(EL_LINESPEC): Adjust.
(initialize_explicit_location): Default to
symbol_name_match_type::WILD.
(new_linespec_location): New symbol_name_match_type parameter.
Record it in the location.
(get_linespec_location): Now returns a struct linespec_location.
(new_explicit_location): Also copy func_name_match_type.
(explicit_to_string_internal)
(string_to_explicit_location): Handle "-qualified".
(copy_event_location): Adjust to LINESPEC_LOCATION type change.
Copy symbol_name_match_type fields.
(event_location_deleter::operator()): Adjust to LINESPEC_LOCATION
type change.
(event_location_to_string): Adjust to LINESPEC_LOCATION type
change. Handle "-qualfied".
(string_to_explicit_location): Handle "-qualified".
(string_to_event_location_basic): New symbol_name_match_type
parameter. Pass it down.
(string_to_event_location): Handle "-qualified".
* location.h (struct linespec_location): New.
(explicit_location::func_name_match_type): New field.
(new_linespec_location): Now returns a const linespec_location *.
(string_to_event_location_basic): New symbol_name_match_type
parameter.
(explicit_completion_info::saw_explicit_location_option): New
field.
* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Adjust to pass a
symbol_name_match_type to new_linespec_location.
* python/py-breakpoint.c (bppy_init): Likewise.
* python/python.c (gdbpy_decode_line): Likewise.
gdb/testsuite/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* gdb.base/langs.exp: Use -qualified.
* gdb.cp/meth-typedefs.exp: Use -qualified, and add tests without
it.
* gdb.cp/namespace.exp: Use -qualified.
* gdb.linespec/cpcompletion.exp (overload-2, fqn, fqn-2)
(overload-3, template-overload, template-ret-type, const-overload)
(const-overload-quoted, anon-ns, ambiguous-prefix): New
procedures.
(test_driver): Call them.
* gdb.cp/save-bp-qualified.cc: New.
* gdb.cp/save-bp-qualified.exp: New.
* gdb.linespec/explicit.exp: Test -qualified.
* lib/completion-support.exp (completion::explicit_opts_list): Add
"-qualified".
* lib/gdb.exp (gdb_breakpoint): Handle "qualified".
gdb/doc/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Linespec Locations): Document how "function" is
interpreted in C++ and Ada. Document "-qualified".
(Explicit Locations): Document how "-function" is interpreted in
C++ and Ada. Document "-qualified".
2017-11-30 03:33:23 +08:00
|
|
|
{"-function" "-label" "-line" "-qualified" "-source"}
|
Comprehensive C++ linespec/completer tests
Exercises all sorts of aspects fixed by previous patches, going back a
few months.
- Exercises label completion, linespecs and explicit locations.
- Exercises both quoting vs non-quoting, source filenames, function
names, labels, with both linespecs and explicit locations.
- Tests corner cases around not-quoting function names, and
whitespace and/and completing inside a parameter or template
argument list, anonymous namespace awareness, etc.
E.g.,
"break foo<[TAB]" -> "break foo<int>()"
"break bar ( int[TAB]" -> "break bar ( int)
"break ( anon" -> "break ( anonymous namespace)::func()"
"b cfunc() [tab]" -> "b cfunc() const"
"b rettype templfunc[tab]" -> "b rettype templfunc<bar>()"
... and others.
- Tests the "b source.c[TAB] -> b source.cc:" feature. I.e., colon
auto-appending.
- Exercises corner cases around C++ "operator<" / "operator<<".
(Much more extensive C++ operator completion/linespec handling in a
separate patch.)
- Exercises both tab completion and "complete" command completion,
using routines that handle it automatically, to ensure no test
forgets either mode.
- Many of the completion tests test completion at at prefix of a
given tricky name, to make sure all corner cases are covered.
E.g., completing before, at and after ":", "(", "<".
- Exercises "keyword" completion. I.e., "b function() [TAB]"
displaying "if task thread" as completion match list. Likewise for
display explicit location options matches at the appropriate
points.
- Ensures that the completer finds the same breakpoint locations that
setting a breakpoint finds.
- Tests that linespec/location completion doesn't find data symbols.
- Tests that expression completion still kicks in after a
linespec/location keyword. I.e., this:
"b function () if global1 + global[TAB]"
knows that after "if", you're completing on an expression, and thus
breaks words after "if" as an expression and matches on "global" as
a data symbol.
- Adds common routines to help with all the above, to be used by
multiple completion and linespec/location test cases.
- More...
Grows the gdb.linespec/ tests like this:
-# of expected passes 573
+# of expected passes 3464
gdb/testsuite/ChangeLog:
2017-11-24 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpcompletion.exp: New file.
* gdb.linespec/cpls-hyphen.cc: New file.
* gdb.linespec/cpls.cc: New file.
* gdb.linespec/cpls2.cc: New file.
* gdb.linespec/explicit.exp: Load completion-support.exp. Adjust
test to use test_gdb_complete_unique. Add label completion,
keyword completion and explicit location completion tests.
* lib/completion-support.exp: New file.
2017-11-25 07:41:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Make a regular expression that matches a TAB completion list.
|
|
|
|
|
|
|
|
proc make_tab_completion_list_re { completion_list } {
|
|
|
|
# readline separates the completion columns that fit on the same
|
|
|
|
# line with whitespace. Since we're testing under "set width
|
|
|
|
# unlimited", all completions will be printed on the same line.
|
|
|
|
# The amount of whitespace depends on the length of the widest
|
|
|
|
# completion. We could compute that here and expect the exact
|
|
|
|
# number of ws characters between each completion match, but to
|
|
|
|
# keep it simple, we accept any number of characters.
|
|
|
|
set ws " +"
|
|
|
|
|
|
|
|
set completion_list_re ""
|
|
|
|
foreach c $completion_list {
|
|
|
|
append completion_list_re [string_to_regexp $c]
|
|
|
|
append completion_list_re $ws
|
|
|
|
}
|
|
|
|
append completion_list_re $ws
|
|
|
|
|
|
|
|
return $completion_list_re
|
|
|
|
}
|
|
|
|
|
|
|
|
# Make a regular expression that matches a "complete" command
|
|
|
|
# completion list. CMD_PREFIX is the command prefix added to each
|
|
|
|
# completion match.
|
|
|
|
|
|
|
|
proc make_cmd_completion_list_re { cmd_prefix completion_list start_quote_char end_quote_char } {
|
|
|
|
|
|
|
|
set completion_list_re ""
|
|
|
|
foreach c $completion_list {
|
|
|
|
# The command prefix is included in all completion matches.
|
|
|
|
append completion_list_re [string_to_regexp $cmd_prefix$start_quote_char$c$end_quote_char]
|
|
|
|
append completion_list_re "\r\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
return $completion_list_re
|
|
|
|
}
|
|
|
|
|
|
|
|
# Clear the input line.
|
|
|
|
|
|
|
|
proc clear_input_line { test } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
send_gdb "\003"
|
|
|
|
gdb_test_multiple "" "$test (clearing input line)" {
|
|
|
|
-re "Quit\r\n$gdb_prompt $" {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test that completing LINE with TAB completes to nothing.
|
|
|
|
|
|
|
|
proc test_gdb_complete_tab_none { line } {
|
|
|
|
set line_re [string_to_regexp $line]
|
|
|
|
|
|
|
|
set test "tab complete \"$line\""
|
|
|
|
send_gdb "$line\t"
|
|
|
|
gdb_test_multiple "" "$test" {
|
|
|
|
-re "^$line_re$completion::bell_re$" {
|
|
|
|
pass "$test"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
clear_input_line $test
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test that completing INPUT_LINE with TAB completes to
|
|
|
|
# COMPLETE_LINE_RE. APPEND_CHAR_RE is the character expected to be
|
|
|
|
# appended after EXPECTED_OUTPUT. Normally that's a whitespace, but
|
|
|
|
# in some cases it's some other character, like a colon.
|
|
|
|
|
|
|
|
proc test_gdb_complete_tab_unique { input_line complete_line_re append_char_re } {
|
|
|
|
|
|
|
|
set test "tab complete \"$input_line\""
|
|
|
|
send_gdb "$input_line\t"
|
|
|
|
gdb_test_multiple "" "$test" {
|
|
|
|
-re "^$complete_line_re$append_char_re$" {
|
|
|
|
pass "$test"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
clear_input_line $test
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test that completing INPUT_LINE with TAB completes to "INPUT_LINE +
|
|
|
|
# ADD_COMPLETED_LINE" and that it displays the completion matches in
|
|
|
|
# COMPLETION_LIST.
|
|
|
|
|
|
|
|
proc test_gdb_complete_tab_multiple { input_line add_completed_line \
|
|
|
|
completion_list } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
set input_line_re [string_to_regexp $input_line]
|
|
|
|
set add_completed_line_re [string_to_regexp $add_completed_line]
|
|
|
|
|
|
|
|
set expected_re [make_tab_completion_list_re $completion_list]
|
|
|
|
|
|
|
|
set test "tab complete \"$input_line\""
|
|
|
|
send_gdb "$input_line\t"
|
|
|
|
gdb_test_multiple "" "$test (first tab)" {
|
|
|
|
-re "^${input_line_re}${completion::bell_re}$add_completed_line_re$" {
|
|
|
|
send_gdb "\t"
|
|
|
|
# If we auto-completed to an ambiguous prefix, we need an
|
|
|
|
# extra tab to show the matches list.
|
|
|
|
if {$add_completed_line != ""} {
|
|
|
|
send_gdb "\t"
|
2017-12-14 00:38:50 +08:00
|
|
|
set maybe_bell ${completion::bell_re}
|
|
|
|
} else {
|
|
|
|
set maybe_bell ""
|
Comprehensive C++ linespec/completer tests
Exercises all sorts of aspects fixed by previous patches, going back a
few months.
- Exercises label completion, linespecs and explicit locations.
- Exercises both quoting vs non-quoting, source filenames, function
names, labels, with both linespecs and explicit locations.
- Tests corner cases around not-quoting function names, and
whitespace and/and completing inside a parameter or template
argument list, anonymous namespace awareness, etc.
E.g.,
"break foo<[TAB]" -> "break foo<int>()"
"break bar ( int[TAB]" -> "break bar ( int)
"break ( anon" -> "break ( anonymous namespace)::func()"
"b cfunc() [tab]" -> "b cfunc() const"
"b rettype templfunc[tab]" -> "b rettype templfunc<bar>()"
... and others.
- Tests the "b source.c[TAB] -> b source.cc:" feature. I.e., colon
auto-appending.
- Exercises corner cases around C++ "operator<" / "operator<<".
(Much more extensive C++ operator completion/linespec handling in a
separate patch.)
- Exercises both tab completion and "complete" command completion,
using routines that handle it automatically, to ensure no test
forgets either mode.
- Many of the completion tests test completion at at prefix of a
given tricky name, to make sure all corner cases are covered.
E.g., completing before, at and after ":", "(", "<".
- Exercises "keyword" completion. I.e., "b function() [TAB]"
displaying "if task thread" as completion match list. Likewise for
display explicit location options matches at the appropriate
points.
- Ensures that the completer finds the same breakpoint locations that
setting a breakpoint finds.
- Tests that linespec/location completion doesn't find data symbols.
- Tests that expression completion still kicks in after a
linespec/location keyword. I.e., this:
"b function () if global1 + global[TAB]"
knows that after "if", you're completing on an expression, and thus
breaks words after "if" as an expression and matches on "global" as
a data symbol.
- Adds common routines to help with all the above, to be used by
multiple completion and linespec/location test cases.
- More...
Grows the gdb.linespec/ tests like this:
-# of expected passes 573
+# of expected passes 3464
gdb/testsuite/ChangeLog:
2017-11-24 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpcompletion.exp: New file.
* gdb.linespec/cpls-hyphen.cc: New file.
* gdb.linespec/cpls.cc: New file.
* gdb.linespec/cpls2.cc: New file.
* gdb.linespec/explicit.exp: Load completion-support.exp. Adjust
test to use test_gdb_complete_unique. Add label completion,
keyword completion and explicit location completion tests.
* lib/completion-support.exp: New file.
2017-11-25 07:41:12 +08:00
|
|
|
}
|
|
|
|
gdb_test_multiple "" "$test (second tab)" {
|
2017-12-14 00:38:50 +08:00
|
|
|
-re "^${maybe_bell}\r\n$expected_re\r\n$gdb_prompt $input_line_re$add_completed_line_re$" {
|
Comprehensive C++ linespec/completer tests
Exercises all sorts of aspects fixed by previous patches, going back a
few months.
- Exercises label completion, linespecs and explicit locations.
- Exercises both quoting vs non-quoting, source filenames, function
names, labels, with both linespecs and explicit locations.
- Tests corner cases around not-quoting function names, and
whitespace and/and completing inside a parameter or template
argument list, anonymous namespace awareness, etc.
E.g.,
"break foo<[TAB]" -> "break foo<int>()"
"break bar ( int[TAB]" -> "break bar ( int)
"break ( anon" -> "break ( anonymous namespace)::func()"
"b cfunc() [tab]" -> "b cfunc() const"
"b rettype templfunc[tab]" -> "b rettype templfunc<bar>()"
... and others.
- Tests the "b source.c[TAB] -> b source.cc:" feature. I.e., colon
auto-appending.
- Exercises corner cases around C++ "operator<" / "operator<<".
(Much more extensive C++ operator completion/linespec handling in a
separate patch.)
- Exercises both tab completion and "complete" command completion,
using routines that handle it automatically, to ensure no test
forgets either mode.
- Many of the completion tests test completion at at prefix of a
given tricky name, to make sure all corner cases are covered.
E.g., completing before, at and after ":", "(", "<".
- Exercises "keyword" completion. I.e., "b function() [TAB]"
displaying "if task thread" as completion match list. Likewise for
display explicit location options matches at the appropriate
points.
- Ensures that the completer finds the same breakpoint locations that
setting a breakpoint finds.
- Tests that linespec/location completion doesn't find data symbols.
- Tests that expression completion still kicks in after a
linespec/location keyword. I.e., this:
"b function () if global1 + global[TAB]"
knows that after "if", you're completing on an expression, and thus
breaks words after "if" as an expression and matches on "global" as
a data symbol.
- Adds common routines to help with all the above, to be used by
multiple completion and linespec/location test cases.
- More...
Grows the gdb.linespec/ tests like this:
-# of expected passes 573
+# of expected passes 3464
gdb/testsuite/ChangeLog:
2017-11-24 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpcompletion.exp: New file.
* gdb.linespec/cpls-hyphen.cc: New file.
* gdb.linespec/cpls.cc: New file.
* gdb.linespec/cpls2.cc: New file.
* gdb.linespec/explicit.exp: Load completion-support.exp. Adjust
test to use test_gdb_complete_unique. Add label completion,
keyword completion and explicit location completion tests.
* lib/completion-support.exp: New file.
2017-11-25 07:41:12 +08:00
|
|
|
pass "$test"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
clear_input_line $test
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test that completing LINE with the complete command completes to
|
|
|
|
# nothing.
|
|
|
|
|
|
|
|
proc test_gdb_complete_cmd_none { line } {
|
|
|
|
gdb_test_no_output "complete $line" "cmd complete \"$line\""
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test that completing LINE with the complete command completes to
|
|
|
|
# COMPLETE_LINE_RE.
|
|
|
|
|
|
|
|
proc test_gdb_complete_cmd_unique { input_line complete_line_re } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
set cmd "complete $input_line"
|
|
|
|
set cmd_re [string_to_regexp $cmd]
|
|
|
|
set test "cmd complete \"$input_line\""
|
|
|
|
gdb_test_multiple $cmd $test {
|
|
|
|
-re "^$cmd_re\r\n$complete_line_re\r\n$gdb_prompt $" {
|
|
|
|
pass $test
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test that completing "CMD_PREFIX + COMPLETION_WORD" with the
|
|
|
|
# complete command displays the COMPLETION_LIST completion list. Each
|
|
|
|
# entry in the list should be prefixed by CMD_PREFIX.
|
|
|
|
|
2017-12-14 00:38:50 +08:00
|
|
|
proc test_gdb_complete_cmd_multiple { cmd_prefix completion_word completion_list {start_quote_char ""} {end_quote_char ""} } {
|
Comprehensive C++ linespec/completer tests
Exercises all sorts of aspects fixed by previous patches, going back a
few months.
- Exercises label completion, linespecs and explicit locations.
- Exercises both quoting vs non-quoting, source filenames, function
names, labels, with both linespecs and explicit locations.
- Tests corner cases around not-quoting function names, and
whitespace and/and completing inside a parameter or template
argument list, anonymous namespace awareness, etc.
E.g.,
"break foo<[TAB]" -> "break foo<int>()"
"break bar ( int[TAB]" -> "break bar ( int)
"break ( anon" -> "break ( anonymous namespace)::func()"
"b cfunc() [tab]" -> "b cfunc() const"
"b rettype templfunc[tab]" -> "b rettype templfunc<bar>()"
... and others.
- Tests the "b source.c[TAB] -> b source.cc:" feature. I.e., colon
auto-appending.
- Exercises corner cases around C++ "operator<" / "operator<<".
(Much more extensive C++ operator completion/linespec handling in a
separate patch.)
- Exercises both tab completion and "complete" command completion,
using routines that handle it automatically, to ensure no test
forgets either mode.
- Many of the completion tests test completion at at prefix of a
given tricky name, to make sure all corner cases are covered.
E.g., completing before, at and after ":", "(", "<".
- Exercises "keyword" completion. I.e., "b function() [TAB]"
displaying "if task thread" as completion match list. Likewise for
display explicit location options matches at the appropriate
points.
- Ensures that the completer finds the same breakpoint locations that
setting a breakpoint finds.
- Tests that linespec/location completion doesn't find data symbols.
- Tests that expression completion still kicks in after a
linespec/location keyword. I.e., this:
"b function () if global1 + global[TAB]"
knows that after "if", you're completing on an expression, and thus
breaks words after "if" as an expression and matches on "global" as
a data symbol.
- Adds common routines to help with all the above, to be used by
multiple completion and linespec/location test cases.
- More...
Grows the gdb.linespec/ tests like this:
-# of expected passes 573
+# of expected passes 3464
gdb/testsuite/ChangeLog:
2017-11-24 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpcompletion.exp: New file.
* gdb.linespec/cpls-hyphen.cc: New file.
* gdb.linespec/cpls.cc: New file.
* gdb.linespec/cpls2.cc: New file.
* gdb.linespec/explicit.exp: Load completion-support.exp. Adjust
test to use test_gdb_complete_unique. Add label completion,
keyword completion and explicit location completion tests.
* lib/completion-support.exp: New file.
2017-11-25 07:41:12 +08:00
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
set expected_re [make_cmd_completion_list_re $cmd_prefix $completion_list $start_quote_char $end_quote_char]
|
|
|
|
set cmd_re [string_to_regexp "complete $cmd_prefix$completion_word"]
|
|
|
|
set test "cmd complete \"$cmd_prefix$completion_word\""
|
|
|
|
gdb_test_multiple "complete $cmd_prefix$completion_word" $test {
|
|
|
|
-re "^$cmd_re\r\n$expected_re$gdb_prompt $" {
|
|
|
|
pass $test
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test that completing LINE completes to nothing.
|
|
|
|
|
|
|
|
proc test_gdb_complete_none { input_line } {
|
|
|
|
test_gdb_complete_tab_none $input_line
|
|
|
|
test_gdb_complete_cmd_none $input_line
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test that completing INPUT_LINE completes to COMPLETE_LINE_RE.
|
|
|
|
#
|
|
|
|
# APPEND_CHAR is the character expected to be appended after
|
|
|
|
# EXPECTED_OUTPUT when TAB completing. Normally that's a whitespace,
|
|
|
|
# but in some cases it's some other character, like a colon.
|
|
|
|
#
|
|
|
|
# If MAX_COMPLETIONS is true, then we expect the completion to hit the
|
|
|
|
# max-completions limit. Since we're expecting a unique completion
|
|
|
|
# match, this will only be visible in the "complete" command output.
|
|
|
|
# Tab completion will just auto-complete the only match and won't
|
|
|
|
# display a match list.
|
|
|
|
#
|
|
|
|
# Note: usually it's more convenient to pass a literal string instead
|
|
|
|
# of a regular expression (as COMPLETE_LINE_RE). See
|
|
|
|
# test_gdb_complete_unique below.
|
|
|
|
|
|
|
|
proc test_gdb_complete_unique_re { input_line complete_line_re {append_char " "} {max_completions 0}} {
|
|
|
|
set append_char_re [string_to_regexp $append_char]
|
|
|
|
test_gdb_complete_tab_unique $input_line $complete_line_re $append_char_re
|
|
|
|
|
|
|
|
# Trim INPUT_LINE and COMPLETE LINE, for the case we're completing
|
|
|
|
# a command with leading whitespace. Leading command whitespace
|
|
|
|
# is discarded by GDB.
|
|
|
|
set input_line [string trimleft $input_line]
|
|
|
|
set expected_output_re [string trimleft $complete_line_re]
|
|
|
|
if {$append_char_re != " "} {
|
|
|
|
append expected_output_re $append_char_re
|
|
|
|
}
|
|
|
|
if {$max_completions} {
|
|
|
|
set max_completion_reached_msg \
|
|
|
|
"*** List may be truncated, max-completions reached. ***"
|
|
|
|
set input_line_re \
|
|
|
|
[string_to_regexp $input_line]
|
|
|
|
set max_completion_reached_msg_re \
|
|
|
|
[string_to_regexp $max_completion_reached_msg]
|
|
|
|
|
|
|
|
append expected_output_re \
|
|
|
|
"\r\n$input_line_re $max_completion_reached_msg_re"
|
|
|
|
}
|
|
|
|
|
|
|
|
test_gdb_complete_cmd_unique $input_line $expected_output_re
|
|
|
|
}
|
|
|
|
|
|
|
|
# Like TEST_GDB_COMPLETE_UNIQUE_RE, but COMPLETE_LINE is a string, not
|
|
|
|
# a regular expression.
|
|
|
|
|
|
|
|
proc test_gdb_complete_unique { input_line complete_line {append_char " "} {max_completions 0}} {
|
|
|
|
set complete_line_re [string_to_regexp $complete_line]
|
|
|
|
test_gdb_complete_unique_re $input_line $complete_line_re $append_char $max_completions
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test that completing "CMD_PREFIX + COMPLETION_WORD" adds
|
|
|
|
# ADD_COMPLETED_LINE to the input line, and that it displays
|
|
|
|
# COMPLETION_LIST as completion match list. COMPLETION_WORD is the
|
|
|
|
# completion word.
|
|
|
|
|
|
|
|
proc test_gdb_complete_multiple { cmd_prefix completion_word add_completed_line completion_list {start_quote_char ""} {end_quote_char ""}} {
|
|
|
|
test_gdb_complete_tab_multiple "$cmd_prefix$completion_word" $add_completed_line $completion_list
|
|
|
|
test_gdb_complete_cmd_multiple $cmd_prefix $completion_word $completion_list $start_quote_char $end_quote_char
|
|
|
|
}
|
|
|
|
|
Add comprehensive C++ operator linespec/location/completion tests
This exercises the special handling C++ operators require in several
places in the linespec parser, both the linespec and explicit location
completers, symbol lookup, etc. Particularly, makes sure all that
works without quoting.
Note that despite the apparent smallish size, this adds thousands of
tests to the testsuite, due to combination explosion (linespecs,
explicit locations, tab completion, complete command, completion at
different points in each function, etc.)
Grows the gdb.linespec/ tests like this:
-# of expected passes 3464
+# of expected passes 7823
gdb/testsuite/ChangeLog:
2017-11-25 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpls-ops.cc: New file.
* gdb.linespec/cpls-ops.exp: New file.
* lib/completion-support.exp (test_complete_prefix_range_re): New,
factored out from ...
(test_complete_prefix_range): ... this.
2017-11-25 08:09:25 +08:00
|
|
|
# Test that all the substring prefixes of INPUT from [0..START) to
|
|
|
|
# [0..END) complete to COMPLETION_RE (a regular expression). If END
|
|
|
|
# is ommitted, default to the length of INPUT.
|
Comprehensive C++ linespec/completer tests
Exercises all sorts of aspects fixed by previous patches, going back a
few months.
- Exercises label completion, linespecs and explicit locations.
- Exercises both quoting vs non-quoting, source filenames, function
names, labels, with both linespecs and explicit locations.
- Tests corner cases around not-quoting function names, and
whitespace and/and completing inside a parameter or template
argument list, anonymous namespace awareness, etc.
E.g.,
"break foo<[TAB]" -> "break foo<int>()"
"break bar ( int[TAB]" -> "break bar ( int)
"break ( anon" -> "break ( anonymous namespace)::func()"
"b cfunc() [tab]" -> "b cfunc() const"
"b rettype templfunc[tab]" -> "b rettype templfunc<bar>()"
... and others.
- Tests the "b source.c[TAB] -> b source.cc:" feature. I.e., colon
auto-appending.
- Exercises corner cases around C++ "operator<" / "operator<<".
(Much more extensive C++ operator completion/linespec handling in a
separate patch.)
- Exercises both tab completion and "complete" command completion,
using routines that handle it automatically, to ensure no test
forgets either mode.
- Many of the completion tests test completion at at prefix of a
given tricky name, to make sure all corner cases are covered.
E.g., completing before, at and after ":", "(", "<".
- Exercises "keyword" completion. I.e., "b function() [TAB]"
displaying "if task thread" as completion match list. Likewise for
display explicit location options matches at the appropriate
points.
- Ensures that the completer finds the same breakpoint locations that
setting a breakpoint finds.
- Tests that linespec/location completion doesn't find data symbols.
- Tests that expression completion still kicks in after a
linespec/location keyword. I.e., this:
"b function () if global1 + global[TAB]"
knows that after "if", you're completing on an expression, and thus
breaks words after "if" as an expression and matches on "global" as
a data symbol.
- Adds common routines to help with all the above, to be used by
multiple completion and linespec/location test cases.
- More...
Grows the gdb.linespec/ tests like this:
-# of expected passes 573
+# of expected passes 3464
gdb/testsuite/ChangeLog:
2017-11-24 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpcompletion.exp: New file.
* gdb.linespec/cpls-hyphen.cc: New file.
* gdb.linespec/cpls.cc: New file.
* gdb.linespec/cpls2.cc: New file.
* gdb.linespec/explicit.exp: Load completion-support.exp. Adjust
test to use test_gdb_complete_unique. Add label completion,
keyword completion and explicit location completion tests.
* lib/completion-support.exp: New file.
2017-11-25 07:41:12 +08:00
|
|
|
|
Add comprehensive C++ operator linespec/location/completion tests
This exercises the special handling C++ operators require in several
places in the linespec parser, both the linespec and explicit location
completers, symbol lookup, etc. Particularly, makes sure all that
works without quoting.
Note that despite the apparent smallish size, this adds thousands of
tests to the testsuite, due to combination explosion (linespecs,
explicit locations, tab completion, complete command, completion at
different points in each function, etc.)
Grows the gdb.linespec/ tests like this:
-# of expected passes 3464
+# of expected passes 7823
gdb/testsuite/ChangeLog:
2017-11-25 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpls-ops.cc: New file.
* gdb.linespec/cpls-ops.exp: New file.
* lib/completion-support.exp (test_complete_prefix_range_re): New,
factored out from ...
(test_complete_prefix_range): ... this.
2017-11-25 08:09:25 +08:00
|
|
|
proc test_complete_prefix_range_re {input completion_re start {end -1}} {
|
Comprehensive C++ linespec/completer tests
Exercises all sorts of aspects fixed by previous patches, going back a
few months.
- Exercises label completion, linespecs and explicit locations.
- Exercises both quoting vs non-quoting, source filenames, function
names, labels, with both linespecs and explicit locations.
- Tests corner cases around not-quoting function names, and
whitespace and/and completing inside a parameter or template
argument list, anonymous namespace awareness, etc.
E.g.,
"break foo<[TAB]" -> "break foo<int>()"
"break bar ( int[TAB]" -> "break bar ( int)
"break ( anon" -> "break ( anonymous namespace)::func()"
"b cfunc() [tab]" -> "b cfunc() const"
"b rettype templfunc[tab]" -> "b rettype templfunc<bar>()"
... and others.
- Tests the "b source.c[TAB] -> b source.cc:" feature. I.e., colon
auto-appending.
- Exercises corner cases around C++ "operator<" / "operator<<".
(Much more extensive C++ operator completion/linespec handling in a
separate patch.)
- Exercises both tab completion and "complete" command completion,
using routines that handle it automatically, to ensure no test
forgets either mode.
- Many of the completion tests test completion at at prefix of a
given tricky name, to make sure all corner cases are covered.
E.g., completing before, at and after ":", "(", "<".
- Exercises "keyword" completion. I.e., "b function() [TAB]"
displaying "if task thread" as completion match list. Likewise for
display explicit location options matches at the appropriate
points.
- Ensures that the completer finds the same breakpoint locations that
setting a breakpoint finds.
- Tests that linespec/location completion doesn't find data symbols.
- Tests that expression completion still kicks in after a
linespec/location keyword. I.e., this:
"b function () if global1 + global[TAB]"
knows that after "if", you're completing on an expression, and thus
breaks words after "if" as an expression and matches on "global" as
a data symbol.
- Adds common routines to help with all the above, to be used by
multiple completion and linespec/location test cases.
- More...
Grows the gdb.linespec/ tests like this:
-# of expected passes 573
+# of expected passes 3464
gdb/testsuite/ChangeLog:
2017-11-24 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpcompletion.exp: New file.
* gdb.linespec/cpls-hyphen.cc: New file.
* gdb.linespec/cpls.cc: New file.
* gdb.linespec/cpls2.cc: New file.
* gdb.linespec/explicit.exp: Load completion-support.exp. Adjust
test to use test_gdb_complete_unique. Add label completion,
keyword completion and explicit location completion tests.
* lib/completion-support.exp: New file.
2017-11-25 07:41:12 +08:00
|
|
|
if {$end == -1} {
|
Add comprehensive C++ operator linespec/location/completion tests
This exercises the special handling C++ operators require in several
places in the linespec parser, both the linespec and explicit location
completers, symbol lookup, etc. Particularly, makes sure all that
works without quoting.
Note that despite the apparent smallish size, this adds thousands of
tests to the testsuite, due to combination explosion (linespecs,
explicit locations, tab completion, complete command, completion at
different points in each function, etc.)
Grows the gdb.linespec/ tests like this:
-# of expected passes 3464
+# of expected passes 7823
gdb/testsuite/ChangeLog:
2017-11-25 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpls-ops.cc: New file.
* gdb.linespec/cpls-ops.exp: New file.
* lib/completion-support.exp (test_complete_prefix_range_re): New,
factored out from ...
(test_complete_prefix_range): ... this.
2017-11-25 08:09:25 +08:00
|
|
|
set end [string length $input]
|
Comprehensive C++ linespec/completer tests
Exercises all sorts of aspects fixed by previous patches, going back a
few months.
- Exercises label completion, linespecs and explicit locations.
- Exercises both quoting vs non-quoting, source filenames, function
names, labels, with both linespecs and explicit locations.
- Tests corner cases around not-quoting function names, and
whitespace and/and completing inside a parameter or template
argument list, anonymous namespace awareness, etc.
E.g.,
"break foo<[TAB]" -> "break foo<int>()"
"break bar ( int[TAB]" -> "break bar ( int)
"break ( anon" -> "break ( anonymous namespace)::func()"
"b cfunc() [tab]" -> "b cfunc() const"
"b rettype templfunc[tab]" -> "b rettype templfunc<bar>()"
... and others.
- Tests the "b source.c[TAB] -> b source.cc:" feature. I.e., colon
auto-appending.
- Exercises corner cases around C++ "operator<" / "operator<<".
(Much more extensive C++ operator completion/linespec handling in a
separate patch.)
- Exercises both tab completion and "complete" command completion,
using routines that handle it automatically, to ensure no test
forgets either mode.
- Many of the completion tests test completion at at prefix of a
given tricky name, to make sure all corner cases are covered.
E.g., completing before, at and after ":", "(", "<".
- Exercises "keyword" completion. I.e., "b function() [TAB]"
displaying "if task thread" as completion match list. Likewise for
display explicit location options matches at the appropriate
points.
- Ensures that the completer finds the same breakpoint locations that
setting a breakpoint finds.
- Tests that linespec/location completion doesn't find data symbols.
- Tests that expression completion still kicks in after a
linespec/location keyword. I.e., this:
"b function () if global1 + global[TAB]"
knows that after "if", you're completing on an expression, and thus
breaks words after "if" as an expression and matches on "global" as
a data symbol.
- Adds common routines to help with all the above, to be used by
multiple completion and linespec/location test cases.
- More...
Grows the gdb.linespec/ tests like this:
-# of expected passes 573
+# of expected passes 3464
gdb/testsuite/ChangeLog:
2017-11-24 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpcompletion.exp: New file.
* gdb.linespec/cpls-hyphen.cc: New file.
* gdb.linespec/cpls.cc: New file.
* gdb.linespec/cpls2.cc: New file.
* gdb.linespec/explicit.exp: Load completion-support.exp. Adjust
test to use test_gdb_complete_unique. Add label completion,
keyword completion and explicit location completion tests.
* lib/completion-support.exp: New file.
2017-11-25 07:41:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for {set i $start} {$i < $end} {incr i} {
|
Add comprehensive C++ operator linespec/location/completion tests
This exercises the special handling C++ operators require in several
places in the linespec parser, both the linespec and explicit location
completers, symbol lookup, etc. Particularly, makes sure all that
works without quoting.
Note that despite the apparent smallish size, this adds thousands of
tests to the testsuite, due to combination explosion (linespecs,
explicit locations, tab completion, complete command, completion at
different points in each function, etc.)
Grows the gdb.linespec/ tests like this:
-# of expected passes 3464
+# of expected passes 7823
gdb/testsuite/ChangeLog:
2017-11-25 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpls-ops.cc: New file.
* gdb.linespec/cpls-ops.exp: New file.
* lib/completion-support.exp (test_complete_prefix_range_re): New,
factored out from ...
(test_complete_prefix_range): ... this.
2017-11-25 08:09:25 +08:00
|
|
|
set line [string range $input 0 $i]
|
|
|
|
test_gdb_complete_unique_re "$line" $completion_re
|
Comprehensive C++ linespec/completer tests
Exercises all sorts of aspects fixed by previous patches, going back a
few months.
- Exercises label completion, linespecs and explicit locations.
- Exercises both quoting vs non-quoting, source filenames, function
names, labels, with both linespecs and explicit locations.
- Tests corner cases around not-quoting function names, and
whitespace and/and completing inside a parameter or template
argument list, anonymous namespace awareness, etc.
E.g.,
"break foo<[TAB]" -> "break foo<int>()"
"break bar ( int[TAB]" -> "break bar ( int)
"break ( anon" -> "break ( anonymous namespace)::func()"
"b cfunc() [tab]" -> "b cfunc() const"
"b rettype templfunc[tab]" -> "b rettype templfunc<bar>()"
... and others.
- Tests the "b source.c[TAB] -> b source.cc:" feature. I.e., colon
auto-appending.
- Exercises corner cases around C++ "operator<" / "operator<<".
(Much more extensive C++ operator completion/linespec handling in a
separate patch.)
- Exercises both tab completion and "complete" command completion,
using routines that handle it automatically, to ensure no test
forgets either mode.
- Many of the completion tests test completion at at prefix of a
given tricky name, to make sure all corner cases are covered.
E.g., completing before, at and after ":", "(", "<".
- Exercises "keyword" completion. I.e., "b function() [TAB]"
displaying "if task thread" as completion match list. Likewise for
display explicit location options matches at the appropriate
points.
- Ensures that the completer finds the same breakpoint locations that
setting a breakpoint finds.
- Tests that linespec/location completion doesn't find data symbols.
- Tests that expression completion still kicks in after a
linespec/location keyword. I.e., this:
"b function () if global1 + global[TAB]"
knows that after "if", you're completing on an expression, and thus
breaks words after "if" as an expression and matches on "global" as
a data symbol.
- Adds common routines to help with all the above, to be used by
multiple completion and linespec/location test cases.
- More...
Grows the gdb.linespec/ tests like this:
-# of expected passes 573
+# of expected passes 3464
gdb/testsuite/ChangeLog:
2017-11-24 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpcompletion.exp: New file.
* gdb.linespec/cpls-hyphen.cc: New file.
* gdb.linespec/cpls.cc: New file.
* gdb.linespec/cpls2.cc: New file.
* gdb.linespec/explicit.exp: Load completion-support.exp. Adjust
test to use test_gdb_complete_unique. Add label completion,
keyword completion and explicit location completion tests.
* lib/completion-support.exp: New file.
2017-11-25 07:41:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add comprehensive C++ operator linespec/location/completion tests
This exercises the special handling C++ operators require in several
places in the linespec parser, both the linespec and explicit location
completers, symbol lookup, etc. Particularly, makes sure all that
works without quoting.
Note that despite the apparent smallish size, this adds thousands of
tests to the testsuite, due to combination explosion (linespecs,
explicit locations, tab completion, complete command, completion at
different points in each function, etc.)
Grows the gdb.linespec/ tests like this:
-# of expected passes 3464
+# of expected passes 7823
gdb/testsuite/ChangeLog:
2017-11-25 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpls-ops.cc: New file.
* gdb.linespec/cpls-ops.exp: New file.
* lib/completion-support.exp (test_complete_prefix_range_re): New,
factored out from ...
(test_complete_prefix_range): ... this.
2017-11-25 08:09:25 +08:00
|
|
|
# Test that all the substring prefixes of COMPLETION from [0..START)
|
|
|
|
# to [0..END) complete to COMPLETION. If END is ommitted, default to
|
|
|
|
# the length of COMPLETION.
|
|
|
|
|
|
|
|
proc test_complete_prefix_range {completion start {end -1}} {
|
|
|
|
set completion_re [string_to_regexp $completion]
|
|
|
|
test_complete_prefix_range_re $completion $completion_re $start $end
|
|
|
|
}
|
|
|
|
|
Comprehensive C++ linespec/completer tests
Exercises all sorts of aspects fixed by previous patches, going back a
few months.
- Exercises label completion, linespecs and explicit locations.
- Exercises both quoting vs non-quoting, source filenames, function
names, labels, with both linespecs and explicit locations.
- Tests corner cases around not-quoting function names, and
whitespace and/and completing inside a parameter or template
argument list, anonymous namespace awareness, etc.
E.g.,
"break foo<[TAB]" -> "break foo<int>()"
"break bar ( int[TAB]" -> "break bar ( int)
"break ( anon" -> "break ( anonymous namespace)::func()"
"b cfunc() [tab]" -> "b cfunc() const"
"b rettype templfunc[tab]" -> "b rettype templfunc<bar>()"
... and others.
- Tests the "b source.c[TAB] -> b source.cc:" feature. I.e., colon
auto-appending.
- Exercises corner cases around C++ "operator<" / "operator<<".
(Much more extensive C++ operator completion/linespec handling in a
separate patch.)
- Exercises both tab completion and "complete" command completion,
using routines that handle it automatically, to ensure no test
forgets either mode.
- Many of the completion tests test completion at at prefix of a
given tricky name, to make sure all corner cases are covered.
E.g., completing before, at and after ":", "(", "<".
- Exercises "keyword" completion. I.e., "b function() [TAB]"
displaying "if task thread" as completion match list. Likewise for
display explicit location options matches at the appropriate
points.
- Ensures that the completer finds the same breakpoint locations that
setting a breakpoint finds.
- Tests that linespec/location completion doesn't find data symbols.
- Tests that expression completion still kicks in after a
linespec/location keyword. I.e., this:
"b function () if global1 + global[TAB]"
knows that after "if", you're completing on an expression, and thus
breaks words after "if" as an expression and matches on "global" as
a data symbol.
- Adds common routines to help with all the above, to be used by
multiple completion and linespec/location test cases.
- More...
Grows the gdb.linespec/ tests like this:
-# of expected passes 573
+# of expected passes 3464
gdb/testsuite/ChangeLog:
2017-11-24 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpcompletion.exp: New file.
* gdb.linespec/cpls-hyphen.cc: New file.
* gdb.linespec/cpls.cc: New file.
* gdb.linespec/cpls2.cc: New file.
* gdb.linespec/explicit.exp: Load completion-support.exp. Adjust
test to use test_gdb_complete_unique. Add label completion,
keyword completion and explicit location completion tests.
* lib/completion-support.exp: New file.
2017-11-25 07:41:12 +08:00
|
|
|
# Find NEEDLE in HAYSTACK and return the index _after_ NEEDLE. E.g.,
|
|
|
|
# searching for "(" in "foo(int)" returns 4, which would be useful if
|
|
|
|
# you want to find the "(" to try completing "foo(".
|
|
|
|
|
|
|
|
proc index_after {needle haystack} {
|
|
|
|
set start [string first $needle $haystack]
|
|
|
|
if {$start == -1} {
|
|
|
|
error "could not find \"$needle\" in \"$haystack\""
|
|
|
|
}
|
|
|
|
return [expr $start + [string length $needle]]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create a breakpoint using BREAK_COMMAND, and return the number
|
|
|
|
# of locations found.
|
|
|
|
|
|
|
|
proc completion::_create_bp {break_command} {
|
|
|
|
global gdb_prompt
|
|
|
|
global decimal hex
|
|
|
|
|
|
|
|
set found_locations -1
|
|
|
|
|
|
|
|
set test "set breakpoint"
|
|
|
|
gdb_test_multiple "$break_command" $test {
|
|
|
|
-re "\\\(\($decimal\) locations\\\)\r\n$gdb_prompt $" {
|
|
|
|
set found_locations "$expect_out(1,string)"
|
|
|
|
}
|
|
|
|
-re "Breakpoint $decimal at $hex: file .*, line .*$gdb_prompt $" {
|
|
|
|
set found_locations 1
|
|
|
|
}
|
|
|
|
-re "Make breakpoint pending on future shared library load.*y or .n.. $" {
|
|
|
|
send_gdb "n\n"
|
|
|
|
gdb_test_multiple "" "$test (prompt)" {
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set found_locations 0
|
|
|
|
}
|
|
|
|
-re "invalid explicit location argument, \[^\r\n\]*\r\n$gdb_prompt $" {
|
|
|
|
set found_locations 0
|
|
|
|
}
|
|
|
|
-re "Function \[^\r\n\]* not defined in \[^\r\n\]*\r\n$gdb_prompt $" {
|
|
|
|
set found_locations 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $found_locations
|
|
|
|
}
|
|
|
|
|
|
|
|
# Return true if lists A and B have the same elements. Order of
|
|
|
|
# elements does not matter.
|
|
|
|
|
|
|
|
proc completion::_leq {a b} {
|
|
|
|
return [expr {[lsort $a] eq [lsort $b]}]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check that trying to create a breakpoint using BREAK_COMMAND fails.
|
|
|
|
|
|
|
|
proc check_setting_bp_fails {break_command} {
|
|
|
|
with_test_prefix "\"$break_command\" creates no bp locations" {
|
|
|
|
set found_locations [completion::_create_bp $break_command]
|
|
|
|
gdb_assert {$found_locations == 0} "matches"
|
|
|
|
if {$found_locations != 0} {
|
|
|
|
delete_breakpoints
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check that creating the breakpoint using BREAK_COMMAND finds the
|
|
|
|
# same breakpoint locations as completing BREAK_COMMAND.
|
|
|
|
# COMPLETION_LIST is the expected completion match list.
|
|
|
|
|
|
|
|
proc check_bp_locations_match_list {break_command completion_list} {
|
|
|
|
global gdb_prompt
|
|
|
|
global hex
|
|
|
|
|
|
|
|
with_test_prefix "compare \"$break_command\" completion list with bp location list" {
|
|
|
|
set num_locations [completion::_create_bp $break_command]
|
|
|
|
|
|
|
|
set found_list ""
|
|
|
|
|
|
|
|
set any "\[^\r\n\]*"
|
|
|
|
|
|
|
|
gdb_test_multiple "info breakpoint \$bpnum" "info breakpoint" {
|
|
|
|
-re "in \(\[^\r\n\]*\) at " {
|
|
|
|
# A function location.
|
|
|
|
set found_location "$expect_out(1,string)"
|
|
|
|
lappend found_list $found_location
|
|
|
|
exp_continue
|
|
|
|
}
|
|
|
|
-re "breakpoint${any}keep${any}y${any}$hex\[ \t]*\(${any}\)\r\n" {
|
|
|
|
# A label location.
|
|
|
|
set found_location "$expect_out(1,string)"
|
|
|
|
lappend found_list $found_location
|
|
|
|
exp_continue
|
|
|
|
}
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gdb_assert {[completion::_leq $found_list $completion_list]} "matches"
|
|
|
|
|
|
|
|
delete_breakpoints
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Build linespec and explicit locations out of all the combinations of
|
|
|
|
# SOURCES, FUNCTIONS and LABELS, with all combinations of possible
|
|
|
|
# quoting and whitespace around separators, and run BODY_LINESPEC and
|
|
|
|
# BODY_EXPLICIT in the context of the caller for each combination. A
|
|
|
|
# variable named "location" is set in the callers context with the
|
|
|
|
# currently iterated location.
|
|
|
|
|
|
|
|
proc foreach_location_functions { sources functions body_linespec body_explicit } {
|
|
|
|
upvar source source
|
|
|
|
upvar function function
|
|
|
|
upvar source_sep source_sep
|
|
|
|
upvar location location
|
|
|
|
|
|
|
|
foreach source $sources {
|
|
|
|
# Test with and without source quoting.
|
|
|
|
foreach sqc $completion::maybe_quoted_list {
|
|
|
|
if {$source == "" && $sqc != ""} {
|
|
|
|
# Invalid combination.
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test with and without function quoting.
|
|
|
|
foreach fqc $completion::maybe_quoted_list {
|
|
|
|
# Test known and unknown functions.
|
|
|
|
foreach function $functions {
|
|
|
|
# Linespec version. Test with and without spacing
|
|
|
|
# after the source/colon colon separator.
|
|
|
|
foreach source_sep {"" ":" ": "} {
|
|
|
|
# Skip invalid combinations.
|
|
|
|
if {$source == "" && $source_sep != ""} {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if {$source != "" && $source_sep == ""} {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
set location "${sqc}${source}${sqc}${source_sep}${fqc}$function${fqc}"
|
|
|
|
uplevel 1 $body_linespec
|
|
|
|
}
|
|
|
|
|
|
|
|
# Explicit locations version.
|
|
|
|
if {$source != ""} {
|
|
|
|
set loc_src "-source ${sqc}${source}${sqc} "
|
|
|
|
} else {
|
|
|
|
set loc_src ""
|
|
|
|
}
|
|
|
|
|
|
|
|
set location "${loc_src}-function ${fqc}$function${fqc}"
|
|
|
|
uplevel 1 $body_explicit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Same as foreach_locations_functions, but also iterate over
|
|
|
|
# combinations of labels.
|
|
|
|
proc foreach_location_labels { sources functions labels body_linespec body_explicit } {
|
|
|
|
upvar source source
|
|
|
|
upvar function function
|
|
|
|
upvar label label
|
|
|
|
upvar source_sep source_sep
|
|
|
|
upvar label_sep label_sep
|
|
|
|
upvar location location
|
|
|
|
|
|
|
|
# Test both with a known source file and without a source file
|
|
|
|
# component.
|
|
|
|
foreach_location_functions \
|
|
|
|
$sources \
|
|
|
|
$functions \
|
|
|
|
{
|
|
|
|
# Linespec version. Test various spacing around the label
|
|
|
|
# colon separator.
|
|
|
|
set saved_location ${location}
|
|
|
|
foreach label_sep {":" " :" ": " " : "} {
|
|
|
|
# Test both known and unknown label.
|
|
|
|
foreach label $labels {
|
|
|
|
set location "${saved_location}${label_sep}$label"
|
|
|
|
uplevel 1 $body_linespec
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} \
|
|
|
|
{
|
|
|
|
# Explicit locations version.
|
|
|
|
set saved_location ${location}
|
|
|
|
foreach label $labels {
|
|
|
|
set location "${saved_location} -label $label"
|
|
|
|
uplevel 1 $body_explicit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|