OSDN Git Service

variables whose type is a typedef to an array pointer
authorbrobecke <brobecke>
Fri, 1 Jul 2011 18:25:49 +0000 (18:25 +0000)
committerbrobecke <brobecke>
Fri, 1 Jul 2011 18:25:49 +0000 (18:25 +0000)
commiteab25b1a55ab27a5690ae96b820a022eb57b9eec
tree9fb6a6665471b1e52e0041cbfeeeeebfa656ab91
parent4c3d8cca88ac5486c73b210a1376f78d36f24fb0
variables whose type is a typedef to an array pointer

If we declare a type as being an access to array type, and then
declare a variable of that type, for instance:

        type Some_Array is array [...];
        type Array_Access is access all Some_Array;
        Table : Array_Access := [...];

The variable "Table" may be defined in the debugging information
as being a typedef to the array pointer type. In the past, it was
defined directly as the array pointer type, but this has been changed
to make sure that the typedef type gets used.

If the typedef type wasn't used, it would allow the compiler to stop
emitting that typedef type when compiling with
-feliminate-unused-debug-types.  The removal of this typedef would
be a problem, because GDB relies on the typedef to create symbols
for pointer types, and without it, we would no longer be able to
do "ptype array_access".

This patch helps prevent incorrect output or even crashes when that
extra typedef layer is used.

The testing is already mostly covered by arrayptr.exp, but I still
added a 'ptype' test, just for good measure.

gdb/ChangeLog: (Eric Botcazou)

        * ada-lang.c (thin_descriptor_type): Deal with typedefs.
        (decode_constrained_packed_array): Likewise.
        (ada_evaluate_subexp) <TERNOP_SLICE>: Likewise.

gdb/testsuite/ChangeLog (Joel Brobecker):

        * gdb.ada/arrayptr.exp: Add ptype test.
gdb/ChangeLog
gdb/ada-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/arrayptr.exp