From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4985 invoked by alias); 10 Sep 2002 06:49:28 -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 4974 invoked from network); 10 Sep 2002 06:49:27 -0000 Received: from unknown (HELO zenia.red-bean.com) (66.244.67.22) by sources.redhat.com with SMTP; 10 Sep 2002 06:49:27 -0000 Received: (from jimb@localhost) by zenia.red-bean.com (8.11.6/8.11.6) id g8A6aFN03090; Tue, 10 Sep 2002 01:36:15 -0500 To: Faheem Mitha Cc: gdb@sources.redhat.com Subject: Re: setfault calling functions within gdb References: From: Jim Blandy Date: Mon, 09 Sep 2002 23:49:00 -0000 In-Reply-To: Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.90 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-09/txt/msg00075.txt.bz2 I don't see anything obviously wrong with what you're doing (although someone is certain to pop up and correct me). Could you file this as a bug report at http://sources.redhat.com/gdb/bugs/, so it won't get lost? Faheem Mitha writes: > 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 > > ii gdb 5.2.cvs20020401-6 The GNU Debugger > ii g++-3.0 3.0.4-9 The GNU C++ compiler. > > I locally compiled the slightly more recent version of gdb from August > which is in unstable, but I get the same behaviour. > > Faheem. > > (gdb) call print(foo) > [ > Program received signal SIGSEGV, Segmentation fault. > 0x0804a1a4 in print(std::vector >) > (pt=0x804f008) at test.cc:22 > The program being debugged was signaled while in a function called > >From GDB. > GDB remains in the frame where the signal was received. > To change this behavior use "set unwindonsignal on" > Evaluation of the expression containing the function > (print(std::vector >)) will be > abandoned. > (gdb)