This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] [Ada] Preserve typedef layer when getting struct element


*** TEST RESULTS FOR COMMIT 460efde16c5ce834f03d1a7525e453b508cb43da ***

Author: Joel Brobecker <brobecker@adacore.com>
Branch: master
Commit: 460efde16c5ce834f03d1a7525e453b508cb43da

[Ada] Preserve typedef layer when getting struct element
Consider the following declarations:

   type Int_Access is access Integer;
   type Record_Type is record
      IA : Int_Access;
   end record;

   R : Record_Type;

Printing the type name of "R.IA" yields:

    (gdb) whatis r.ia
    type = access integer

It should be:

    (gdb) whatis r.ia
    type = bar.int_access

Looking at the debugging info, field "r.ia" is defined as
a typedef which has the name of the field type:

        .uleb128 0x3    # (DIE (0x4e) DW_TAG_typedef)
        .long   .LASF4  # DW_AT_name: "bar__int_access"
        .long   0x8b    # DW_AT_type

... with the typedef's target type being an anonymous pointer
type:

        .uleb128 0x7    # (DIE (0x8b) DW_TAG_pointer_type)
        .byte   0x8     # DW_AT_byte_size
        .long   0x91    # DW_AT_type

What happens here is that a couple of function in ada-lang.c
always start by stripping all typedef layers when handling
struct fields, with the effect of making us lose the type name
in this case.

We did not understand this at the time the code was written,
but typedefs should be stripped only when we know we do not
need them. So this patch, adjust the code to avoid the stripping
while handling the fields, and adds it back in the lone place
which handles the result of processing and didn't know how to
handle typedefs struct fields yet.

gdb/ChangeLog:

        * ada-lang.c (ada_is_tagged_type): Add call to ada_check_typedef.
        (ada_lookup_struct_elt_type): Remove calls to ada_check_typedef.
        (template_to_static_fixed_type): Call ada_check_typedef only
        when necessary.

gdb/testsuite/ChangeLog:

        * gdb.ada/rec_comp: New testcase.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]