Re: How to setup a breakpoint on constructor

Eli Zaretskii
2004-07-17T10:30:34Z

> 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.