Re: debugging custom array types

Michael Haupt
2013-02-13T10:50:50Z

Jan,

thanks a lot, this is most enlightening ...

Am 11.02.2013 um 18:02 schrieb Jan Kratochvil <jan.kratochvil@redhat.com>:
> On Mon, 11 Feb 2013 17:51:36 +0100, Michael Haupt wrote:
>> The internal layout of an array instance is as follows:
>> +0 hub reference (reference to meta-information, e.g., class, vtable, ...)
>> +8 length
>> +12 beginning of array contents (offset depends on type, 12 is for char, for instance)
>
> THis means the type length is stored in inferior memory. I call it 'dynamic
> type', FSF GDB does not support it, it is supported in
> archer-jankratochvil-vla from
> http://sourceware.org/gdb/wiki/ArcherBranchManagement
> or in any Fedora GDB.

Is there documentation somewhere that explicates which pieces of DWARF gdb supports out of the box? I'm not opposed to patching it but would like to know better what to (not) expect.

>> The DWARF I'm generating right now looks as pasted at the end of this message.
>
> Could you display it with GNU binutils "readelf -wi"? There aren't the DWARF
> expressions decoded so it is not easy to read what you have there.

Sure; sorry about having missed that. It's pasted below. Interestingly the byte_size DWARF expressions are not interpreted.

The one in char_array looks as follows:
DW_OP_push_object_address
DW_OP_plus_uconst: 8
DW_OP_deref_size: 4
DW_OP_const1u: 2
DW_OP_mul
DW_OP_plus_uconst: 12

The one in the array type, as follows:
DW_OP_push_object_address
DW_OP_plus_uconst: 8
DW_OP_deref_size: 4
DW_OP_const1u: 2
DW_OP_mul

Best,

Michael

<1><5320>: Abbrev Number: 16 (DW_TAG_structure_type)
<5321> DW_AT_name : (indirect string, offset: 0x177): char_array
<5325> DW_AT_byte_size : 10 byte block: 97 23 8 94 4 8 2 1e 23 c
<5330> DW_AT_sibling : <0x5359>
<2><5334>: Abbrev Number: 10 (DW_TAG_member)
<5335> DW_AT_name : (indirect string, offset: 0xdc): __hub_reference__
<5339> DW_AT_type : <0x5c6f>
<533d> DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0)
<2><5340>: Abbrev Number: 10 (DW_TAG_member)
<5341> DW_AT_name : (indirect string, offset: 0x185): __length__
<5345> DW_AT_type : <0x2d>
<5349> DW_AT_data_member_location: 2 byte block: 23 8 (DW_OP_plus_uconst: 8)
<2><534c>: Abbrev Number: 10 (DW_TAG_member)
<534d> DW_AT_name : (indirect string, offset: 0x195): __array__
<5351> DW_AT_type : <0x5a6c>
<5355> DW_AT_data_member_location: 2 byte block: 23 c (DW_OP_plus_uconst: 12)
...
<1><5a6c>: Abbrev Number: 11 (DW_TAG_array_type)
<5a6d> DW_AT_type : <0x4f11>
<5a71> DW_AT_byte_size : 8 byte block: 97 23 8 94 4 8 2 1e
<5a7a> DW_AT_data_location: 3 byte block: 97 23 c (DW_OP_push_object_address; DW_OP_plus_uconst: 12)
<5a7e> DW_AT_sibling : <0x5a91>
<2><5a82>: Abbrev Number: 14 (DW_TAG_subrange_type)
<5a83> DW_AT_type : <0x2d>
<5a87> DW_AT_upper_bound : 8 byte block: 97 23 8 94 4 8 1 1c (DW_OP_push_object_address; DW_OP_plus_uconst: 8; DW_OP_deref_size: 4; DW_OP_const1u: 1; DW_OP_minus)

--
Dr. Michael Haupt
Principal Member of Technical Staff
Phone: +49 331 200 7277, Fax: +49 331 200 7561
Oracle Labs
Oracle Deutschland B.V. & Co. KG, Schiffbauergasse 14, 14467 Potsdam, Germany