38 #include "blocxx/BLOCXX_config.h" 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 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
BLOCXX_COMMON_API int flush(FileHandle &hdl)
Flush any buffered data to the file if buffering supported.
This String class is an abstract data type that represents as NULL terminated string of characters...
#define BLOCXX_DEFAULT_GDB_PATH
Process::Status system(const Array< String > &command, const char *const envp[], const Timeout &timeout)
Execute a command.
static String getLine(std::istream &istr)
Reads from in input stream until a newline is encountered.
const char * c_str() const
BLOCXX_COMMON_API String getStackTrace(EDoStackTraceFlag=E_NO_CHECK_ENV_VAR)
void push_back(const T &x)
Append an element to the end of the Array.
BLOCXX_COMMON_API void printStackTrace(EDoStackTraceFlag=E_CHECK_ENV_VAR)