From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31577 invoked by alias); 13 May 2010 17:51:59 -0000 Received: (qmail 31565 invoked by uid 22791); 13 May 2010 17:51:57 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp2.ugent.be (HELO smtp2.UGent.be) (157.193.49.126) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 13 May 2010 17:51:51 +0000 Received: from localhost (mcheck2.ugent.be [157.193.49.249]) by smtp2.UGent.be (Postfix) with ESMTP id 9B2E744A1CE; Thu, 13 May 2010 19:51:48 +0200 (CEST) Received: from smtp2.UGent.be ([157.193.49.126]) by localhost (mcheck2.ugent.be [157.193.43.11]) (amavisd-new, port 10024) with ESMTP id kP4p2nP908WC; Thu, 13 May 2010 19:51:48 +0200 (CEST) Received: from [192.168.1.2] (unknown [91.182.107.115]) (Authenticated sender: jmaebe) by smtp2.UGent.be (Postfix) with ESMTPSA id 55D3744A1C7; Thu, 13 May 2010 19:51:46 +0200 (CEST) Subject: Re: [Core] [RFC] dwarf debug information: Handle Free Pascal virtual table indexes Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=us-ascii From: Jonas Maebe In-Reply-To: Date: Thu, 13 May 2010 18:12:00 -0000 Cc: "Pierre Muller" , gdb-patches@sourceware.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <23651.5388860882$1273672053@news.gmane.org> <11064.3996195451$1273708856@news.gmane.org> To: tromey@redhat.com, FPC Core Developer List X-j-chkmail-Enveloppe: 4BEC3C31.001/91.182.107.115/[91.182.107.115]/[192.168.1.2]/ X-j-chkmail-Score: MSGID : 4BEC3C31.001 on smtp2.UGent.be : j-chkmail score : . : R=. U=. O=. B=0.000 -> S=0.000 X-j-chkmail-Status: Ham Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-05/txt/msg00281.txt.bz2 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: >=20 > 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. >=20 > 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 gene= rating 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/virt= meth.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=20=20=20=20=20=20 DW_AT_name : eat=20=20=20=20 DW_AT_decl_file : 1=20=20=20=20=20=20 DW_AT_decl_line : 7=20=20=20=20=20=20 DW_AT_MIPS_linkage_name: _ZN6Animal3eatEv=20=20 DW_AT_virtuality : 1 (virtual) DW_AT_vtable_elem_location: 2 byte block: 10 0 (DW_OP_constu: 0) DW_AT_containing_type: <5c94>=20=20=20=20=20=20 DW_AT_declaration : 1=20=20=20=20=20=20 So I'm not sure what's going on here. The C++ code I used is below (some ex= ample I took from the web). Jonas #include using namespace std; =20 class Animal { public: virtual void eat() { cout << "I eat like a generic Animal." << endl;=20 } }; =20 class Wolf : public Animal { public: void eat() { cout << "I eat like a wolf!" << endl; } }; =20 class Fish : public Animal { public: void eat() { cout << "I eat like a fish!" << endl; } }; =20 class OtherAnimal : public Animal { }; =20 int main() { Animal* anAnimal[4]; =20 anAnimal[0] =3D new Animal(); anAnimal[1] =3D new Wolf(); anAnimal[2] =3D new Fish(); anAnimal[3] =3D new OtherAnimal(); =20 for (int i =3D 0; i < 4; i++) { anAnimal[i]->eat(); delete anAnimal[i]; } =20 return 0; }