mirror of https://gitee.com/bigwinds/arangodb
fixed inconsistent ifdefs
This commit is contained in:
parent
b9c8972477
commit
21d023b502
|
@ -293,26 +293,27 @@ void TRI_ShutdownDebugging () {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void TRI_GetBacktrace (std::string& btstr) {
|
void TRI_GetBacktrace (std::string& btstr) {
|
||||||
|
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||||
#if HAVE_BACKTRACE
|
#if HAVE_BACKTRACE
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void * stack[100];
|
void* stack[100];
|
||||||
unsigned short frames;
|
unsigned short frames;
|
||||||
SYMBOL_INFO * symbol;
|
SYMBOL_INFO* symbol;
|
||||||
HANDLE process;
|
HANDLE process;
|
||||||
|
|
||||||
process = GetCurrentProcess();
|
process = GetCurrentProcess();
|
||||||
|
|
||||||
SymInitialize(process, nullptr, true);
|
SymInitialize(process, nullptr, true);
|
||||||
|
|
||||||
frames = CaptureStackBackTrace(0, 100, stack, nullptr);
|
frames = CaptureStackBackTrace(0, 100, stack, nullptr);
|
||||||
symbol = (SYMBOL_INFO*) calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1);
|
symbol = (SYMBOL_INFO*) calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1);
|
||||||
|
|
||||||
if (symbol == nullptr) {
|
if (symbol == nullptr) {
|
||||||
// cannot allocate memory
|
// cannot allocate memory
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol->MaxNameLen = 255;
|
symbol->MaxNameLen = 255;
|
||||||
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
|
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < frames; i++) {
|
for (unsigned int i = 0; i < frames; i++) {
|
||||||
|
@ -327,12 +328,12 @@ void TRI_GetBacktrace (std::string& btstr) {
|
||||||
|
|
||||||
#else
|
#else
|
||||||
void* stack_frames[50];
|
void* stack_frames[50];
|
||||||
size_t size, i;
|
|
||||||
char** strings;
|
char** strings;
|
||||||
|
|
||||||
size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
|
size_t size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
|
||||||
strings = backtrace_symbols(stack_frames, size);
|
char** strings = backtrace_symbols(stack_frames, size);
|
||||||
for (i = 0; i < size; i++) {
|
|
||||||
|
for (size_t i = 0; i < size; i++) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
if (strings != nullptr) {
|
if (strings != nullptr) {
|
||||||
char *mangled_name = nullptr, *offset_begin = nullptr, *offset_end = nullptr;
|
char *mangled_name = nullptr, *offset_begin = nullptr, *offset_end = nullptr;
|
||||||
|
@ -394,34 +395,26 @@ void TRI_GetBacktrace (std::string& btstr) {
|
||||||
*offset_begin++ = '\0';
|
*offset_begin++ = '\0';
|
||||||
*offset_end++ = '\0';
|
*offset_end++ = '\0';
|
||||||
int status = 0;
|
int status = 0;
|
||||||
char * demangled_name = abi::__cxa_demangle(mangled_name, 0, 0, &status);
|
char* demangled_name = abi::__cxa_demangle(mangled_name, 0, 0, &status);
|
||||||
|
|
||||||
if (demangled_name != nullptr) {
|
if (demangled_name != nullptr) {
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
ss << stack_frames[i];
|
ss << stack_frames[i];
|
||||||
btstr += strings[i] +
|
btstr += strings[i] + std::string("() [") + ss.str() + std::string("] ") + demangled_name + std::string("\n");
|
||||||
std::string("() [") +
|
|
||||||
ss.str() +
|
|
||||||
std::string("] ") +
|
|
||||||
demangled_name +
|
|
||||||
std::string("\n");
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
btstr += strings[i] +
|
btstr += strings[i] + std::string("\n");
|
||||||
std::string("\n");
|
|
||||||
}
|
}
|
||||||
TRI_SystemFree(demangled_name);
|
TRI_SystemFree(demangled_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
btstr += strings[i] +
|
btstr += strings[i] + std::string("\n");
|
||||||
std::string("\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ss << stack_frames[i];
|
ss << stack_frames[i];
|
||||||
btstr += ss.str() +
|
btstr += ss.str() + std::string("\n");
|
||||||
std::string("\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strings != nullptr) {
|
if (strings != nullptr) {
|
||||||
|
@ -429,6 +422,7 @@ void TRI_GetBacktrace (std::string& btstr) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -436,11 +430,13 @@ void TRI_GetBacktrace (std::string& btstr) {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void TRI_PrintBacktrace () {
|
void TRI_PrintBacktrace () {
|
||||||
|
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||||
#if HAVE_BACKTRACE
|
#if HAVE_BACKTRACE
|
||||||
std::string out;
|
std::string out;
|
||||||
TRI_GetBacktrace(out);
|
TRI_GetBacktrace(out);
|
||||||
fprintf(stderr, "%s", out.c_str());
|
fprintf(stderr, "%s", out.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue