Re: debugging custom array types

Jan Kratochvil
2013-02-11T17:02:40Z

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.

But FSF GDB generally displays such arrays as pointers instead:

34 foo (int size) {
36 char temp1[size];
FSF GDB:
(gdb) p temp1
$1 = 0x7fffffffd9e0 "XXX"
(gdb) ptype temp1
type = char []
archer-jankratochvil-vla:
(gdb) p temp1
$1 = "XXX"
(gdb) ptype temp1
type = char [26]

> 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.

BTW such dynamic types are in the archer-jankratochvil-vla branch above, for a
simple one see gdb.base/vla.exp.

<1><12c>: Abbrev Number: 11 (DW_TAG_array_type)
<12d> DW_AT_type : <0x49>
<2><135>: Abbrev Number: 12 (DW_TAG_subrange_type)
<136> DW_AT_type : <0x34>
<13a> DW_AT_upper_bound : 3 byte block: 91 48 6 (DW_OP_fbreg: -56; DW_OP_deref)
<2><13e>: Abbrev Number: 0

Regards,
Jan