From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25040 invoked by alias); 17 Jul 2004 14:30:16 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 25032 invoked from network); 17 Jul 2004 14:30:16 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sourceware.org with SMTP; 17 Jul 2004 14:30:16 -0000 Received: from drow by nevyn.them.org with local (Exim 4.34 #1 (Debian)) id 1BlqBr-0007ey-NB; Sat, 17 Jul 2004 10:29:27 -0400 Date: Sat, 17 Jul 2004 14:54:00 -0000 From: Daniel Jacobowitz To: Eli Zaretskii Cc: Michael Elizabeth Chastain , gdb@sources.redhat.com, rolandz@poczta.fm Subject: Re: How to setup a breakpoint on constructor Message-ID: <20040717142927.GA29310@nevyn.them.org> Mail-Followup-To: Eli Zaretskii , Michael Elizabeth Chastain , gdb@sources.redhat.com, rolandz@poczta.fm References: <20040716193117.EFE514B104@berman.michael-chastain.com> <5567-Sat17Jul2004132833+0300-eliz@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5567-Sat17Jul2004132833+0300-eliz@gnu.org> User-Agent: Mutt/1.5.5.1+cvs20040105i X-SW-Source: 2004-07/txt/msg00224.txt.bz2 On Sat, Jul 17, 2004 at 01:28:33PM +0200, Eli Zaretskii wrote: > > Date: Fri, 16 Jul 2004 15:31:17 -0400 (EDT) > > From: mec.gnu@mindspring.com (Michael Elizabeth Chastain) > > > > To take the points in reverse order, > > > > > (B) It exposes the difference between complete and base constructors, > > > which is an implementation detail of the C++ ABI that most users don't > > > understand. > > > > That is reality. > > Yes. > > > The reality is that g++ emits two functions in the object code. In > > my opinion, if we try to gloss over that, then we'll just create > > more confusion for commands such as 'disassemble' and 'tbreak'. > > We could perhaps help users who are oblivious to this (or just > forgot) by showing them the possible places where GDB could put the > breakpoint, including the more self-explaining names, and asking them > what to do. For example: > > (gdb) break 'A::A()' > The constructor 'A::A()' has two code instances: > > Address Mangled Name Name Description > 08048544 _ZN1AC1Ev A::A()$base() Base constructor for A > 080486e2 _ZN1AC2Ev A::A()$allocate() Allocating constructor for A > > Where do you want to put your breakpoint? Type `1' for the first > instance, `2' for the second, `A' for all of them: > 1 <==== user response > > Breakpoint 1 at 0x8048544: file derivation.cc, line 7. At that point we may as well automatically set both breakpoints; that's almost always what the user wants. Then we can do without the naming hack. Coincidentally that's what the entire discussion of 1:N breakpoints last year was about but no one has had time to implement it. Note that we'll still get continuous complaints about setting breakpoints in constructors! The reason this is hard is that breakpoints by line number inside the constructor will still get randomly set on one copy. Many IDEs will set breakpoints in this fashion. -- Daniel Jacobowitz