Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@mvista.com>
To: David Carlton <carlton@bactrian.org>
Cc: gdb <gdb@sources.redhat.com>
Subject: Re: breakpoints in constructors
Date: Thu, 24 Apr 2003 14:50:00 -0000	[thread overview]
Message-ID: <20030424145034.GA14226@nevyn.them.org> (raw)
In-Reply-To: <m38yu7zi5d.fsf@papaya.bactrian.org>

On Fri, Apr 18, 2003 at 01:04:46PM -0700, David Carlton wrote:
> I might have some time over the next few weeks (/months) to work on
> the "breakpoints in constructors" issue.  Daniel: clearly you've
> thought about this already, so if you happen to have time to do a bit
> of a brain dump on the issue at some point, I'd appreciate it.

Sure.  First of all, a rough overview of the problem; might as well
keep everything in one place.

With the new GCC 3.x multi-vendor C++ ABI, constructors are implemented
as multiple functions:
  C1, the complete object constructor [in-charge]
  C2, the base object constructor [not-in-charge]
  C3, the allocating constructor [not currently used]

Similarly for destructors - most of the rest of this message applies to
destructors too.  The base constructor is generally called for the base
objects of a derived class, esp. with virtual inheritance; it's been a
while since I looked at exactly when.

GCC has chosen to implement this by duplicating the function, including
any user-provided code and any compiler-added code.  A better
implementation would have one copy and labels for multiple entry
points, on systems where that is supported; that's temporarily tabled
pending a better description of the GCC tree structure to describe
multiple entry points.

So the end result is that we start with:
class C {
  public: C();
};

C::C()
{
  // do stuff
}

And there are two copies of that function.  If we use the demangler in
non-verbose mode, we get the same demangled name for both of them:
C::C().  If we use it in verbose mode we get C::C[in-charge]() and
C::C[not-in-charge](), but using verbose mode has other issues for GDB;
it's too verbose/obscure in some places.

So there are two interesting problems:
  - What happens when I say "break C::C"?
  - What happens when I say "break <line>", pointing at the "do stuff"?

So that's the general problem.


Ideally, when we say "break C::C" we will get multiple breakpoints
automatically.  Not to be confused with find_methods/decode_line_2!
We'd still get a menu with two choices if there was a copy constructor
and a default constructor; but choosing either one would place two
breakpoints.

What would this mean for "info breakpoints"?  Would they be one
breakpoint with multiple addresses or visible to the user as two
breakpoints?  I'd prefer the former but I believe there was some
disagreement.  I don't know what current art in other debuggers is;
does anybody?

Similarly when we say "break line", IMO, there should be multiple
breakpoints.  This is even harder; in optimized code we may have
multiple ranges of PC for a particular line even in the same function
(and IMO we should be placing more than one breakpoint in that case);
here we have multiple ranges across different functions.  Placing one
user-visible breakpoint per range would get out of hand pretty fast. 
With the current breakpoint implementation even placing all the
breakpoints would get out of hand pretty fast, since we remove all
breakpoints from memory at each stop.  I think that's fixable.

[Assuming an improved breakpoint layer, can we place a breakpoint on
every possible instruction in a line?  With variable-length
instructions this is very hard; with jump tables in text sections it
might be downright impossible, since we don't know what is code and
what isn't.  Placing a breakpoint at the beginning of every distinct
range, while not perfect, is still an improvement.

However, it's kind of confusing.  Stepping through optimized code you
might hit the "one" breakpoint multiple times.  Bears some thinking
about.]

All of this eventually ties in to debugging inlined functions and
templated functions, which are harder versions of the same thing.

Can't think of anything else at the moment...

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


  reply	other threads:[~2003-04-24 14:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-18 20:04 David Carlton
2003-04-24 14:50 ` Daniel Jacobowitz [this message]
2003-04-24 22:02   ` Paul Koning
2003-04-25  0:30     ` Daniel Jacobowitz
2003-04-29 20:45   ` Paul Koning
2003-04-29 21:24     ` Daniel Jacobowitz
2003-04-30 19:04       ` Michael Eager
2003-04-30 19:11         ` Paul Koning
2003-04-30 19:19         ` Daniel Jacobowitz
2003-04-30  4:36 Michael Elizabeth Chastain
2003-04-30  5:20 ` Daniel Berlin
2003-04-30 14:44 Michael Elizabeth Chastain
2003-05-01  2:13 ` Daniel Berlin
2005-12-15 14:06 Breakpoints " Amit Kale
2005-12-26  7:52 ` Amit Kale
2005-12-27  4:07   ` Jim Blandy

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=20030424145034.GA14226@nevyn.them.org \
    --to=drow@mvista.com \
    --cc=carlton@bactrian.org \
    --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