From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2629 invoked by alias); 23 Jun 2003 19:57:02 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 777 invoked from network); 23 Jun 2003 19:56:38 -0000 Received: from unknown (HELO mail.isg.siue.edu) (146.163.5.4) by sources.redhat.com with SMTP; 23 Jun 2003 19:56:38 -0000 Received: from WEBSHIELD2.isg.siue.edu (webshield2.isg.siue.edu [146.163.5.150]) by mail.isg.siue.edu (8.9.3p2/8.9.3) with SMTP id OAA16194 for ; Mon, 23 Jun 2003 14:56:36 -0500 (CDT) Received: From mail.isg.siue.edu ([146.163.5.4]) by WEBSHIELD2.isg.siue.edu (WebShield SMTP v4.5 MR1a); id 1056398196248; Mon, 23 Jun 2003 14:56:36 -0500 Received: from cougar.isg.siue.edu (cougar [146.163.5.29]) by mail.isg.siue.edu (8.9.3p2/8.9.3) with ESMTP id OAA16149 for ; Mon, 23 Jun 2003 14:56:33 -0500 (CDT) Received: from localhost (mjeng@localhost) by cougar.isg.siue.edu (8.9.3p2/8.9.3) with ESMTP id OAA00850 for ; Mon, 23 Jun 2003 14:56:33 -0500 (CDT) Date: Mon, 23 Jun 2003 19:57:00 -0000 From: MONWHEA JENG To: gdb@sources.redhat.com Subject: Breakpoints in constructor/destructor Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2003-06/txt/msg00463.txt.bz2 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 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; }