diff options
author | Joel Brobecker <brobecker@adacore.com> | 2018-01-05 04:29:54 -0500 |
---|---|---|
committer | Joel Brobecker <brobecker@adacore.com> | 2018-01-05 04:29:54 -0500 |
commit | 342f82403949c74517a6353baec73b94d18549ad (patch) | |
tree | cfb5a6f2c1a52386f9ba17ebf6d66e977ea86b26 /gdb/ada-exp.y | |
parent | 7150d33cda60fd543e9d9d68eb58d4e6155fb878 (diff) | |
download | gdb-342f82403949c74517a6353baec73b94d18549ad.zip gdb-342f82403949c74517a6353baec73b94d18549ad.tar.gz gdb-342f82403949c74517a6353baec73b94d18549ad.tar.bz2 |
(Ada) problem printing renaming which references a subprogram parameter
Consider the following code, which creates a local variable B
which is a renaming whose expression references a subprogram
parameter:
procedure Flip (Bits : in out Bits_Type; I : Natural) is
begin
declare
B : Boolean renames Bits (I);
begin
B := not B; -- BREAK
end;
end Flip;
Trying to print the value of B when at the "BREAK" line currently
does not work:
(gdb) p b
Could not find i
What happens is the following: For the renaming, GNAT generates
a variable whose name is encoded as follow:
b___XR_bits___XEXSi
GDB properly detects that variable, determines that, to compute
the variable's value, we start from the symbol "Bits", which
we then have to subscript (XS) using 'i' as the index. The error
occurs while trying to find 'i'.
This is because we forgot to pass the block in the call to
ada_lookup_encoded_symbol, which this patch fixes.
gdb/ChangeLog:
* ada-exp.y (write_object_renaming): When subscripting an array
using a symbol as the index, pass the block in call to
ada_lookup_encoded_symbol when looking that symbol up.
gdb/testsuite/ChangeLog:
* gdb.ada/rename_subscript_param: New testcase.
Tested on x86_64-linux.
Note: This requires the following GCC patch:
| 2017-04-25 Pierre-Marie de Rodat <derodat@adacore.com>
|
| * exp_dbug.adb: In Debug_Renaming_Declaration,
| when dealing with indexed component, accept to produce a renaming
| symbol when the index is an IN parameter or when it is a name
| defined in an outer scope.
Diffstat (limited to 'gdb/ada-exp.y')
-rw-r--r-- | gdb/ada-exp.y | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 0e60108..0acd1e2 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -891,8 +891,8 @@ write_object_renaming (struct parser_state *par_state, end - renaming_expr); renaming_expr = end; - ada_lookup_encoded_symbol (index_name, NULL, VAR_DOMAIN, - &index_sym_info); + ada_lookup_encoded_symbol (index_name, orig_left_context, + VAR_DOMAIN, &index_sym_info); if (index_sym_info.symbol == NULL) error (_("Could not find %s"), index_name); else if (SYMBOL_CLASS (index_sym_info.symbol) == LOC_TYPEDEF) |