Re: verbose exception



On Fri, 2006-09-22 at 16:01 -0500, Paul Davis wrote:
> I've know of a guy that did something with similar functionality but a
> better implementation.
> 
> http://www.slamb.org/svn/repos/trunk/projects/atoms/atoms/debug.cc
> 
> This is an implementation of a Backtrace class that can be
> conditionally included in throw exceptions ( He has it compile
> conditional )

c/o glibc, which the vast majority of us are using, i suspect:

void
stacktrace (std::ostream& out)
{
	void *array[200];
	size_t size;
	char **strings;
	size_t i;
     
	size = backtrace (array, 200);
	strings = backtrace_symbols (array, size);
     
	if (strings) {

		for (i = 0; i < size; i++) {
			out << strings[i] << std::endl;
		}
		
		free (strings);
	}
}






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]