From: Jonas Maebe <jonas.maebe@elis.ugent.be>
To: tromey@redhat.com, FPC Core Developer List <core@freepascal.org>
Cc: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>,
gdb-patches@sourceware.org
Subject: Re: [Core] [RFC] dwarf debug information: Handle Free Pascal virtual table indexes
Date: Thu, 13 May 2010 18:12:00 -0000 [thread overview]
Message-ID: <D690278D-68ED-42B8-9FEE-B3ADF3F68DFA@elis.ugent.be> (raw)
In-Reply-To: <m38w7nvhz1.fsf@fleche.redhat.com>
On 13 May 2010, at 19:17, Tom Tromey wrote:
> The value of DW_AT_vtable_elem_location is a DWARF location expression.
> From the DWARF 4 (review) spec:
>
> An entry for a virtual function also has a DW_AT_vtable_elem_location
> attribute whose value contains a location description yielding the
> address of the slot for the function within the virtual function table
> for the enclosing class. The address of an object of the enclosing type
> is pushed onto the expression stack before the location description is
> evaluated.
>
> One thing that would be helpful is if you ran "readelf -w" (or some
> other DWARF dumper) on a program created by FPC that has this attribute,
> then posted the DIE in question.
I agree with you that from reading the DWARF spec it seems that we are generating an incomplete location. Here's a dwarfdump of what we generate (Mac OS X):
0x000000f1: TAG_subprogram [12] *
AT_name( "TEST" )
AT_prototyped( 0x01 )
AT_calling_convention( 0x41 )
AT_external( 0x01 )
AT_virtuality( DW_VIRTUALITY_virtual )
AT_vtable_elem_location( <0x2> 10 03 )
AT_low_pc( 0x00000050 )
AT_high_pc( 0x00000096 )
I based that on what I saw gcc 4.0 (and 4.2) generate under Mac OS X for a virtual C++ method:
0x00007d35: TAG_subprogram [115] *
AT_external( 0x01 )
AT_name( "eat" )
AT_decl_file( "/Volumes/Leopard/Data/dev/fpc/test/virtmeth.cpp" )
AT_decl_line( 7 )
AT_MIPS_linkage_name( "_ZN6Animal3eatEv" )
AT_virtuality( DW_VIRTUALITY_virtual )
AT_vtable_elem_location( <0x2> 10 00 )
AT_containing_type( {0x00007d0f} )
AT_declaration( 0x01 )
AT_sibling( {0x00007d55} )
In fact, it seem to be the same for g++ 4.1.2 under Linux/x86-64:
<2><5ce5>: Abbrev Number: 102 (DW_TAG_subprogram)
DW_AT_external : 1
DW_AT_name : eat
DW_AT_decl_file : 1
DW_AT_decl_line : 7
DW_AT_MIPS_linkage_name: _ZN6Animal3eatEv
DW_AT_virtuality : 1 (virtual)
DW_AT_vtable_elem_location: 2 byte block: 10 0 (DW_OP_constu: 0)
DW_AT_containing_type: <5c94>
DW_AT_declaration : 1
So I'm not sure what's going on here. The C++ code I used is below (some example I took from the web).
Jonas
#include <iostream>
using namespace std;
class Animal
{
public:
virtual void eat() { cout << "I eat like a generic Animal." << endl;
}
};
class Wolf : public Animal
{
public:
void eat() { cout << "I eat like a wolf!" << endl; }
};
class Fish : public Animal
{
public:
void eat() { cout << "I eat like a fish!" << endl; }
};
class OtherAnimal : public Animal
{
};
int main()
{
Animal* anAnimal[4];
anAnimal[0] = new Animal();
anAnimal[1] = new Wolf();
anAnimal[2] = new Fish();
anAnimal[3] = new OtherAnimal();
for (int i = 0; i < 4; i++) {
anAnimal[i]->eat();
delete anAnimal[i];
}
return 0;
}
next prev parent reply other threads:[~2010-05-13 17:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <23651.5388860882$1273672053@news.gmane.org>
2010-05-12 21:24 ` Tom Tromey
2010-05-13 7:59 ` Pierre Muller
[not found] ` <11064.3996195451$1273708856@news.gmane.org>
2010-05-13 17:29 ` Tom Tromey
2010-05-13 18:12 ` Jonas Maebe [this message]
2010-05-13 21:13 ` [Core] " Tom Tromey
2010-05-13 21:25 ` Jonas Maebe
2010-05-14 17: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=D690278D-68ED-42B8-9FEE-B3ADF3F68DFA@elis.ugent.be \
--to=jonas.maebe@elis.ugent.be \
--cc=core@freepascal.org \
--cc=gdb-patches@sourceware.org \
--cc=pierre.muller@ics-cnrs.unistra.fr \
--cc=tromey@redhat.com \
/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