This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: How to setup a breakpoint on constructor
- From: "Eli Zaretskii" <eliz at gnu dot org>
- To: mec dot gnu at mindspring dot com (Michael Elizabeth Chastain)
- Cc: drow at false dot org, gdb at sources dot redhat dot com, rolandz at poczta dot fm
- Date: Sat, 17 Jul 2004 13:28:33 +0200
- Subject: Re: How to setup a breakpoint on constructor
- References: <20040716193117.EFE514B104@berman.michael-chastain.com>
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
> 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.