Re: generating stack dump in C++ application??
From: Qasim Zaidi (qasim_zaidi_at_agilent.com)
Date: 06/09/04
- Next message: LEE Sau Dan: "Re: System shutdown using a module, is this feasible"
- Previous message: Daniel Miller: "generating stack dump in C++ application??"
- In reply to: Daniel Miller: "generating stack dump in C++ application??"
- Next in thread: Daniel Miller: "Re: generating stack dump in C++ application??"
- Reply: Daniel Miller: "Re: generating stack dump in C++ application??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
$cat commands
where
detach
quit
This works on my system.
Qasim
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),
> recommended:
>
> sprintf(s, "/bin/echo 'where\ndetach' | gdb /home/m7000/m7600/m7k %d",
> getpid());
>
> 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:
> http://home1.stofanet.dk/breese/debug/debug.tar.gz
> 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
- Next message: LEE Sau Dan: "Re: System shutdown using a module, is this feasible"
- Previous message: Daniel Miller: "generating stack dump in C++ application??"
- In reply to: Daniel Miller: "generating stack dump in C++ application??"
- Next in thread: Daniel Miller: "Re: generating stack dump in C++ application??"
- Reply: Daniel Miller: "Re: generating stack dump in C++ application??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|