diff options
author | Joel Brobecker <brobecker@gnat.com> | 2012-02-29 19:35:37 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2012-02-29 19:35:37 +0000 |
commit | 2ad01556c70780fe89eb7a7cc6e669de34a4b770 (patch) | |
tree | 89d221ccb334c8d663065a203fc632a50430e8b6 | |
parent | 99b1c762c990c8488c70ad537412f1209b5610bd (diff) | |
download | gdb-2ad01556c70780fe89eb7a7cc6e669de34a4b770.zip gdb-2ad01556c70780fe89eb7a7cc6e669de34a4b770.tar.gz gdb-2ad01556c70780fe89eb7a7cc6e669de34a4b770.tar.bz2 |
[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.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/ada-lang.c | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c00ab1d..6684959 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 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 parallel XA type, use it to determine the array index type. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index b1dbe32..cbdff3f 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); |