The ada_lookup_symbol_list function has recently been changed to accept
a "full_search" parameter. When null, this parameter instructs the
function to perform a partial search (global and static symbols are not
searched). When doing a partial search, the result should not be saved
into the lookup cache, as the result might be incomplete.
This manifested itself when trying to perform a function call on AVR
after having inserted a breakpoint inside that function:
(gdb) b same
Breakpoint 2 at 0x78: file r.adb, line 5.
(gdb) call same(42)
Breakpoint 2, r.same (i=42) at r.adb:5
5 return I;
The program being debugged stopped while in a function called from GDB.
Evaluation of the expression containing the function
(at 0x0x800068) will be abandoned.
^^^^^^^^^^^^^^^
When the function is done executing, GDB will silently stop.
The expected output for the underlined portion is "(r.same)".
What happens is that the breakpoint command triggers 3 lookups of the
name "same":
1. full search in LABEL_DOMAIN -> no match, cached;
2. full search in VAR_DOMAIN -> 1 match, cached;
3. partial search in VAR_DOMAIN -> no match, cached.
The third lookup therefore causes the results of the partial search
to be cached, thus overriding the result of the full search lookup.
During the following command, the reference to "same" triggers a lookup
of that symbol again. And since GDB CAN find the result of that lookup
in the cache, it returns just that, which is: No match. (wrong!)
As a result, we fallback on the symbol table to resolve the lookup.
And instead of pushing an OP_VAR_VALUE subexpression for symbol "same",
the parser ends up pushing an UNOP_MEMVAL subexpression using the value
of the minimal symbol. This is where being on AVR becomes important:
addresses on AVR are modular types, and if GDB thinks an address is
a data address, it converts it.
This is where one notices the fact that the breakpoint was inserted
at 0x78, and yet GDB says that the function we stopped at is at
0x0x800068...
This patch fixes the problem by making sure we only cache the result
of full searches.
gdb/ChangeLog:
* ada-lang.c (ada_lookup_symbol_list): Only cache the result of
full searches.
+2012-02-29 Joel Brobecker <brobecker@adacore.com>
+
+ * ada-lang.c (ada_lookup_symbol_list): Only cache the result of
+ full searches.
+
2012-02-29 Joel Brobecker <brobecker@adacore.com>
* ada-lang.c (constrained_packed_array_type): If there is a
ndefns = remove_extra_symbols (*results, ndefns);
- if (ndefns == 0)
+ if (ndefns == 0 && full_search)
cache_symbol (name0, namespace, NULL, NULL);
- if (ndefns == 1 && cacheIfUnique)
+ if (ndefns == 1 && full_search && cacheIfUnique)
cache_symbol (name0, namespace, (*results)[0].sym, (*results)[0].block);
ndefns = remove_irrelevant_renamings (*results, ndefns, block0);