This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: question about SIGTRAP


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<int, std::allocator<int> >::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<int, std::allocator<int> >::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 <signal.h>
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  <function called from gdb>
#3  main () at trap.c:3
(gdb) frame 2
#2  <function called from gdb>
(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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]