Application stack trace facility
Hi,
I would like to know if there is a system call/library function
available in linux which prints the current stack trace of the
application.
For ex.,
If main() calls a() which calls b() which in turn calls c() and if
c() is defined as
c()
{
....
if (condition)
dump_stack_trac();
....
}
the dump_stack_trace() should print if the "condition" is true -
c(...)
b(...)
a(...)
main(..)
Is there such "dump_stack_trace" library function/system call available?
I know that if I make the program dump core in the dump_stack_trace
function then I can get the stack trace from the core dump but I would
like to know if I can do this without forcing the core dump.TIA
Krishna Kondaka
Sanera Systems
Quoted 3 lines · Krishna Kondaka
I would like to know if there is a system call/library function available in linux which prints the current stack trace of the application.
The Glib has a function g_on_error_stack_trace() which does this in a slightly hackish way by attaching gdb to the crashed program (to be called from a SIGSEGV handler).
Look at gbacktrace.c there:
http://cvs.gnome.org/bonsai/rview.cgi?cvsroot=/cvs/gnome&dir=glib/glib&module=.
HTH,
Johannes