public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Michael Elizabeth Chastain <mec@shout.net>
To: gdb@sources.redhat.com, mjeng@siue.edu
Subject: Re: Breakpoints in constructor/destructor
Date: Tue, 24 Jun 2003 02:58:00 -0000	[thread overview]
Message-ID: <200306240253.h5O2rDvc030724@duracef.shout.net> (raw)

I can shed a little light ...

When gcc compiles any constructor or any destructor, it generates *two*
functions in the object code (sometimes three, but I have never seen
three).  This is part of the implementation of virtual base classes in
C++.

These two object code functions have different names for the linker (or
else the program wouldn't even link properly), but gdb thinks that these
functions have the same name, and confusion ensues.  You set a
breakpoint -- it goes into one copy of the function -- but not the
other.  And then your program executes the other one.

Try this: compile your program with "-S" to get assembly code.
Then read the assembly code.  You will see two copies of
'MyNumber::MyNumber' and 'MyNumber::~MyNumber'.  To make the assembly
code easier to visualize, you can call 'APointLessFunction' in the
constructor, and then you can find two object-code functions with calls
to 'APointLessFunction'.

This won't help you set breakpoints in the constructor, but I hope it
will help explain gdb's behavior.

Michael C

             reply	other threads:[~2003-06-24  2:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-24  2:58 Michael Elizabeth Chastain [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-06-23 19:57 MONWHEA JENG
2003-06-23 20:11 ` 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=200306240253.h5O2rDvc030724@duracef.shout.net \
    --to=mec@shout.net \
    --cc=gdb@sources.redhat.com \
    --cc=mjeng@siue.edu \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).