From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27716 invoked by alias); 24 Jun 2003 02:58:35 -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 15560 invoked from network); 24 Jun 2003 02:53:14 -0000 Received: from unknown (HELO concert.shout.net) (204.253.184.25) by sources.redhat.com with SMTP; 24 Jun 2003 02:53:14 -0000 Received: from duracef.shout.net (duracef.shout.net [204.253.184.12]) by concert.shout.net (8.12.9/8.12.9) with ESMTP id h5O2rDGp022818; Mon, 23 Jun 2003 21:53:13 -0500 Received: from duracef.shout.net (localhost [127.0.0.1]) by duracef.shout.net (8.12.9/8.12.9) with ESMTP id h5O2rDns030725; Mon, 23 Jun 2003 21:53:13 -0500 Received: (from mec@localhost) by duracef.shout.net (8.12.9/8.12.9/Submit) id h5O2rDvc030724; Mon, 23 Jun 2003 22:53:13 -0400 Date: Tue, 24 Jun 2003 02:58:00 -0000 From: Michael Elizabeth Chastain Message-Id: <200306240253.h5O2rDvc030724@duracef.shout.net> To: gdb@sources.redhat.com, mjeng@siue.edu Subject: Re: Breakpoints in constructor/destructor X-SW-Source: 2003-06/txt/msg00467.txt.bz2 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