public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* question about SIGTRAP
@ 2012-08-02  1:32 John Smith
  2012-08-04 19:17 ` Jan Kratochvil
  0 siblings, 1 reply; 2+ messages in thread
From: John Smith @ 2012-08-02  1:32 UTC (permalink / raw)
  To: gdb

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?


thank you
!

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: question about SIGTRAP
  2012-08-02  1:32 question about SIGTRAP John Smith
@ 2012-08-04 19:17 ` Jan Kratochvil
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kratochvil @ 2012-08-04 19:17 UTC (permalink / raw)
  To: John Smith; +Cc: gdb

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-04 19:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-02  1:32 question about SIGTRAP John Smith
2012-08-04 19:17 ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).