From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15554 invoked by alias); 10 Sep 2002 03:58:12 -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 15540 invoked from network); 10 Sep 2002 03:58:10 -0000 Received: from unknown (HELO intrex.net) (209.42.192.250) by sources.redhat.com with SMTP; 10 Sep 2002 03:58:10 -0000 Received: from Chrestomanci [209.42.199.186] by intrex.net with ESMTP (SMTPD32-5.05) id ADD424DC0040; Mon, 09 Sep 2002 23:58:12 -0400 Received: from faheem (helo=localhost) by Chrestomanci with local-esmtp (Exim 3.35 #1 (Debian)) id 17oc82-0003FI-00 for ; Mon, 09 Sep 2002 23:55:54 -0400 Date: Mon, 09 Sep 2002 20:58:00 -0000 From: Faheem Mitha X-X-Sender: faheem@Chrestomanci To: gdb@sources.redhat.com Subject: setfault calling functions within gdb Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Declude-Sender: faheem@email.unc.edu [209.42.199.186] X-SW-Source: 2002-09/txt/msg00069.txt.bz2 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)