|
|
@ -88,29 +88,30 @@ namespace mrw { |
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
mrw::StackTrace::StackTrace() throw(std::bad_exception) { |
|
|
|
mrw::StackTrace::StackTrace() throw(std::bad_exception) { |
|
|
|
// maximum trace level is limited here to 50, see below why
|
|
|
|
// maximum trace level is limited here to 50, see below why
|
|
|
|
# if defined(__GNUG__) |
|
|
|
# if defined(__GLIBC__) |
|
|
|
{ |
|
|
|
|
|
|
|
# define PUSH(i) \ |
|
|
|
|
|
|
|
(__builtin_frame_address(i)!=0 ? \
|
|
|
|
|
|
|
|
(_trace.push_back(__builtin_return_address(i)), true) : false) |
|
|
|
|
|
|
|
PUSH(0) && PUSH(1) && PUSH(2) && PUSH(3) && PUSH(4) && PUSH(5) && |
|
|
|
|
|
|
|
PUSH(6) && PUSH(7) && PUSH(8) && PUSH(9) && PUSH(10) && PUSH(11) && |
|
|
|
|
|
|
|
PUSH(12) && PUSH(13) && PUSH(14) && PUSH(15) && PUSH(16) && PUSH(17) |
|
|
|
|
|
|
|
&& PUSH(18) && PUSH(19) && PUSH(20) && PUSH(21) && PUSH(22) && |
|
|
|
|
|
|
|
PUSH(23) && PUSH(24) && PUSH(25) && PUSH(26) && PUSH(27) && PUSH(28) |
|
|
|
|
|
|
|
&& PUSH(29) && PUSH(30) && PUSH(31) && PUSH(32) && PUSH(33) && |
|
|
|
|
|
|
|
PUSH(34) && PUSH(35) && PUSH(36) && PUSH(37) && PUSH(38) && PUSH(39) |
|
|
|
|
|
|
|
&& PUSH(40) && PUSH(41) && PUSH(42) && PUSH(43) && PUSH(44) && |
|
|
|
|
|
|
|
PUSH(45) && PUSH(46) && PUSH(47) && PUSH(48) && PUSH(49); |
|
|
|
|
|
|
|
# undef PUSH |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
# elif defined(__GLIBC__) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
const int TRACE_LEVEL(50); |
|
|
|
const int TRACE_LEVEL(50); |
|
|
|
void* ba[TRACE_LEVEL]; |
|
|
|
void* ba[TRACE_LEVEL]; |
|
|
|
for (int n(backtrace(ba, TRACE_LEVEL)), i(0); i<n; ++i) |
|
|
|
for (int n(backtrace(ba, TRACE_LEVEL)), i(0); i<n; ++i) |
|
|
|
_trace.push_back(ba[i]); |
|
|
|
_trace.push_back(ba[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// crash ...?
|
|
|
|
|
|
|
|
// # elif defined(__GNUG__)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// # define PUSH(i) \
|
|
|
|
|
|
|
|
// (__builtin_frame_address(i)!=0 ? \
|
|
|
|
|
|
|
|
// (_trace.push_back(__builtin_return_address(i)), true) : false)
|
|
|
|
|
|
|
|
// PUSH(0) && PUSH(1) && PUSH(2) && PUSH(3) && PUSH(4) && PUSH(5) &&
|
|
|
|
|
|
|
|
// PUSH(6) && PUSH(7) && PUSH(8) && PUSH(9) && PUSH(10) && PUSH(11) &&
|
|
|
|
|
|
|
|
// PUSH(12) && PUSH(13) && PUSH(14) && PUSH(15) && PUSH(16) && PUSH(17)
|
|
|
|
|
|
|
|
// && PUSH(18) && PUSH(19) && PUSH(20) && PUSH(21) && PUSH(22) &&
|
|
|
|
|
|
|
|
// PUSH(23) && PUSH(24) && PUSH(25) && PUSH(26) && PUSH(27) && PUSH(28)
|
|
|
|
|
|
|
|
// && PUSH(29) && PUSH(30) && PUSH(31) && PUSH(32) && PUSH(33) &&
|
|
|
|
|
|
|
|
// PUSH(34) && PUSH(35) && PUSH(36) && PUSH(37) && PUSH(38) && PUSH(39)
|
|
|
|
|
|
|
|
// && PUSH(40) && PUSH(41) && PUSH(42) && PUSH(43) && PUSH(44) &&
|
|
|
|
|
|
|
|
// PUSH(45) && PUSH(46) && PUSH(47) && PUSH(48) && PUSH(49);
|
|
|
|
|
|
|
|
// # undef PUSH
|
|
|
|
|
|
|
|
// }
|
|
|
|
# else |
|
|
|
# else |
|
|
|
# warning "You need GNU gcc or GNU glibc to be able to use mrw::StackTrace" |
|
|
|
# warning "You need GNU gcc or GNU glibc to be able to use mrw::StackTrace" |
|
|
|
# endif |
|
|
|
# endif |
|
|
|