OSDN Git Service

[Ada] Fix unconstrained packed array size
authorbrobecke <brobecke>
Thu, 17 Feb 2011 15:42:55 +0000 (15:42 +0000)
committerbrobecke <brobecke>
Thu, 17 Feb 2011 15:42:55 +0000 (15:42 +0000)
commitbd6dea736a58bffa89fd95b4191dd120e43f83e4
treec6ca74ce2bf868cddecfc8d66c2e5f37db5c9745
parente06b80a5235197937c8579dbbae9f9f1af9c77b5
[Ada] Fix unconstrained packed array size

When ada-lang transforms an array descriptor type (an XUP structure)
into an array type, the size of the array type is computed by using
the element size, and multiplying it by the number of elements in
that array. This does not work, however, for packed arrays, where
the *packed* size in bits needs to be used.

This usually does not cause any problem, because we end up reading
more memory than needed.  However, we have observed on LynxOS
a memory error while trying to read the entire array, because
the larger-than-needed read tried to read past the end of the stack
into inaccessible memory.

This patch fixes the problem by correctly computing the array size
in bytes in the case of packed arrays.

gdb/ChangeLog:

        * ada-lang.c (ada_type_of_array): Fix the size of the array
        in the case of an unconstrained packed array.

gdb/testsuite/ChangeLog:

        * gdb.ada/packed_array: Expand testcase to test printing of
        unconstrained packed array.
gdb/ChangeLog
gdb/ada-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/packed_array.exp
gdb/testsuite/gdb.ada/packed_array/pa.adb
gdb/testsuite/gdb.ada/packed_array/pck.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/packed_array/pck.ads [new file with mode: 0644]