From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13465 invoked by alias); 14 Feb 2006 17:31:17 -0000 Received: (qmail 13455 invoked by uid 22791); 14 Feb 2006 17:31:15 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Tue, 14 Feb 2006 17:31:12 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1F9415-0007Cw-CY; Tue, 14 Feb 2006 12:31:07 -0500 Date: Tue, 14 Feb 2006 17:31:00 -0000 From: Daniel Jacobowitz To: Mark Kettenis Cc: f.hackenberger@chello.at, gdb@sourceware.org Subject: Re: breakpoints in shared libraries Message-ID: <20060214173107.GA27548@nevyn.them.org> Mail-Followup-To: Mark Kettenis , f.hackenberger@chello.at, gdb@sourceware.org References: <200602141729.09355.f.hackenberger@chello.at> <20060214170031.GA26297@nevyn.them.org> <200602141721.k1EHL7R0015198@elgar.sibelius.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200602141721.k1EHL7R0015198@elgar.sibelius.xs4all.nl> User-Agent: Mutt/1.5.8i X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-02/txt/msg00137.txt.bz2 On Tue, Feb 14, 2006 at 06:21:07PM +0100, Mark Kettenis wrote: > But Florian is setting a breakpoint using FILENAME:LINE syntax and not > using FUNCTIONNAME syntax. That should work isn't it? At least as > long as GCC is not inlining the constructor such that there are > actually multiple copies in the code and GDB sets the breakpoint in a > different copy than the one being executed. Nope. I don't have a handy copy of the explanation, so here it is. Take a look at the "Itanium C++ ABI", which has some Itanium-specific language in it but is actually widely adopted for non-Itanium platforms by multiple compilers, GNU and otherwise. Here it is: http://www.codesourcery.com/cxx-abi/abi.html It's got this to say about constructors: ::= C1 # complete object constructor ::= C2 # base object constructor ::= C3 # complete object allocating constructor ::= D0 # deleting destructor ::= D1 # complete object destructor ::= D2 # base object destructor The relevant section is 2.6. When constructing a virtual base class, the C2 constructor is called instead of the C1 constructor. Now, in theory, a compiler can generate one of these as a tiny trampoline that jumps to the other, and only emit debug information for the real one, and things will work. But GCC doesn't do this and attempts to get it to do so have, so far, met with failure. So there's two functions for every single constructor, and GDB tends to breakpoint one of them more or less at random. I maintain that the two right things to do here are (A) fix GCC to support functions with multiple entry points, or at least something that can give a good impression of it, and (B) set breakpoints by function name or line number at all copies. An astute observer will notice that both (A) and (B) are hard :-) I've been working on (B) as I can find the time, and some cleanups for it have already been done, and I posted an early prototype. But I never got back to it. The Ada folks expressed some interested, and I think Fred did too, but so far nothing's come of it. -- Daniel Jacobowitz CodeSourcery