Revision: | 1491 |
Committed: | Mon Aug 16 18:05:58 2010 UTC (14 years, 8 months ago) by chuckv |
File size: | 432 byte(s) |
Log Message: | Adding debugging and tracing tools from protomol to openmd. |
# | Content |
---|---|
1 | #include "debug/Backtrace.hpp" |
2 | #include "config.h" |
3 | |
4 | #ifdef HAVE_BACKTRACE |
5 | #include <execinfo.h> |
6 | |
7 | using namespace std; |
8 | using namespace OpenMD; |
9 | |
10 | #define MAX_STACK 256 |
11 | |
12 | void Backtrace::getStackTrace(trace_t &trace) { |
13 | void *stack[MAX_STACK]; |
14 | char **strings; |
15 | |
16 | int n = backtrace(stack, MAX_STACK); |
17 | strings = backtrace_symbols(stack, n); |
18 | |
19 | for (int i = 0; i < n; i++) |
20 | trace.push_back(strings[i]); |
21 | } |
22 | #endif // HAVE_BACKTRACE |