25 #if ( defined( __linux__ ) && defined( __GNUC__ ) )
37 #include <boost/algorithm/string.hpp>
39 #include "WException.h"
60 std::cerr <<
m_headlineColor( std::string(
"Exception thrown! Callstack's backtrace:" ) ) << std::endl <<
getBacktrace() << std::endl;
77 std::cerr <<
m_headlineColor( std::string(
"Exception thrown! Callstack's backtrace:" ) ) << std::endl <<
getBacktrace() << std::endl;
94 std::string result(
what() );
96 std::list< std::string >::const_iterator citer;
98 result +=
"trace: " + *citer +
"\n";
99 boost::trim( result );
106 std::ostringstream o;
108 #if ( defined( __linux__ ) && defined( __GNUC__ ) )
112 const size_t maxDepth = 100;
114 void* stackAddrs[maxDepth];
118 stackDepth = backtrace( stackAddrs, maxDepth );
119 stackSymbols = backtrace_symbols( stackAddrs, stackDepth );
122 for(
size_t i = 1; i < stackDepth; ++i )
126 size_t functionLength = 512;
127 char*
function =
new char[functionLength];
134 for(
char* j = stackSymbols[i]; *j; ++j )
154 char* ret = abi::__cxa_demangle( begin,
function, &functionLength, &status );
164 std::strncpy(
function, begin, functionLength );
165 std::strncat(
function,
"()", functionLength );
166 function[functionLength-1] =
'\0';
187 free( stackSymbols );
189 o <<
"Backtrace not supported on your platform. Currently just works on Linux with GCC. Sorry!";