From: Joel Brobecker Date: Wed, 29 Feb 2012 19:35:37 +0000 (+0000) Subject: [Ada] Do not cache lookup result if not full_search X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2ad01556c70780fe89eb7a7cc6e669de34a4b770;p=binutils-gdb.git [Ada] Do not cache lookup result if not full_search 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c00ab1d66dc..66849598d36 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2012-02-29 Joel Brobecker + + * ada-lang.c (ada_lookup_symbol_list): Only cache the result of + full searches. + 2012-02-29 Joel Brobecker * ada-lang.c (constrained_packed_array_type): If there is a diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index b1dbe32a27b..cbdff3fb55e 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5069,10 +5069,10 @@ done: 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);