Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@redhat.com>
To: <Cedric.Pillonel@swisscom.com>
Cc: <gdb@sources.redhat.com>, <gdb-prs@sources.redhat.com>
Subject: Re: Breakpoints in ctor and gcc 3.x
Date: Wed, 01 Oct 2003 06:57:00 -0000	[thread overview]
Message-ID: <vt2smmdla9n.fsf@zenia.home> (raw)
In-Reply-To: <57CE6CB990693A478C1106BBC91398BA7D559D@sxmbx04.corproot.net>


<Cedric.Pillonel@swisscom.com> writes:
> This bug is old and I'm surprised that it still has not been fixed
> !!!  Is there any workaround?  When will it be fixed ? I think it is
> a serious one since you can't debug your ctor or dtor !

The problem is that GCC emits two copies of a constructor: one that's
called to initialize a direct instance of the class (the "in charge"
constructor), and one to initialize the class's portion of an instance
of some derived class (the "not-in-charge" constructor).  They deal
with virtual base classes differently, and there may be some other
things.  But GDB only sets a breakpoint in one copy --- whichever one
appears first in the code.

At the moment, GDB assumes that each breakpoint set by the user can be
implemented by a single break instruction or hardware breakpoint.  To
handle breakpoints on constructors, you need to set two low-level
breakpoints --- one on the in-charge, and one on the not-in-charge.
This is going to be a lot of work to fix, and there were other, also
serious, C++ bugs folks decided to work on first.

Simply knowing the in-charge vs. not-in-charge distinction may help
out.  For example, if you're trying to debug the constructor for some
class's base class, but GDB is setting its breakpoint on the in-charge
constructor, you could try instantiating the base class directly, to
hit the breakpoint.  Or the reverse. 

You could try setting the breakpoint by raw address: use "disassemble"
and x/i to find the code address of the constructor instance you
actually want to debug, and use "break *EXPR" to set the breakpoint
there.


  reply	other threads:[~2003-10-01  6:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-01  6:38 Cedric.Pillonel
2003-10-01  6:57 ` Jim Blandy [this message]
2003-10-01 10:35   ` about class LOC_COMPUTED_ARG ankit thukral
2003-10-01 14:49     ` Daniel Jacobowitz
2003-10-02  3:52       ` Jim Blandy
2003-10-01 14:48 ` Breakpoints in ctor and gcc 3.x Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vt2smmdla9n.fsf@zenia.home \
    --to=jimb@redhat.com \
    --cc=Cedric.Pillonel@swisscom.com \
    --cc=gdb-prs@sources.redhat.com \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox