Re: generating stack dump in C++ application??
From: Qasim Zaidi (qasim_zaidi_at_agilent.com)
Date: Wed, 09 Jun 2004 10:20:48 +0500
Piping to an interactive program like gdb would not work because the pipe
can't mimic the behavior of stdin that well.
Instead you can do something like
sprintf(s, "gdb /home/m7000/m7600/m7k -x commands %d", getpid());
where commands will be a file containing the gdb commands, such as
This works on my system.
On Tue, 08 Jun 2004 18:22:28 -0500, Daniel Miller wrote:
> I want to generate a stack dump in a C++ program, when it gets a SIGSEGV or
> GPF. I tried searching the archives for this newsgroup, and found a couple
> of suggestions, but none of them return useful results in my application!!
> The Unix Programming FAQ (which hasn't been updated since 2000),
> sprintf(s, "/bin/echo 'where\ndetach' | gdb /home/m7000/m7600/m7k %d",
> When I run this in my signal handler, though, and force a fault by writing
> to a NULL pointer, it loads all the library symbols just fine, but it
> doesn't show anything:
> 0x40207d57 in waitpid () from /lib/libc.so.6
> (gdb) Hangup detected on fd 0
> error detected on stdin
> Detaching from program: /home/m7000/m7600/m7k, process 21304
> caught signal 11
> I also found a stacktrace utility from Bjorn Reese:
> When I run this in STANDALONE mode, it produces a *beautiful* and accurate
> stack dump...
> But when I run it, it *also* shows no stack contents or symbol data.
> I've compiled all my modules with -ggdb, so the data *should* be
> available... And I'm generating the fault from two levels down in function
> calls, so there should be data on the stack.
> Does anyone have any idea what I'm doing wrong?? Is there some simpler way
> to solve this problem??
> Dan Miller