Skip to content

Commit

Permalink
Merge pull request #5245 from BOINC/mac_fix_backtrace
Browse files Browse the repository at this point in the history
  • Loading branch information
AenBleidd authored May 20, 2023
2 parents 051eb73 + df54f4a commit 56b3346
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 4 additions & 3 deletions lib/mac/mac_backtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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);
}
Expand Down
16 changes: 16 additions & 0 deletions mac_build/boinc.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 56b3346

Please sign in to comment.