38 #include "blocxx/BLOCXX_config.h"
43 namespace BLOCXX_NAMESPACE
49 cerr <<
"StackTrace::printStackTrace not implemented yet" << endl;
63 #if defined(BLOCXX_HAVE_BACKTRACE)
67 #if defined(BLOCXX_HAVE_CXXABI_H)
71 #ifdef BLOCXX_HAVE_UNISTD_H
78 namespace BLOCXX_NAMESPACE
85 #ifndef BLOCXX_DEFAULT_GDB_PATH
86 #define BLOCXX_DEFAULT_GDB_PATH "/usr/bin/gdb"
103 #ifdef BLOCXX_HAVE_BACKTRACE
106 size_t size = backtrace (array, 200);
107 char **strings = backtrace_symbols (array, size);
112 for (i = 0; i < size; i++)
114 #if defined(BLOCXX_HAVE_CXXABI_H)
118 char* firstparen = ::strchr(strings[i],
'(');
119 char* lastparen = ::strchr(strings[i],
'+');
120 if (firstparen != 0 && lastparen != 0 && firstparen < lastparen)
124 char* realname = abi::__cxa_demangle(firstparen+1, 0, 0, &status);
142 String scriptName(
"/tmp/owgdb-");
143 String outputName(
"/tmp/owgdbout-");
145 outputName +=
String(UInt32(::getpid()));
146 scriptName +=
String(UInt32(::getpid())) +
".sh";
148 exeName +=
String(UInt32(::getpid())) +
"/exe";
150 ofstream scriptFile(scriptName.
c_str(), std::ios::out);
151 scriptFile <<
"#!/bin/sh\n"
152 <<
"gdb " << exeName <<
" " << ::getpid() <<
" << EOS > " << outputName <<
" 2>&1\n"
163 ifstream outputFile(outputName.
c_str(), std::ios::in);
171 unlink(outputName.
c_str());
172 unlink(scriptName.
c_str());
173 return output.releaseString();
182 #endif // ifdef BLOCXX_WIN32