From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9449 invoked by alias); 10 Sep 2002 13:27:56 -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 9442 invoked from network); 10 Sep 2002 13:27:55 -0000 Received: from unknown (HELO crack.them.org) (65.125.64.184) by sources.redhat.com with SMTP; 10 Sep 2002 13:27:55 -0000 Received: from nevyn.them.org ([66.93.61.169] ident=mail) by crack.them.org with asmtp (Exim 3.12 #1 (Debian)) id 17olzg-0005Is-00; Tue, 10 Sep 2002 09:27:57 -0500 Received: from drow by nevyn.them.org with local (Exim 3.35 #1 (Debian)) id 17ol3i-0001gM-00; Tue, 10 Sep 2002 09:28:02 -0400 Date: Tue, 10 Sep 2002 06:27:00 -0000 From: Daniel Jacobowitz To: Faheem Mitha Cc: gdb@sources.redhat.com Subject: Re: setfault calling functions within gdb Message-ID: <20020910132802.GA6062@nevyn.them.org> Mail-Followup-To: Faheem Mitha , gdb@sources.redhat.com References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.1i X-SW-Source: 2002-09/txt/msg00077.txt.bz2 On Mon, Sep 09, 2002 at 11:55:53PM -0400, Faheem Mitha wrote: > > Dear People, > > I'm having problems calling functions from within gdb. Can someone tell me > what I am doing wrong? Consider the following innocuous program > > --------------------------------------------------------- > #include > #include > > using std::vector; > using std::cout; > > typedef vector Point; > void print(Point pt); > > int main() > { > Point foo(3,1.0); > //print(foo); > } > > void print(Point pt) > { > unsigned int i; > cout << "["; > for(i=0; i < pt.size(); i++) > { > cout << pt[i]; > cout << ","; > } > cout << "]"; > } > ----------------------------------------------------------- > > When I set a breakpoint after the definition of foo and call > print(foo) I get a segfault. There appears to be nothing wrong with > this function, since print(foo) when compiled into the function works > as expected. Also, "print foo[0]" works fine. There seem to be two > possibilities; a) I am doing something wrong, b) this is a bug in > gdb. I'm hoping it is the former. I dimly recall calling functions > successfully sometime in the past, but I can't remember whether it was > in C or C++ code. > > Any help would be greatly appreciated. This is really frustrating! > Output from gdb follows. I'm using gdb, gcc-3.0 on Debian Sarge. The > respective versions are Thanks for the great testcase. It may be a couple days before I have time to look at it, but I know roughly what's wrong: we're trying to pass foo as a structure-by-value, as if this were C, and in C++ we are required to do this by the copy constructor. Or something similar. When it calls the destructor, as the argument goes out of scope, it is crashing trying to free something already freed. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer