mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
a22ecf7026
I noticed this regression in the expression completer: "(gdb) p std::[TAB]" => "(gdb) p std::std::" obviously we should have not completed to "std::std::". The problem is that in the earlier big completer rework, I missed taking into account the fact that with expressions, the completion word point is not always at the start of the symbol name (it is with linespecs). The fix is to run the common prefix / LCD string (what readline uses to expand the input line) through make_completion_match_str too. New testcase included, exercising both TAB completion and the complete command. gdb/ChangeLog: 2017-12-13 Pedro Alves <palves@redhat.com> * completer.c (completion_tracker::maybe_add_completion): New 'text' and 'word' parameters. Use make_completion_match_str. (completion_tracker::add_completion): New 'text' and 'word' parameters. Pass down. (completion_tracker::recompute_lowest_common_denominator): Change parameter type to gdb::unique_xmalloc_ptr rval ref. Adjust. * completer.h (completion_tracker::add_completion): New 'text' and 'word' parameters. (completion_tracker::recompute_lowest_common_denominator): Change parameter type to gdb::unique_xmalloc_ptr rval ref. (completion_tracker::recompute_lowest_common_denominator): Change parameter type to gdb::unique_xmalloc_ptr rval ref. * symtab.c (completion_list_add_name): Pass down 'text' and 'word' as well. gdb/testsuite/ChangeLog: 2017-12-13 Pedro Alves <palves@redhat.com> * gdb.cp/cpcompletion.exp: Load completion-support.exp. ("expression with namespace"): New set of tests. * gdb.cp/pr9594.cc (Test_NS::foo, Test_NS::bar) (Nested::Test_NS::qux): New. * lib/completion-support.exp (test_gdb_complete_cmd_multiple): Add defaults to 'start_quote_char' and 'end_quote_char' parameters.
66 lines
910 B
C++
66 lines
910 B
C++
|
|
class Base
|
|
{
|
|
public:
|
|
virtual int get_foo () { return 1; }
|
|
int base_function_only () { return 2; }
|
|
};
|
|
|
|
class Foo : public Base
|
|
{
|
|
|
|
private:
|
|
int foo_value;
|
|
|
|
public:
|
|
Foo () { foo_value = 0;}
|
|
Foo (int i) { foo_value = i;}
|
|
~Foo () { }
|
|
void set_foo (int value);
|
|
int get_foo ();
|
|
|
|
// Something similar to a constructor name.
|
|
void Foofoo ();
|
|
|
|
bool operator== (const Foo &other) { return foo_value == other.foo_value; }
|
|
};
|
|
|
|
void Foo::set_foo (int value)
|
|
{
|
|
foo_value = value;
|
|
}
|
|
|
|
int Foo::get_foo ()
|
|
{
|
|
return foo_value;
|
|
}
|
|
|
|
void Foo::Foofoo ()
|
|
{
|
|
}
|
|
|
|
namespace Test_NS {
|
|
|
|
int foo;
|
|
int bar;
|
|
|
|
namespace Nested {
|
|
|
|
int qux;
|
|
|
|
} /* namespace Nested */
|
|
|
|
} /* namespace Test_NS */
|
|
|
|
int main ()
|
|
{
|
|
// Anonymous struct with method.
|
|
struct {
|
|
int get() { return 5; }
|
|
} a;
|
|
Foo foo1;
|
|
foo1.set_foo (42); // Set breakpoint here.
|
|
a.get(); // Prevent compiler from throwing 'a' away.
|
|
return 0;
|
|
}
|