collecting "oobs" message for user applications (WAS: Re: stack trace without core)
- From: RezaRob <RezaRob@xxxxxxxxx>
- Date: Fri, 22 Jun 2007 20:58:22 -0700
On Jun 22, 3:50 pm, David Schwartz <dav...@xxxxxxxxxxxxx> wrote:
On Jun 22, 11:33 am, RezaRob <Reza...@xxxxxxxxx> wrote:
On Jun 22, 7:04 am, Jasen <j...@xxxxxxxxxxx> wrote:
On 2007-06-22, RezaRob <Reza...@xxxxxxxxx> wrote:
Is there a way to generate a brief view of the stack without dumping
entire core?
attach gdb to the process?
This isn't an option because it's in "production mode" and only in the
event of an exception I need a stack trace.
The simplest solution is to 'fork' and have the child call 'abort' to
generate a core dump. There are more complex solutions.
If you dynamically link and keep symbols, you can 'fork' and have the
child dump its stack directly. The idea is to call
'__builtin_return_address' and then call 'dladdr' on the address you
get back.
Note that if you have a real exception, you can't rely on anything
working because your process environment might be corrupt. For
example, after you 'fork', you should probably set all fatal signal
handlers to their default in the child. (You don't want to invoke your
own stack dump routine if the stack dump routine faults!)
DS
Sorry I didn't clarify this: It's okay for the main process to be
killed; however, it's core may be gigabytes huge, and I only want a
small "stack trace."
Really, I want some kind of "oobs!" message, like the one the kernel
dumps. I guess a signal handler can just copy the stack into a "core"
file, but then, how do you prevent gdb from complaining "this is not a
core file?"
Thank you so much for your responses.
Reza.
.
- Follow-Ups:
- References:
- stack trace without core
- From: RezaRob
- Re: stack trace without core
- From: Jasen
- Re: stack trace without core
- From: RezaRob
- Re: stack trace without core
- From: David Schwartz
- stack trace without core
- Prev by Date: Re: stack trace without core
- Next by Date: Re: My way to check if a progam is already running
- Previous by thread: Re: stack trace without core
- Next by thread: Re: collecting "oobs" message for user applications (WAS: Re: stack trace without core)
- Index(es):
Relevant Pages
|