Fix regression: expression completer and scope operator (PR gdb/22584)
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.
This commit is contained in:
parent
60a20c1907
commit
a22ecf7026
8 changed files with 104 additions and 13 deletions
|
@ -319,7 +319,8 @@ public:
|
|||
it is not there already. If too many completions were already
|
||||
found, this throws an error. */
|
||||
void add_completion (gdb::unique_xmalloc_ptr<char> name,
|
||||
completion_match_for_lcd *match_for_lcd = NULL);
|
||||
completion_match_for_lcd *match_for_lcd = NULL,
|
||||
const char *text = NULL, const char *word = NULL);
|
||||
|
||||
/* Add all completions matches in LIST. Elements are moved out of
|
||||
LIST. */
|
||||
|
@ -406,7 +407,8 @@ private:
|
|||
it is not there already. If false is returned, too many
|
||||
completions were found. */
|
||||
bool maybe_add_completion (gdb::unique_xmalloc_ptr<char> name,
|
||||
completion_match_for_lcd *match_for_lcd);
|
||||
completion_match_for_lcd *match_for_lcd,
|
||||
const char *text, const char *word);
|
||||
|
||||
/* Given a new match, recompute the lowest common denominator (LCD)
|
||||
to hand over to readline. Normally readline computes this itself
|
||||
|
@ -418,7 +420,8 @@ private:
|
|||
"std::vector<..>::push_back", "std::string::push_back", etc., and
|
||||
in this case we want the lowest common denominator to be
|
||||
"push_back" instead of "std::". */
|
||||
void recompute_lowest_common_denominator (const char *new_match);
|
||||
void recompute_lowest_common_denominator
|
||||
(gdb::unique_xmalloc_ptr<char> &&new_match);
|
||||
|
||||
/* Completion match outputs returned by the symbol name matching
|
||||
routines (see symbol_name_matcher_ftype). These results are only
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue