ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/debug/Backtrace.cpp
Revision: 1490
Committed: Fri Aug 13 15:02:28 2010 UTC (14 years, 8 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.

File Contents

# Content
1 #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