From 229650ec1592bcc0e1e6867234def875d4d88302 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Fri, 5 Sep 2008 02:47:10 +0000 Subject: [PATCH] SCR: Fix trace statements in screensaver.cpp; enable diagnostics in Mac screensaver svn path=/trunk/boinc/; revision=15967 --- checkin_notes | 13 +++++++++++ clientscr/Mac_Saver_Module.h | 5 ++++- clientscr/Mac_Saver_ModuleView.m | 4 +++- clientscr/mac_saver_module.cpp | 27 +++++++++++++++++++++-- clientscr/screensaver.cpp | 9 +++++--- mac_build/boinc.xcodeproj/project.pbxproj | 17 ++++++++++++-- 6 files changed, 66 insertions(+), 9 deletions(-) diff --git a/checkin_notes b/checkin_notes index 15401f444b..322ca7e9c7 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7214,3 +7214,16 @@ David 4 Sep 2008 lib/ crypt.C,h crypt_prog.C + +Charlie 4 Sep 2008 + SCR: Fix trace statements in screensaver.cpp; enable diagnostics in + Mac screensaver. + + clientscr/ + mac_saver_module.cpp + Mac_Saver_Module.h + Mac_Saver_ModuleView.m + screensaver.cpp + mac_build/ + boinc.xcodeproj/ + project.pbxproj diff --git a/clientscr/Mac_Saver_Module.h b/clientscr/Mac_Saver_Module.h index da68c49942..7eb91e684c 100644 --- a/clientscr/Mac_Saver_Module.h +++ b/clientscr/Mac_Saver_Module.h @@ -24,7 +24,9 @@ #include - +#ifdef _DEBUG + #define _T(x) x +#endif #ifdef __cplusplus extern "C" { @@ -36,6 +38,7 @@ void drawPreview(CGContextRef myContext); void closeBOINCSaver(void); void print_to_log_file(const char *format, ...); void strip_cr(char *buf); +void PrintBacktrace(void); #ifdef __cplusplus } // extern "C" diff --git a/clientscr/Mac_Saver_ModuleView.m b/clientscr/Mac_Saver_ModuleView.m index bf04df45f3..3bbcc2e780 100644 --- a/clientscr/Mac_Saver_ModuleView.m +++ b/clientscr/Mac_Saver_ModuleView.m @@ -211,7 +211,9 @@ int signof(float x) { NSRect windowFrame = [ myWindow frame ]; if ( (windowFrame.origin.x != 0) || (windowFrame.origin.y != 0) ) { // Hide window on second display to aid in debugging -// [[[ NSView focusView] window ] setLevel:kCGMinimumWindowLevel ]; +#ifdef _DEBUG + [[[ NSView focusView] window ] setLevel:kCGMinimumWindowLevel ]; +#endif return; // We draw only to main screen } diff --git a/clientscr/mac_saver_module.cpp b/clientscr/mac_saver_module.cpp index 4c2d8da6df..8089d97988 100644 --- a/clientscr/mac_saver_module.cpp +++ b/clientscr/mac_saver_module.cpp @@ -37,7 +37,8 @@ #include "util.h" #include "Mac_Saver_Module.h" #include "screensaver.h" - +#include "diagnostics.h" + //#include // It would be nice to always display the scrolled progress info in case the @@ -96,6 +97,19 @@ const char * ScreenSaverAppStartingMsg = "Starting screensaver graphics.\nPleas // Returns desired Animation Frequency (per second) or 0 for no change int initBOINCSaver(Boolean ispreview) { +#ifdef _DEBUG + char buf1[256], buf2[256]; + strcpy(buf1, getenv("HOME")); + strcat(buf1, "/Documents/ss_stdout"); + strcpy(buf2, getenv("HOME")); + strcat(buf2, "/Documents/ss_stderr"); + + diagnostics_init(BOINC_DIAG_REDIRECTSTDOUTOVERWRITE + | BOINC_DIAG_REDIRECTSTDERROVERWRITE + | BOINC_DIAG_TRACETOSTDOUT, buf1, buf2 + ); +#endif + if (ispreview) return 8; @@ -166,6 +180,10 @@ int CScreensaver::Create() { // occur when the screensaver is run normally (from the screensaver // engine.) So we just display a message and don't access the core // client. + // With V6 graphics when using gfx_switcher, the graphics application + // fails to run and stderr shows the message: + // "The process has forked and you cannot use this CoreFoundation + // functionality safely. You MUST exec()" GetCurrentProcess(&psn); memset(&pInfo, 0, sizeof(pInfo)); pInfo.processInfoLength = sizeof( ProcessInfoRec ); @@ -315,8 +333,9 @@ int CScreensaver::getSSMessage(char **theMessage, int* coveredFreq) { // Take care of the possible race condition where the Core Client was in the // process of shutting down just as ScreenSaver started, so initBOINCApp() // found it already running but now it has shut down. - if (m_wasAlreadyRunning) // If we launched it, then just wait for it to start + if (m_wasAlreadyRunning) { // If we launched it, then just wait for it to start saverState = SaverState_RelaunchCoreClient; + } break; case SaverState_CoreClientRunning: @@ -773,4 +792,8 @@ void strip_cr(char *buf) *theCR = '\0'; } #endif // CREATE_LOG + +void PrintBacktrace(void) { +} + const char *BOINC_RCSID_7ce0778d35="$Id$"; diff --git a/clientscr/screensaver.cpp b/clientscr/screensaver.cpp index 5ecad640f5..545db66a51 100644 --- a/clientscr/screensaver.cpp +++ b/clientscr/screensaver.cpp @@ -442,7 +442,8 @@ void *CScreensaver::DataManagementProc() { // V6 graphics only: if worker application has stopped running, terminate_screensaver if ((graphics_app_result_ptr == NULL) && (m_hGraphicsApplication != 0)) { if (previous_result_ptr) { - BOINCTRACE(_T("CScreensaver::DataManagementProc - %s finished\n"), previous_result.name.c_str()); + BOINCTRACE(_T("CScreensaver::DataManagementProc - %s finished\n"), + previous_result.graphics_exec_path.c_str()); } terminate_screensaver(m_hGraphicsApplication, previous_result_ptr); previous_result_ptr = NULL; @@ -452,7 +453,8 @@ void *CScreensaver::DataManagementProc() { if (last_change_time && ((dtime() - last_change_time) > GFX_CHANGE_PERIOD)) { if (count_active_graphic_apps(results, previous_result_ptr) > 0) { if (previous_result_ptr) { - BOINCTRACE(_T("CScreensaver::DataManagementProc - time to change: %s\n"), previous_result.name.c_str()); + BOINCTRACE(_T("CScreensaver::DataManagementProc - time to change: %s / %s\n"), + previous_result.name.c_str(), previous_result.graphics_exec_path.c_str()); } terminate_screensaver(m_hGraphicsApplication, graphics_app_result_ptr); if (m_hGraphicsApplication == 0) { @@ -491,7 +493,8 @@ void *CScreensaver::DataManagementProc() { previous_result = *graphics_app_result_ptr; previous_result_ptr = &previous_result; if (previous_result_ptr) { - BOINCTRACE(_T("CScreensaver::DataManagementProc - launching %s\n"), previous_result.name.c_str()); + BOINCTRACE(_T("CScreensaver::DataManagementProc - launching %s\n"), + previous_result.graphics_exec_path.c_str()); } } } else { diff --git a/mac_build/boinc.xcodeproj/project.pbxproj b/mac_build/boinc.xcodeproj/project.pbxproj index 9af2122ebd..dca545a6fe 100755 --- a/mac_build/boinc.xcodeproj/project.pbxproj +++ b/mac_build/boinc.xcodeproj/project.pbxproj @@ -183,6 +183,7 @@ DD67F8140ADB9DD000B0015E /* wxPieCtrl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD40E75D0ADB87BC00214518 /* wxPieCtrl.cpp */; }; DD6802300E701ACD0067D009 /* cert_sig.C in Sources */ = {isa = PBXBuildFile; fileRef = DD68022E0E701ACD0067D009 /* cert_sig.C */; }; DD6802310E701ACD0067D009 /* cert_sig.C in Sources */ = {isa = PBXBuildFile; fileRef = DD68022E0E701ACD0067D009 /* cert_sig.C */; }; + DD6803440E70A61D0067D009 /* diagnostics.C in Sources */ = {isa = PBXBuildFile; fileRef = DD344BA207C5AE5A0043025C /* diagnostics.C */; }; DD69FEF508416C6B00C01361 /* gui_rpc_client.C in Sources */ = {isa = PBXBuildFile; fileRef = DD81C5CC07C5D7D90098A04D /* gui_rpc_client.C */; }; DD69FEF708416C9A00C01361 /* boinc_cmd.C in Sources */ = {isa = PBXBuildFile; fileRef = DD69FEF608416C9A00C01361 /* boinc_cmd.C */; }; DD69FF0C084171CF00C01361 /* network.C in Sources */ = {isa = PBXBuildFile; fileRef = DD6D0A8507E9A61B007F882B /* network.C */; }; @@ -2406,6 +2407,7 @@ DDB873990C85072500E0DE1F /* mac_saver_module.cpp in Sources */, DDB8739A0C85072500E0DE1F /* Mac_Saver_ModuleView.m in Sources */, DD7AEB4A0C87CE1300AC3B5C /* screensaver.cpp in Sources */, + DD6803440E70A61D0067D009 /* diagnostics.C in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4266,11 +4268,22 @@ OTHER_CFLAGS = ( "-DMAC_OS_X_VERSION_MAX_ALLOWED=1040", "-D_THREAD_SAFE", + "-D_DEBUG", "-include", ../clientgui/mac/config.h, ); - OTHER_CFLAGS_i386 = "-DMAC_OS_X_VERSION_MAX_ALLOWED=1040 -D_THREAD_SAFE -include ../clientgui/mac/config.h"; - OTHER_CFLAGS_ppc = "-DMAC_OS_X_VERSION_MAX_ALLOWED=1030 -D_THREAD_SAFE -include ../clientgui/mac/config.h"; + "OTHER_CFLAGS[arch=x86_64]" = ( + "-DMAC_OS_X_VERSION_MAX_ALLOWED=1050", + "-D_THREAD_SAFE", + "-DDEBUG", + "-D_DEBUG", + "-DSANDBOX", + "-include", + ../clientgui/mac/config.h, + ); + OTHER_CFLAGS_i386 = "-DMAC_OS_X_VERSION_MAX_ALLOWED=1040 -D_THREAD_SAFE -D_DEBUG -include ../clientgui/mac/config.h"; + OTHER_CFLAGS_ppc = "-DMAC_OS_X_VERSION_MAX_ALLOWED=1030 -D_THREAD_SAFE -D_DEBUG -include ../clientgui/mac/config.h"; + OTHER_CFLAGS_x86_64 = "-DMAC_OS_X_VERSION_MAX_ALLOWED=1050 -D_THREAD_SAFE -D_DEBUG -DSANDBOX -include ../clientgui/mac/config.h"; OTHER_LDFLAGS = ( "-framework", Foundation,