Skip to content

Commit 7a19098

Browse files
committed
Fix gdb.ada/info_addr_mixed_case.exp (PR gdb/22670)
The comments about mixed case in the testcase are actually a red herring. The problem here is that we'd get to ada_lookup_encoded_symbol with "my_table", which wraps the looked up name in "<>"s to force a verbatim match, and that in turn disables wild matching. Fix this by swapping around the internals of ada_lookup_encoded_symbol and ada_lookup_symbol, thus avoiding the encoding and verbatim-wrapping in the ada_lookup_symbol case, the case that starts with a user-provided lookup name. Ada encoding is still done of course, in the ada_lookup_name_info ctor. This could be also seen as avoiding the double-encoding problem in a different way. gdb/ChangeLog: 2018-01-05 Pedro Alves <palves@redhat.com> PR gdb/22670 * ada-lang.c (ada_lookup_encoded_symbol): Reimplement in terms of ada_lookup_symbol. (ada_lookup_symbol): Reimplement in terms of ada_lookup_symbol_list, bits factored out from ada_lookup_encoded_symbol. gdb/testsuite/ChangeLog: 2018-01-05 Pedro Alves <palves@redhat.com> PR gdb/22670 * gdb.ada/info_addr_mixed_case.exp: Remove kfail. Extend test to exercise lower case too, and to exercise both full matching and wild matching.
1 parent 7a9dac5 commit 7a19098

File tree

4 files changed

+42
-32
lines changed

4 files changed

+42
-32
lines changed

gdb/ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2018-01-05 Pedro Alves <palves@redhat.com>
2+
3+
PR gdb/22670
4+
* ada-lang.c (ada_lookup_encoded_symbol): Reimplement in terms of
5+
ada_lookup_symbol.
6+
(ada_lookup_symbol): Reimplement in terms of
7+
ada_lookup_symbol_list, bits factored out from
8+
ada_lookup_encoded_symbol.
9+
110
2018-01-05 Joel Brobecker <brobecker@adacore.com>
211

312
GDB 8.1 branch created (5219ac6237c272b938c28517bf371429260c71e7):

gdb/ada-lang.c

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5911,10 +5911,6 @@ ada_lookup_encoded_symbol (const char *name, const struct block *block,
59115911
domain_enum domain,
59125912
struct block_symbol *info)
59135913
{
5914-
struct block_symbol *candidates;
5915-
int n_candidates;
5916-
struct cleanup *old_chain;
5917-
59185914
/* Since we already have an encoded name, wrap it in '<>' to force a
59195915
verbatim match. Otherwise, if the name happens to not look like
59205916
an encoded name (because it doesn't include a "__"),
@@ -5924,22 +5920,7 @@ ada_lookup_encoded_symbol (const char *name, const struct block *block,
59245920
std::string verbatim = std::string ("<") + name + '>';
59255921

59265922
gdb_assert (info != NULL);
5927-
memset (info, 0, sizeof (struct block_symbol));
5928-
5929-
n_candidates = ada_lookup_symbol_list (verbatim.c_str (), block,
5930-
domain, &candidates);
5931-
old_chain = make_cleanup (xfree, candidates);
5932-
5933-
if (n_candidates == 0)
5934-
{
5935-
do_cleanups (old_chain);
5936-
return;
5937-
}
5938-
5939-
*info = candidates[0];
5940-
info->symbol = fixup_symbol_section (info->symbol, NULL);
5941-
5942-
do_cleanups (old_chain);
5923+
*info = ada_lookup_symbol (verbatim.c_str (), block, domain, NULL);
59435924
}
59445925

59455926
/* Return a symbol in DOMAIN matching NAME, in BLOCK0 and enclosing
@@ -5952,13 +5933,27 @@ struct block_symbol
59525933
ada_lookup_symbol (const char *name, const struct block *block0,
59535934
domain_enum domain, int *is_a_field_of_this)
59545935
{
5955-
struct block_symbol info;
5956-
59575936
if (is_a_field_of_this != NULL)
59585937
*is_a_field_of_this = 0;
59595938

5960-
ada_lookup_encoded_symbol (ada_encode (ada_fold_name (name)),
5961-
block0, domain, &info);
5939+
struct block_symbol *candidates;
5940+
int n_candidates;
5941+
struct cleanup *old_chain;
5942+
5943+
n_candidates = ada_lookup_symbol_list (name, block0, domain, &candidates);
5944+
old_chain = make_cleanup (xfree, candidates);
5945+
5946+
if (n_candidates == 0)
5947+
{
5948+
do_cleanups (old_chain);
5949+
return {};
5950+
}
5951+
5952+
block_symbol info = candidates[0];
5953+
info.symbol = fixup_symbol_section (info.symbol, NULL);
5954+
5955+
do_cleanups (old_chain);
5956+
59625957
return info;
59635958
}
59645959

gdb/testsuite/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2018-01-05 Pedro Alves <palves@redhat.com>
2+
3+
PR gdb/22670
4+
* gdb.ada/info_addr_mixed_case.exp: Remove kfail. Extend test to
5+
exercise lower case too, and to exercise both full matching and
6+
wild matching.
7+
18
2018-01-04 Joel Brobecker <brobecker@adacore.com>
29

310
PR gdb/22670

gdb/testsuite/gdb.ada/info_addr_mixed_case.exp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ if ![runto "foo.adb:$bp_location" ] then {
3131

3232
# The following test exercises the situation when uppercase letters
3333
# are used in the name of the symbol passed to the "info address"
34-
# command. This should not make a difference, as the language is
35-
# Ada, and Ada is case-insensitive.
34+
# command. This should not make a difference, as the language is Ada,
35+
# and Ada is case-insensitive. Also, exercise both fully-qualified
36+
# name matching and wild matching.
3637

37-
# commit b5ec771e60c1a0863e51eb491c85c674097e9e13 (Introduce
38-
# lookup_name_info and generalize Ada's FULL/WILD name matching)
39-
# caused the following test to fail. KFAIL it while investigating...
40-
setup_kfail gdb/22670 "*-*-*"
41-
gdb_test "info address My_Table" \
42-
"Symbol \"pck\\.my_table\" is static storage at address $hex\\."
38+
foreach sym {"my_table" "My_Table" "pck.my_table" "Pck.My_Table"} {
39+
gdb_test "info address $sym" \
40+
"Symbol \"pck\\.my_table\" is static storage at address $hex\\."
41+
}

0 commit comments

Comments
 (0)