Subject: Application stack trace facility

From: Krishna Kondaka <[email-masked]>
Date: Tue, 19 Mar 2002 12:13:54 -0800 (PST)

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

---

From: Johannes Stezenbach <[email-masked]>
Date: Wed, 20 Mar 2002 14:01:20 +0100

> 	available in linux which prints the current stack trace of the 

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