diff options
author | Joel Brobecker <brobecker@gnat.com> | 2012-02-29 19:33:02 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2012-02-29 19:33:02 +0000 |
commit | 2d4a02ee9526f370ccd9bdc3f30510f03ee59d19 (patch) | |
tree | 7b8bebd3cfae84ee7be07dbe758a0956444f9df1 /libiberty/getopt.c | |
parent | c48db5caef25bc89b8f444300c7740f01405938b (diff) | |
download | fsf-binutils-gdb-2d4a02ee9526f370ccd9bdc3f30510f03ee59d19.zip fsf-binutils-gdb-2d4a02ee9526f370ccd9bdc3f30510f03ee59d19.tar.gz fsf-binutils-gdb-2d4a02ee9526f370ccd9bdc3f30510f03ee59d19.tar.bz2 |
[Ada] Handle reference to array descriptors
This patch is to help handle aliased array variables, such as:
type Bounded is array (Integer range <>) of Integer;
function New_Bounded (Low, High : Integer) return Bounded;
BT : aliased Bounded := New_Bounded (Low => 1, High => 3);
In that case, the compiler describes variable "BT" as a reference
to a thin pointer, and GDB is unable to print its value:
(gdb) p bt
$1 =
The problems starts when ada_value_print deconstructs the struct
value into contents and address in order to call val_print. It
turns out in this case that "bt" is not an lval. In the debug
information, this variable's location is described as:
.uleb128 0xd # (DIE (0xe0) DW_TAG_variable)
.ascii "bt\0" # DW_AT_name
[...]
.byte 0x6 # DW_AT_location
.byte 0x91 # DW_OP_fbreg
.sleb128 -56
.byte 0x6 # DW_OP_deref
.byte 0x23 # DW_OP_plus_uconst
.uleb128 0x8
.byte 0x9f # DW_OP_stack_value
So, when ada_value_print passes the bt's (value) address, it passes
in effect a meaningless address. The problem continues shortly after
when ada_val_print_1 re-creates the value from the contents and address.
The value has become an lval_memory, with a null address.
As a result, we trigger a memory error later on, while trying to
read the array bounds in order to transform our value into a simple
array.
To avoid the problem entirely, the fix is to coerce references before
transforming array descriptors into simple arrays.
gdb/ChangeLog:
* ada-valprint.c (ada_val_print_1): If our value is a reference
to an array descriptor, dereference it before converting it
to a simple array.
gdb/testsuite/ChangeLog:
* gdb.ada/aliased_array: New testcase.
Diffstat (limited to 'libiberty/getopt.c')
0 files changed, 0 insertions, 0 deletions