diff --git a/src/os/macosx/crashlog_osx.cpp b/src/os/macosx/crashlog_osx.cpp index 5d7c9993b1..b26e028952 100644 --- a/src/os/macosx/crashlog_osx.cpp +++ b/src/os/macosx/crashlog_osx.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #ifdef WITH_UCONTEXT #include #endif @@ -385,13 +386,12 @@ public: } /** Generate the crash log. */ - bool MakeCrashLog() + bool MakeOSXCrashLog(char *buffer, const char *last) { - char buffer[65536 * 4]; bool ret = true; printf("Crash encountered, generating crash log...\n"); - this->FillCrashLog(buffer, lastof(buffer)); + this->FillCrashLog(buffer, last); printf("%s\n", buffer); printf("Crash log generated.\n\n"); @@ -419,6 +419,12 @@ public: return ret; } + bool MakeOSXCrashLogWithStackBuffer() + { + char buffer[65536]; + return this->MakeOSXCrashLog(buffer, lastof(buffer)); + } + /** Show a dialog with the crash information. */ void DisplayCrashDialog() const { @@ -461,7 +467,15 @@ void CDECL HandleCrash(int signum, siginfo_t *si, void *context) } CrashLogOSX log(signum, si, context); - log.MakeCrashLog(); + + const size_t length = 65536 * 16; + char *buffer = (char *)mmap(nullptr, length, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); + if (buffer != MAP_FAILED) { + log.MakeOSXCrashLog(buffer, buffer + length - 1); + } else { + log.MakeOSXCrashLogWithStackBuffer(); + } + if (VideoDriver::GetInstance() == nullptr || VideoDriver::GetInstance()->HasGUI()) { log.DisplayCrashDialog(); }