Re: [GD-Linux] signals and exceptions
Brought to you by:
vexxed72
From: Steve B. <sjb...@ai...> - 2001-11-16 00:31:53
|
Mads Bondo Dydensborg wrote: > I do not mind, but I warn you, it is extremely simplistic: > > #ifdef HAVE_EXECINFO_H > #include <execinfo.h> > #endif > > #include <iostream> > > /* Dump a backtrace to cerr */ > void BackTrace() { > #ifdef HAVE_EXECINFO_H > cerr << "Dumping stacktrace" << endl; > void *aTrace[32]; > char **tString; > int size, i; > size = backtrace(aTrace, 32); > tString = backtrace_symbols(aTrace, size); > for (i = 0; i < size; i++) { > cerr << "In " << tString[i] << endl;; > } > #else > cerr << "No stacktrace available" << endl; > #endif > } > Oooh! That's *really* useful. At work I'm working on a package where one program exec's other programs - and they are all forking lots of threads. Debugging with GDB is *really* hard - but just getting a stack backtrace 'on demand' is a very helpful debug aid. (Hmmm: There don't seem to be any 'man' pages for 'backtrace()' and 'backtrace_symbols()') Is there any way to get the stack backtrace to show line numbers like gdb does? ----------------------------- Steve Baker ------------------------------- Mail : <sjb...@ai...> WorkMail: <sj...@li...> URLs : http://www.sjbaker.org http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net http://freeglut.sf.net http://toobular.sf.net http://lodestone.sf.net |