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: SIGTRAP recieved while trying to call C function from GDB


I cannot reproduce this issue in gdb-cvs-head.  AMD64 UBUNTU

(gdb) start
During symbol reading, DW_AT_name missing from DW_TAG_base_type.
Temporary breakpoint 1 at 0x40065c: file 2.c, line 10.
Starting program: /home/teawater/gdb/rec/bgdbno/gdb/a.out

Temporary breakpoint 1, main (argc=
During symbol reading, incomplete CFI data; unspecified registers
(e.g., rax) at 0x400655.
1, argv=0x7fffffffe3b8) at 2.c:10
10	  A *a = new A;
Current language:  auto
The current source language is "auto; currently c++".
(gdb) n
12	  printf("hello, world\n");
(gdb) p atoi("1")
$1 = 1

Thanks,
Hui


2009/9/6 Avi Gozlan <avi@checkpoint.com>:
> 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
>
>


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