From 5957f2d5936341900a5ef824bf8e77db5df16911 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Wed, 16 Mar 2005 20:29:43 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=5670 --- checkin_notes | 13 +++++++ lib/diagnostics.C | 97 +++++++++++++++++++++++++++++++++++++++++++---- lib/diagnostics.h | 91 ++++++++++++++++++++++++++++---------------- 3 files changed, 162 insertions(+), 39 deletions(-) diff --git a/checkin_notes b/checkin_notes index d445ad6f41..e05740fab0 100755 --- a/checkin_notes +++ b/checkin_notes @@ -25989,3 +25989,16 @@ Rom 15 Mar 2005 ViewResources.cpp, .h ViewTransfers.cpp, .h ViewWork.cpp, .h + +Rom 16 Mar 2005 + - Implement the diagnostics functions for platforms other than Windows. + + NOTE: I was working in this area a bit since I'm trying to track down + why E@H isn't always able to display graphics during a start screen saver + request. The changes here and some build environment changes should + now allow us to build a debug E@H application with debug BOINC API + libraries and now see additional information reported to stderr_txt as + the application tries to identify/transition into the calling desktop. + + lib/ + diagnostics.C, .h diff --git a/lib/diagnostics.C b/lib/diagnostics.C index efd5993c0c..7beca020dd 100644 --- a/lib/diagnostics.C +++ b/lib/diagnostics.C @@ -429,7 +429,7 @@ int __cdecl boinc_message_reporting( int reportType, char *szMsg, int *retVal ){ // to the CRT so it can be reported via the normal means. // void boinc_trace(const char *pszFormat, ...) { - static char szBuffer[1024]; + static char szBuffer[4096]; // Trace messages should only be reported if running as a standalone // application or told too. @@ -453,9 +453,8 @@ void boinc_trace(const char *pszFormat, ...) { // Converts the BOINCINFO macro into a single string and report it // to stderr so it can be reported via the normal means. // -void boinc_info_debug(const char *pszFormat, ...) -{ - static char szBuffer[1024]; +void boinc_info_debug(const char *pszFormat, ...){ + static char szBuffer[4096]; memset(szBuffer, 0, sizeof(szBuffer)); @@ -476,9 +475,8 @@ void boinc_info_debug(const char *pszFormat, ...) // Converts the BOINCINFO macro into a single string and report it // to stderr so it can be reported via the normal means. // -void boinc_info_release(const char *pszFormat, ...) -{ - static char szBuffer[1024]; +void boinc_info_release(const char *pszFormat, ...){ + static char szBuffer[4096]; memset(szBuffer, 0, sizeof(szBuffer)); @@ -495,6 +493,91 @@ void boinc_info_release(const char *pszFormat, ...) #endif // _DEBUG + +#else // _WIN32 + + +#ifdef _DEBUG + + +// Converts the BOINCTRACE macro into a single string and report it +// to the CRT so it can be reported via the normal means. +// +void boinc_trace(const char *pszFormat, ...) { + static char szBuffer[4096]; + + // Trace messages should only be reported if running as a standalone + // application or told too. + if ((flags & BOINC_DIAG_TRACETOSTDERR) || + (flags & BOINC_DIAG_TRACETOSTDOUT) ) { + + memset(szBuffer, 0, sizeof(szBuffer)); + + va_list ptr; + va_start(ptr, pszFormat); + + BOINCASSERT( -1 != _vsnprintf(szBuffer, sizeof(szBuffer), pszFormat, ptr) ); + + va_end(ptr); + + if (flags & BOINC_DIAG_TRACETOSTDERR ) { + fprintf( stderr, "TRACE: %s", szBuffer ); + fflush( stderr ); + } + + if (flags & BOINC_DIAG_TRACETOSTDOUT ) { + fprintf( stdout, "TRACE: %s", szBuffer ); + fflush( stdout ); + } + } +} + + +// Converts the BOINCINFO macro into a single string and report it +// to stderr so it can be reported via the normal means. +// +void boinc_info_debug(const char *pszFormat, ...){ + static char szBuffer[4096]; + + memset(szBuffer, 0, sizeof(szBuffer)); + + va_list ptr; + va_start(ptr, pszFormat); + + BOINCASSERT( -1 != _vsnprintf(szBuffer, sizeof(szBuffer), pszFormat, ptr) ); + + va_end(ptr); + + fprintf( stderr, "%s", szBuffer ); + fflush( stderr ); +} + + +#else // _DEBUG + + +// Converts the BOINCINFO macro into a single string and report it +// to stderr so it can be reported via the normal means. +// +void boinc_info_release(const char *pszFormat, ...){ + static char szBuffer[4096]; + + memset(szBuffer, 0, sizeof(szBuffer)); + + va_list ptr; + va_start(ptr, pszFormat); + + _vsnprintf(szBuffer, sizeof(szBuffer), pszFormat, ptr); + + va_end(ptr); + + fprintf( stderr, "%s", szBuffer ); + fflush( stderr ); +} + +#endif // _DEBUG + + #endif // _WIN32 diff --git a/lib/diagnostics.h b/lib/diagnostics.h index d05bf34e5c..8c540fffe2 100644 --- a/lib/diagnostics.h +++ b/lib/diagnostics.h @@ -31,6 +31,10 @@ #include #endif +#ifndef _WIN32 +#include +#endif + // flags for boinc_init_diagnostics() // @@ -54,6 +58,45 @@ #define BOINC_DIAG_STDOUT "stdout" + +#ifdef __cplusplus +extern "C" { +#endif + + +// These are functions common to all platforms +extern int boinc_init_diagnostics(int flags); +extern int boinc_finish_diag(); +extern int boinc_install_signal_handlers(); + +extern int diagnostics_init( + int flags, const char* stdout_prefix, const char* stderr_prefix +); +extern int diagnostics_cycle_logs(); + + +// These are functions that are specific to Unix +#ifndef _WIN32 + +extern void boinc_set_signal_handler(int sig, void(*handler)(int)); +extern void boinc_set_signal_handler_force(int sig, void(*handler)(int)); + +#endif + + +// These functions are used to log the various messages that are +// defined in the BOINC Diagnostics Library +extern void boinc_trace(const char *pszFormat, ...); +extern void boinc_info_debug(const char *pszFormat, ...); +extern void boinc_info_release(const char *pszFormat, ...); + + +#ifdef __cplusplus +} +#endif + + + #ifdef _WIN32 // Define macros for both debug and release builds. @@ -62,11 +105,6 @@ // C Runtime Libraries to trap and report the asserts and traces. // -// Forward declare so we can assign a macro to it. -void boinc_trace(const char *pszFormat, ...); -void boinc_info_debug(const char *pszFormat, ...); -void boinc_info_release(const char *pszFormat, ...); - #ifdef _DEBUG #if defined(WXDEBUG) || defined(WXNDEBUG) @@ -97,19 +135,25 @@ void boinc_info_release(const char *pszFormat, ...); #endif // _DEBUG -#else // non-Win starts here -#include +#else -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus +#ifdef _DEBUG -extern void boinc_set_signal_handler(int sig, void(*handler)(int)); -extern void boinc_set_signal_handler_force(int sig, void(*handler)(int)); +// Standard Frameworks +// + +#define BOINCASSERT assert +#define BOINCTRACE boinc_trace +#define BOINCINFO boinc_info_debug + +#else // _DEBUG + +#define BOINCASSERT(expr) __noop +#define BOINCTRACE __noop +#define BOINCINFO boinc_info_release + +#endif // _DEBUG -#ifdef __cplusplus -} -#endif // __cplusplus #endif // ! _WIN32 @@ -130,21 +174,4 @@ extern void boinc_set_signal_handler_force(int sig, void(*handler)(int)); #define BOINCINFO __noop #endif -#ifdef __cplusplus -extern "C" { -#endif - -extern int boinc_init_diagnostics(int flags); -extern int boinc_finish_diag(); -extern int boinc_install_signal_handlers(); - -extern int diagnostics_init( - int flags, const char* stdout_prefix, const char* stderr_prefix -); -extern int diagnostics_cycle_logs(); - -#ifdef __cplusplus -} -#endif - #endif