Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* SIGTRAP recieved while trying to call C function from GDB
@ 2009-09-06 15:03 Avi Gozlan
  2009-09-06 15:13 ` Hui Zhu
  2009-09-06 15:26 ` Daniel Jacobowitz
  0 siblings, 2 replies; 5+ messages in thread
From: Avi Gozlan @ 2009-09-06 15:03 UTC (permalink / raw)
  To: gdb; +Cc: Avi Gozlan

Hello,

We get SIGTRAP when trying to call C functions in GDB prompt. Following is an example program:

#include <stdio.h>

class A{
public:
  A() {}
};

int main(int argc, char **argv)
{
  A *a = new A;

  printf("hello, world\n");
}

Scenario:
1. Run gdb a.out 
2. b main 
3. r 
4. n (GDB stops prior to the printf() call) 
5. p atoi(“1”) 

(gdb) p atoi(“1”)

Program received signal SIGTRAP, Trace/breakpoint trap.
0x004b7411 in malloc () from /lib/ld-linux.so.2
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 (malloc) will be abandoned.
(gdb)

This does not happen if calling ‘p atoi(“1”)’ immediately when running the program or following the printf() function call.

GDB version: 6.8
Linux Release: Red Hat Enterprise Linux Server release 5.1 (Tikanga)
Kernel version: 2.6.18-53.1.13.el5PAE
Compiler: either gcc 4.1.2 20070626 or gcc 3.2.3 20030502
Compilation command: gcc –g –l stdc++   myprog.cc

Thanks,

Avi


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

end of thread, other threads:[~2009-09-08 19:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-06 15:03 SIGTRAP recieved while trying to call C function from GDB Avi Gozlan
2009-09-06 15:13 ` Hui Zhu
2009-09-06 15:26 ` Daniel Jacobowitz
2009-09-08 10:31   ` Avi Gozlan
2009-09-08 19:21     ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox