This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to setup a breakpoint on constructor


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]