From df54f4ac9d864de2891bda9dc4f877ed97d336c3 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Sat, 20 May 2023 06:27:03 -0700 Subject: [PATCH] Mac: update backtrace for MacOS 13.4 --- lib/diagnostics.cpp | 5 ++++- lib/mac/mac_backtrace.cpp | 7 ++++--- mac_build/boinc.xcodeproj/project.pbxproj | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/diagnostics.cpp b/lib/diagnostics.cpp index 5cb9b0554f4..0a2710e4316 100644 --- a/lib/diagnostics.cpp +++ b/lib/diagnostics.cpp @@ -443,11 +443,14 @@ int diagnostics_init( } #endif // ANDROID_VOODOO +// Our PrintBactrace() won't work in MacOS screensaver so let +// the MacOS handle signals and write backtrace to stderr. +#if !(defined (__APPLE__) && defined(SCREENSAVER)) // Install unhandled exception filters and signal traps. if (BOINC_SUCCESS != boinc_install_signal_handlers()) { return ERR_SIGNAL_OP; } - +#endif // Store various pieces of inforation for future use. if (flags & BOINC_DIAG_BOINCAPPLICATION) { diff --git a/lib/mac/mac_backtrace.cpp b/lib/mac/mac_backtrace.cpp index ebcc1e2a123..ddd8aa3dc64 100644 --- a/lib/mac/mac_backtrace.cpp +++ b/lib/mac/mac_backtrace.cpp @@ -199,7 +199,8 @@ void PrintBacktrace(void) { } atosExists = boinc_file_exists("/usr/bin/atos"); - cppfiltExists = boinc_file_exists("/usr/bin/atos"); + cppfiltExists = boinc_file_exists("/usr/bin/c++filt"); + if (atosExists || cppfiltExists) { // The bidirectional popen only works if the NSUnbufferedIO environment // variable is set, so we save and restore its current value. @@ -222,7 +223,7 @@ void PrintBacktrace(void) { #elif defined (__i386__) snprintf(atosPipeBuf, sizeof(atosPipeBuf), "/usr/bin/atos -o \"%s\" -arch i386", pathToThisProcess); #elif defined (__arm64__) - snprintf(atosPipeBuf, sizeof(atosPipeBuf), "/usr/bin/atos -o \"%s\" -arch arm", pathToThisProcess); + snprintf(atosPipeBuf, sizeof(atosPipeBuf), "/usr/bin/atos -o \"%s\" -arch arm64", pathToThisProcess); #else snprintf(atosPipeBuf, sizeof(atosPipeBuf), "/usr/bin/atos -o \"%s\" -arch ppc", pathToThisProcess); #endif @@ -234,7 +235,7 @@ void PrintBacktrace(void) { } if (cppfiltExists) { - cppfiltPipe = popen("/usr/bin/c++filt -s gnu -n", "r+"); + cppfiltPipe = popen("/usr/bin/c++filt --format=gnu -n", "r+"); if (cppfiltPipe) { setbuf(cppfiltPipe, 0); } diff --git a/mac_build/boinc.xcodeproj/project.pbxproj b/mac_build/boinc.xcodeproj/project.pbxproj index 35ab010885c..328f043cf99 100644 --- a/mac_build/boinc.xcodeproj/project.pbxproj +++ b/mac_build/boinc.xcodeproj/project.pbxproj @@ -4779,6 +4779,14 @@ "$(PROJECT_DIR)", ); INFOPLIST_FILE = "ScreenSaver-Info.plist"; + OTHER_CFLAGS = ( + "-D_THREAD_SAFE", + "-DNDEBUG", + "-DSCREENSAVER", + "-DSANDBOX", + "-include", + ../clientgui/mac/config.h, + ); OTHER_LDFLAGS = ( "-framework", Foundation, @@ -4967,6 +4975,14 @@ "$(PROJECT_DIR)", ); INFOPLIST_FILE = "ScreenSaver-Info.plist"; + OTHER_CFLAGS = ( + "-D_THREAD_SAFE", + "-D_DEBUG", + "-DSCREENSAVER", + "-DSANDBOX", + "-include", + ../clientgui/mac/config.h, + ); OTHER_LDFLAGS = ( "-framework", Foundation,