]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/ada-lang.c
[Ada] print packed arrays indexed by enumerated type
authorJoel Brobecker <brobecker@gnat.com>
Wed, 29 Feb 2012 19:34:40 +0000 (19:34 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Wed, 29 Feb 2012 19:34:40 +0000 (19:34 +0000)
commit99b1c762c990c8488c70ad537412f1209b5610bd
tree602c84fc117b6d1842ac67c07dca089dce8fcb46
parent2d4a02ee9526f370ccd9bdc3f30510f03ee59d19
[Ada] print packed arrays indexed by enumerated type

Consider the following declarations (a packed array indexed by an
enumerated type):

    type Color is (Black, Red, Green, Blue, White);
    type Full_Table is array (Color) of Boolean;
    pragma Pack (Full_Table);
    Full : Full_Table := (False, True, False, True, False);

GDB is unable to print the index values correctly. It prints the
enumeration's underlying value instead of the enumeration name:

    (gdb) p full
    $1 = (0 => false, true, false, true, false)
    (gdb) p full'first
    $2 = 0

And yet, it is capable of printing the correct type description:

    (gdb) ptype full
    type = array (black .. white) of boolean <packed: 1-bit elements>

To get to the real index type, one has to follow the parallel XA type.
We already do this for normal arrays. We can do it for this packed
array as well.

gdb/ChangeLog:

        * ada-lang.c (constrained_packed_array_type): If there is a
        parallel XA type, use it to determine the array index type.

gdb/testsuite/ChangeLog:

        * gdb.ada/arrayidx.exp: Adjust expected output for p_one_two_three.
        * gdb.ada/enum_idx_packed: New testcase.
gdb/ChangeLog
gdb/ada-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/arrayidx.exp
gdb/testsuite/gdb.ada/enum_idx_packed.exp [new file with mode: 0644]
gdb/testsuite/gdb.ada/enum_idx_packed/foo.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/enum_idx_packed/pck.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/enum_idx_packed/pck.ads [new file with mode: 0644]