ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/debug/Backtrace.cpp
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.

File Contents

# User Rev Content
1 chuckv 1491 #include "debug/Backtrace.hpp"
2     #include "config.h"
3 chuckv 1490
4     #ifdef HAVE_BACKTRACE
5     #include <execinfo.h>
6    
7     using namespace std;
8 chuckv 1491 using namespace OpenMD;
9 chuckv 1490
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