Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Hui Zhu <teawater@gmail.com>
To: Avi Gozlan <avi@checkpoint.com>
Cc: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: SIGTRAP recieved while trying to call C function from GDB
Date: Sun, 06 Sep 2009 15:13:00 -0000	[thread overview]
Message-ID: <daef60380909060813h5b20634erce7dfa0e9209d86a@mail.gmail.com> (raw)
In-Reply-To: <9C4E85B61203CD419BB3A638E5F68333D2F050FD81@il-ex01.ad.checkpoint.com>

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
>
>


  reply	other threads:[~2009-09-06 15:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-06 15:03 Avi Gozlan
2009-09-06 15:13 ` Hui Zhu [this message]
2009-09-06 15:26 ` Daniel Jacobowitz
2009-09-08 10:31   ` Avi Gozlan
2009-09-08 19:21     ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=daef60380909060813h5b20634erce7dfa0e9209d86a@mail.gmail.com \
    --to=teawater@gmail.com \
    --cc=avi@checkpoint.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox