| Revision: | 1490 |
| Committed: | Fri Aug 13 15:02:28 2010 UTC (15 years, 2 months ago) by chuckv |
| File size: | 450 byte(s) |
| Log Message: | Adding some error reporting and debuging code to OpenMD. This code is borrowed from ProtoMol. |
| # | User | Rev | Content |
|---|---|---|---|
| 1 | chuckv | 1490 | #include <protomol/debug/Backtrace.h> |
| 2 | #include <protomol/config.h> | ||
| 3 | |||
| 4 | #ifdef HAVE_BACKTRACE | ||
| 5 | #include <execinfo.h> | ||
| 6 | |||
| 7 | using namespace std; | ||
| 8 | using namespace ProtoMol; | ||
| 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 |