From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20502 invoked by alias); 4 Aug 2012 19:17:33 -0000 Received: (qmail 20494 invoked by uid 22791); 4 Aug 2012 19:17:32 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 04 Aug 2012 19:17:18 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q74JHHEu029262 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 4 Aug 2012 15:17:17 -0400 Received: from host2.jankratochvil.net (ovpn-116-17.ams2.redhat.com [10.36.116.17]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q74JHDpk027224 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Sat, 4 Aug 2012 15:17:16 -0400 Date: Sat, 04 Aug 2012 19:17:00 -0000 From: Jan Kratochvil To: John Smith Cc: gdb@sourceware.org Subject: Re: question about SIGTRAP Message-ID: <20120804191709.GA26896@host2.jankratochvil.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00007.txt.bz2 On Thu, 02 Aug 2012 03:32:16 +0200, John Smith wrote: > hi.when I print a vector element using operator [ ],gdb show me this : > > Program received signal SIGTRAP, Trace/breakpoint trap. > 0x08048a0b in std::vector >::operator[] > (this=0xbfffde70, __n=0) at > /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:479 > 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 > (std::vector >::operator[](unsigned int)) > will be abandoned. > When the function is done executing, GDB will silently stop. > > then it is trapped into the stl library,and I can not go out . > > how can I deal with this? Problem (1) is that it did SIGTRAP. Without a reproducer I cannot say more. It just calls inferior function, which may crash. As a suggestion at least gcc-4.1.2 is very old, it is recommended to upgrade. Problem (2) if you need to just discard any failed inferior call you can use 'return' for it (see below). But sure nobody guarantees what the inferior call could cause to the inferior state in the meantime. Regards, Jan (gdb) l 1 1 #include 2 void f (void) { raise (SIGTRAP); } 3 int main (void) { return 0; } (gdb) start (gdb) p f() Program received signal SIGTRAP, Trace/breakpoint trap. 0x00007ffff7a5a285 in __GI_raise (sig=5) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 64 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig); 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 (f) will be abandoned. When the function is done executing, GDB will silently stop. (gdb) bt #0 0x00007ffff7a5a285 in __GI_raise (sig=5) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 #1 0x00000000004004d2 in f () at trap.c:2 #2 #3 main () at trap.c:3 (gdb) frame 2 #2 (gdb) return Make selected stack frame return now? (y or n) y #0 main () at trap.c:3 3 int main (void) { return 0; } (gdb) bt #0 main () at trap.c:3