This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: debugging custom array types
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Michael Haupt <m at haupz dot de>
- Cc: "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Mon, 11 Feb 2013 18:02:21 +0100
- Subject: Re: debugging custom array types
- References: <AF075507-9C9E-4D7A-A747-589E0074057E@haupz.de>
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