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

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:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-06 15:03 Avi Gozlan [this message]
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

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=9C4E85B61203CD419BB3A638E5F68333D2F050FD81@il-ex01.ad.checkpoint.com \
    --to=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