Fix gdb.ada/complete.exp's "complete break ada" test (PR gdb/22670)
This patch fixes the regression covered by the test added by: commit344420da6b
Date: Thu Jan 4 03:30:37 2018 -0500 Subject: Add "complete break ada" test to gdb.ada/complete.exp The regression had been introduced by: commitb5ec771e60
Date: Wed Nov 8 14:22:32 2017 +0000 Subject: Introduce lookup_name_info and generalize Ada's FULL/WILD name matching The gist of it is that linespec completion in Ada mode is generating additional matches that should not appear in the match list (internally generated symbols, or symbols that should be enclosed between "<...>"). These extraneous entries have uppercase characters, such as: break ada__stringsS break ada__strings__R11s [etc] These matches come from minimal symbols. The problem is that Ada minsyms end up with no language set (language_auto), and thus we end up using the generic symbol name matcher for those instead of Ada's. We already had a special case for in compare_symbol_name to handle this, but it was limited to expressions, while the case at hand is completing a linespec. Fix this by applying the special case to linespec completion as well. I.e., remove the EXPRESSION check from compare_symbol_name. That alone turns out to not be sufficient still -- GDB would still show a couple entries that shouldn't be there: ~~ break ada__exceptions__exception_data__append_info_exception_name__2Xn break ada__exceptions__exception_data__exception_name_length__2Xn ~~ The reason is that these minimal symbols end up with their language set to language_cplus / C++, because those encoded names manage to demangle successfully as C++ symbols (using an old C++ mangling scheme): $ echo ada__exceptions__exception_data__append_info_exception_name__2Xn | c++filt Xn::ada__exceptions__exception_data__append_info_exception_name(void) It's unfortunate that Ada's encoding scheme doesn't start with some unique prefix like "_Z" in the C++ Itanium ABI mangling scheme. For now, paper over that by treating C++ minsyms as Ada minsyms. gdb/ChangeLog: 2018-01-10 Pedro Alves <palves@redhat.com> PR gdb/22670 * ada-lang.c (ada_collect_symbol_completion_matches): If the minsym's language is language_auto or language_cplus, pass down language_ada instead. * symtab.c (compare_symbol_name): Don't frob symbol language here. gdb/testsuite/ChangeLog: 2018-01-10 Pedro Alves <palves@redhat.com> PR gdb/22670 * gdb.ada/complete.exp ("complete break ada"): Replace kfail with a fail.
This commit is contained in:
parent
8825213e97
commit
d4c2a405cb
@ -1,3 +1,11 @@
|
||||
2018-01-10 Pedro Alves <palves@redhat.com>
|
||||
|
||||
PR gdb/22670
|
||||
* ada-lang.c (ada_collect_symbol_completion_matches): If the
|
||||
minsym's language is language_auto or language_cplus, pass down
|
||||
language_ada instead.
|
||||
* symtab.c (compare_symbol_name): Don't frob symbol language here.
|
||||
|
||||
2018-01-10 Pedro Alves <palves@redhat.com>
|
||||
|
||||
PR gdb/22670
|
||||
|
@ -6499,8 +6499,25 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
|
||||
if (completion_skip_symbol (mode, msymbol))
|
||||
continue;
|
||||
|
||||
language symbol_language = MSYMBOL_LANGUAGE (msymbol);
|
||||
|
||||
/* Ada minimal symbols won't have their language set to Ada. If
|
||||
we let completion_list_add_name compare using the
|
||||
default/C-like matcher, then when completing e.g., symbols in a
|
||||
package named "pck", we'd match internal Ada symbols like
|
||||
"pckS", which are invalid in an Ada expression, unless you wrap
|
||||
them in '<' '>' to request a verbatim match.
|
||||
|
||||
Unfortunately, some Ada encoded names successfully demangle as
|
||||
C++ symbols (using an old mangling scheme), such as "name__2Xn"
|
||||
-> "Xn::name(void)" and thus some Ada minimal symbols end up
|
||||
with the wrong language set. Paper over that issue here. */
|
||||
if (symbol_language == language_auto
|
||||
|| symbol_language == language_cplus)
|
||||
symbol_language = language_ada;
|
||||
|
||||
completion_list_add_name (tracker,
|
||||
MSYMBOL_LANGUAGE (msymbol),
|
||||
symbol_language,
|
||||
MSYMBOL_LINKAGE_NAME (msymbol),
|
||||
lookup_name, text, word);
|
||||
}
|
||||
|
16
gdb/symtab.c
16
gdb/symtab.c
@ -4704,21 +4704,7 @@ compare_symbol_name (const char *symbol_name, language symbol_language,
|
||||
const lookup_name_info &lookup_name,
|
||||
completion_match_result &match_res)
|
||||
{
|
||||
const language_defn *lang;
|
||||
|
||||
/* If we're completing for an expression and the symbol doesn't have
|
||||
an explicit language set, fallback to the current language. Ada
|
||||
minimal symbols won't have their language set to Ada, for
|
||||
example, and if we compared using the default/C-like matcher,
|
||||
then when completing e.g., symbols in a package named "pck", we'd
|
||||
match internal Ada symbols like "pckS", which are invalid in an
|
||||
Ada expression, unless you wrap them in '<' '>' to request a
|
||||
verbatim match. */
|
||||
if (symbol_language == language_auto
|
||||
&& lookup_name.match_type () == symbol_name_match_type::EXPRESSION)
|
||||
lang = current_language;
|
||||
else
|
||||
lang = language_def (symbol_language);
|
||||
const language_defn *lang = language_def (symbol_language);
|
||||
|
||||
symbol_name_matcher_ftype *name_match
|
||||
= language_get_symbol_name_matcher (lang, lookup_name);
|
||||
|
@ -1,3 +1,9 @@
|
||||
2018-01-10 Pedro Alves <palves@redhat.com>
|
||||
|
||||
PR gdb/22670
|
||||
* gdb.ada/complete.exp ("complete break ada"): Replace kfail with
|
||||
a fail.
|
||||
|
||||
2018-01-10 Pedro Alves <palves@redhat.com>
|
||||
|
||||
PR gdb/22670
|
||||
|
@ -212,7 +212,7 @@ test_gdb_complete "ambiguous_func" \
|
||||
# However, we want to sanity-check each one of them, knowing that
|
||||
# each result should start with "break ada" and that the proposed
|
||||
# completion should look like a valid symbol name (in particular,
|
||||
# no uppercase letters...).
|
||||
# no uppercase letters...). See gdb/22670.
|
||||
|
||||
gdb_test_no_output "set max-completions unlimited"
|
||||
|
||||
@ -222,6 +222,6 @@ gdb_test_multiple "$test" $test {
|
||||
pass $test
|
||||
}
|
||||
-re "\[A-Z\].*$gdb_prompt $" {
|
||||
kfail gdb/22670 $test
|
||||
fail "$test (gdb/22670)"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user