Re: stack trace without core



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

.



Relevant Pages

  • Re: x86 exception handling and stack demand
    ... When an exception occurs that will be passed down to user mode as an SEH exception, the kernel arranges for control to return to user mode at a special function in NTDLL, with several parameters on the stack containing information about the exception. ... In XP and later, the system stores a pointer to the initial stack allocation block in the TEB that is used by the kernel to decommit the stack via NtFreeVirtualMemory when the thread is terminated in a non-graceful fashion, closing this leak. ...
    (microsoft.public.win32.programmer.kernel)
  • [PATCH] x86: style fascism for xen assemblies
    ... * a view to being able to inline as much as possible. ... push %eax ... * This is run where a normal iret would be run, with the same stack setup: ... In order to deliver the nested exception properly, ...
    (Linux-Kernel)
  • RE: System.AccessViolationException in .NET 2.0 application
    ... Based on the call stack, there is an AV exception in the ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.general)
  • Controlled types and exception safety
    ... I can classify the stack's operations by assigning them any of the above four levels, so that I know what can be expected when an exception is thrown for any reason (like inability to allocate more memory, or alike). ... For example, if the Push method of the stack gives me the strong guarantee, then I *know* that by calling this method either the new element will be appended to the stack, or the stack will remain unchanged, so that even if the exception is thrown, I don't have to worry about the stack's internal consistency. ... Since stack can be a dynamic data structure, assigning one stack object to another may involve destroying one existing data structure *and* creating a new one in its place. ...
    (comp.lang.ada)
  • Re: Stop Error: 0x0000007F (0x00000008,0x80042000,0x00000000,0x00000000)
    ... call to the handler for a prior exception. ... double fault. ... A kernel stack overflow. ... One of three types of problems occurred in kernel-mode: Hardware ...
    (microsoft.public.windowsxp.help_and_support)