trap when throwing exceptions while the program is being debugged
parent
73f5f5fc4b
commit
a6075d7439
|
@ -50,8 +50,17 @@ void Logger::log(ELogLevel level, const Class *theClass,
|
||||||
m_appenders[i]->append(level, text);
|
m_appenders[i]->append(level, text);
|
||||||
m_mutex->unlock();
|
m_mutex->unlock();
|
||||||
} else {
|
} else {
|
||||||
#ifdef MTS_DEBUG_TRAP
|
#if defined(__LINUX__)
|
||||||
|
/* A critical error occurred: trap if we're running in a debugger */
|
||||||
|
|
||||||
|
char exePath[PATH_MAX];
|
||||||
|
pid_t ppid = getppid();
|
||||||
|
memset(exePath, 0, PATH_MAX);
|
||||||
|
if (readlink(formatString("/proc/%i/exe", ppid).c_str(), exePath, PATH_MAX) != -1) {
|
||||||
|
if (!strcmp(exePath, "/usr/bin/gdb")) {
|
||||||
__asm__ ("int $3");
|
__asm__ ("int $3");
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
throw std::runtime_error(text);
|
throw std::runtime_error(text);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue