From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9163 invoked by alias); 1 Apr 2009 19:08:29 -0000 Received: (qmail 8886 invoked by uid 22791); 1 Apr 2009 19:08:28 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from ugmailsb.ugent.be (HELO ugmailsb.ugent.be) (157.193.71.46) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 01 Apr 2009 19:08:21 +0000 Received: from localhost (localhost [127.0.0.1]) by ugmailsb.ugent.be (Postfix) with ESMTP id A4E552AAF36 for ; Wed, 1 Apr 2009 21:08:18 +0200 (CEST) Received: from ugmailsb.ugent.be ([127.0.0.1]) by localhost (ugmailsb.ugent.be [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1VFt-wFkMmhp for ; Wed, 1 Apr 2009 21:08:18 +0200 (CEST) Received: from cedar.ugent.be (cedar.ugent.be [157.193.49.14]) by ugmailsb.ugent.be (Postfix) with ESMTP id 586C72AAC9D for ; Wed, 1 Apr 2009 21:08:18 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAOdY00mdwc4w/2dsb2JhbADQdoN7Bg Received: from mail.elis.ugent.be ([157.193.206.48]) by relays9.ugent.be with ESMTP; 01 Apr 2009 21:08:18 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.elis.UGent.be (Postfix) with ESMTP id CD1E82BABED for ; Wed, 1 Apr 2009 21:08:11 +0200 (CEST) Received: from [127.0.0.1] (ssh2.elis.UGent.be [157.193.206.127]) by mail.elis.UGent.be (Postfix) with ESMTP id B9B1D2BABEB for ; Wed, 1 Apr 2009 21:08:11 +0200 (CEST) Message-Id: <4B835C7C-B28E-4552-87E0-25D803741FA3@elis.ugent.be> From: Jonas Maebe To: gdb@sourceware.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v926) Subject: Skipping over trampolines/stubs Date: Wed, 01 Apr 2009 19:08:00 -0000 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-04/txt/msg00008.txt.bz2 Hi, We have a language construct whereby some calls have to be rerouted via a small stubs/trampolines. When encountering such a stub, gdb currently does not step into them, because the have no line info available (and hence gdb also does not step into the target call unless you manually place a breakpoint at the destination). When the stub is generated in the same source file as where its destination lies, I can easily generate the same source info for the stub as for the target code, and then everything works fine (at least with DWARF; stabs would also require a fake procedure body, at least on Mac OS X). The problem is if the target code is located in a different source file. I think I can hack our compiler so it can figure out whether that other source file was compiled with debug information and if so, what the file/line information of the source file of the target code would be, but it wouldn't be easy and kind of messy. So I'm wondering whether there's maybe some trick that you can use to make gdb step through arbitrary stubs somehow (maybe some kind of fake line information that it always ignores and just skips over), or whether there is another possible approach. Thanks, Jonas PS, the actual implementation details: it's in case of interfaces in Free Pascal (similar to Java interfaces). When you call an interface method using a class instance, the self pointer needs to be adjusted before the interface method is entered (it has to be changed so it points to the interface's vmt). This is done using a small stub, to avoid having to inline this code everywhere (it's kind of bulky in some cases). These stubs have to be generated in the source files containing the implementations of classes that implements an interface and not in the source file of the interface itself, because the adjustment of the self pointer depends on the class (depending on how many interfaces it implements, and in which order). Here are a couple of examples of such stubs (the first for a function using the stdcall calling convention, the second for one using the Borland-style fastcall calling convention): .globl _WRPR_P$PROGRAM_TMYCLASS_$_IINTERFACE_$_0_ $__SYSTEM_TINTERFACEDOBJECT_$__QUERYINTERFACE$TGUID$formal$$LONGINT _WRPR_P$PROGRAM_TMYCLASS_$_IINTERFACE_$_0_$__SYSTEM_TINTERFACEDOBJECT_ $__QUERYINTERFACE$TGUID$formal$$LONGINT: subl $12,4(%esp) jmp L_SYSTEM_TINTERFACEDOBJECT_$__QUERYINTERFACE$TGUID $formal$$LONGINT$stub .globl _WRPR_P$PROGRAM_TMYCLASS_$_IINTERFACE_$_3_$__P $PROGRAM_TMYCLASS_$__MYDO _WRPR_P$PROGRAM_TMYCLASS_$_IINTERFACE_$_3_$__P$PROGRAM_TMYCLASS_$__MYDO: subl $12,%eax pushl %ebx pushl %eax movl (%eax),%eax movl 80(%eax),%eax movl %eax,4(%esp) popl %eax ret