Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Michael Haupt <m@haupz.de>
To: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: debugging custom array types
Date: Mon, 11 Feb 2013 16:51:00 -0000	[thread overview]
Message-ID: <AF075507-9C9E-4D7A-A747-589E0074057E@haupz.de> (raw)

Dear all,

in a research project, I'm generating DWARF debug info for machine code generated from Java. Note that I'm not using gcj. I'm using gdb 7.5, mostly on Darwin, but the symptoms are the same on Linux.

I'm having some trouble with my array types. In particular, there are two problems:
1. I would like to generate DWARF info that allows gdb to display array contents.
2. gdb seems to misinterpret valid addresses when they are used in DWARF expressions.

Details follow.

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)

The DWARF I'm generating right now looks as pasted at the end of this message. This is for Java char arrays with the layout given above. Note the __array__ member; its type is a plain TAG_array_type that should be interpreted as embedded.

Now, I cannot for the life of me convince gdb to display the contents of those arrays. I'm pretty sure the DWARF info I'm generating has a problem but cannot figure out what it is. I've been turning things from left to right for a while now.

Here's an excerpt from a debugging session:

    (gdb) p slot_1_Object
    $1 = java.lang.String@101008910
    (gdb) p *slot_1_Object 
    $2 = {__hub_reference__: @101000070, value: @101008928, hash32: 0}
    (gdb) p *slot_1_Object.value 
    Cannot access memory at address 0x101008928

What I'd have expected here is something of the form {__hub_reference__: ..., __length__: ..., __array__: {...}}, but gdb complains about the address.

Still,
    (gdb) x/10xb 0x101008928
    0x101008928:	0xe8	0x00	0x00	0x01	0x01	0x00	0x00	0x00
    0x101008930:	0x0c	0x00

... so this is definitely not illegal memory. (I can tell from the address it's a valid heap address.)



Grateful for any advice,

Michael






0x00005984:     TAG_structure_type [16] *
                 AT_name( "char_array" )
          ((1))  AT_byte_size( <0xa> 97 23 08 94 04 08 02 1e 23 0c  )
                 AT_sibling( {0x000059bd} )
0x00005998:         TAG_member [10]  
                     AT_name( "__hub_reference__" )
                     AT_type( {0x00005c9c} ( Lcom/oracle/svm/core/hub/DynamicHub; ) )
                     AT_data_member_location( +0 )
0x000059a4:         TAG_member [10]  
                     AT_name( "__length__" )
                     AT_type( {0x0000002d} ( base  ) )
                     AT_data_member_location( +8 )
0x000059b0:         TAG_member [10]  
                     AT_name( "__array__" )
                     AT_type( {0x00005a1e} ( char[] ) )
                     AT_data_member_location( +12 )
0x000059bc:         NULL
...
0x00005a1e:     TAG_array_type [11] *
                 AT_type( {0x0000505b} ( char ) )
          ((2))  AT_byte_size( <0x8> 97 23 08 94 04 08 02 1e  )
          ((3))  AT_data_location( <0x3> 97 23 0c  )
                 AT_sibling( {0x00005a43} )
0x00005a34:         TAG_subrange_type [14]  
                     AT_type( {0x0000002d} ( base  ) )
          ((4))      AT_upper_bound( <0x8> 97 23 08 94 04 08 01 1c  )
0x00005a42:         NULL

The DWARF expressions at ((1))-((4)) each compute the respective values by pushing the object location, dereferencing the __length__ field, multiplying with the array element size, and possibly adding the array base offset.



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


             reply	other threads:[~2013-02-11 16:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-11 16:51 Michael Haupt [this message]
2013-02-11 17:02 ` Jan Kratochvil
2013-02-13 10:50   ` Michael Haupt
2013-02-13 17:52     ` Tom Tromey
2013-02-14 13:27       ` Michael Haupt
2013-02-14 16:51         ` Tom Tromey
2013-02-13 17:59     ` Jan Kratochvil
2013-02-14 13:37       ` Michael Haupt
2013-02-14 13:44         ` Jan Kratochvil
2013-02-12 19:28 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AF075507-9C9E-4D7A-A747-589E0074057E@haupz.de \
    --to=m@haupz.de \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox