public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: MONWHEA JENG <mjeng@siue.edu>
To: gdb@sources.redhat.com
Subject: Breakpoints in constructor/destructor
Date: Mon, 23 Jun 2003 19:57:00 -0000	[thread overview]
Message-ID: <Pine.SO4.4.05.10306231456010.787-100000@cougar.isg.siue.edu> (raw)


Hi,

	I just downloaded gdb onto cygwin. I found it pretty
wonderful, but there's one thing I'm completely baffled by. I
can't seem to set breakpoints in constructors or destructors
in my C++ programs. I wrote a simple program that does nothing but
create and destroy a simple object. When I step through it, I can see
my cout statements in the constructors and destructors being called.
But if I set breakpoints at these lines, the gdb doesn't stop there.
The program is reproduced below, but it's pretty simple---there's
not much to see. I read the gdb manual, but saw no mention of 
any special issues related to constructors and destructors. And
I see that there was a thread earlier this year on "breakpoints
in constructors," but unfortunately, I found it incomprehensible.

	Any help would be appreciated. Or, any suggestion on how
I could have figured this out on my own, from the gdb manual
or other source. 

Momo




------------ Program below ------------

#include <iostream>

using std::cout;
using std::cin;
using std::endl;

// ----- START OF CLASS MyNumber -----

class MyNumber{
public:
	MyNumber(int y);
	~MyNumber();
private:
	int x;
};

MyNumber::MyNumber(int y)
{
   cout << "\nConstructor called with number " << y << endl;
   x=y;
}

MyNumber::~MyNumber()
{
   cout << "\nDestructor called for number" << x << endl;
}

// ----- END OF CLASS MyNumber -----

void APointlessFunction(void)
{
   MyNumber c(42);
}

int main()
{
   MyNumber a(100);
   APointlessFunction();
   return 0;
}

             reply	other threads:[~2003-06-23 19:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-23 19:57 MONWHEA JENG [this message]
2003-06-23 20:11 ` Daniel Jacobowitz
2003-06-24  2:58 Michael Elizabeth Chastain

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=Pine.SO4.4.05.10306231456010.787-100000@cougar.isg.siue.edu \
    --to=mjeng@siue.edu \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).