Install termination handler to collect additional information for C++ exceptions

This commit is contained in:
Asher Baker 2019-07-20 00:51:47 +00:00
parent 853ba22b0d
commit 8e42daada7
2 changed files with 36 additions and 14 deletions

View File

@ -88,7 +88,6 @@ class SM:
self.compiler.AddToListVar('POSTLINKFLAGS', '-m32')
self.compiler.AddToListVar('POSTLINKFLAGS', '-Wl,-z,defs')
self.compiler.AddToListVar('CXXFLAGS', '-std=c++11')
self.compiler.AddToListVar('CXXFLAGS', '-fno-exceptions')
self.compiler.AddToListVar('CXXFLAGS', '-fno-threadsafe-statics')
self.compiler.AddToListVar('CXXFLAGS', '-Wno-non-virtual-dtor')
self.compiler.AddToListVar('CXXFLAGS', '-Wno-overloaded-virtual')

View File

@ -146,6 +146,27 @@ PluginInfo plugins[256];
#endif
#if defined _LINUX
void terminateHandler()
{
const char *msg = "missing exception";
std::exception_ptr pEx = std::current_exception();
if (pEx) {
try {
std::rethrow_exception(pEx);
} catch(const std::exception &e) {
msg = strdup(e.what());
} catch(...) {
msg = "unknown exception";
}
}
size_t msgLength = strlen(msg) + 2;
volatile char * volatile msgForCrashDumps = (char *)alloca(msgLength);
strcpy((char *)msgForCrashDumps + 1, msg);
abort();
}
void (*SignalHandler)(int, siginfo_t *, void *);
const int kExceptionSignals[] = {
@ -253,6 +274,8 @@ static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
void OnGameFrame(bool simulating)
{
std::set_terminate(terminateHandler);
bool weHaveBeenFuckedOver = false;
struct sigaction oact;