diff --git a/client/client_msgs.cpp b/client/client_msgs.cpp index acc31a28be..30c5a6976a 100644 --- a/client/client_msgs.cpp +++ b/client/client_msgs.cpp @@ -55,7 +55,7 @@ void show_message( PROJ_AM *p, char* msg, int priority, bool is_html, const char* link ) { const char* x; - char message[1024], event_msg[1024]; + char message[1024], event_msg[1024], evt_message[2048]; char* time_string = time_to_string(gstate.now); // Cycle the log files if needed @@ -119,18 +119,15 @@ void show_message( } else { x = "---"; } - printf("%s [%s] %s\n", time_string, x, message); -#if defined(_WIN32) || defined(ANDROID) - char evt_message[2048]; + // Construct message to be logged/displayed snprintf(evt_message, sizeof(evt_message), "%s [%s] %s\n", time_string, x, message); -#ifdef _WIN32 // print message to the debugger view port - ::OutputDebugString(evt_message); -#endif - -#endif + // print message to the console + printf("%s", evt_message); + // print message to the debugger view port + diagnostics_trace_to_debugger(evt_message); } #endif diff --git a/clientgui/LogBOINC.cpp b/clientgui/LogBOINC.cpp index 1045ce34c8..4192b2030d 100644 --- a/clientgui/LogBOINC.cpp +++ b/clientgui/LogBOINC.cpp @@ -34,7 +34,7 @@ void wxLogBOINC::DoLogText(const wxString& msg) { #ifdef __WXMSW__ wxString strDebug = msg; strDebug += wxT("\r\n"); - ::OutputDebugString(strDebug.c_str()); + diagnostics_trace_to_debugger(strDebug.mb_str()); #endif wxLogStderr::DoLogText(msg); } diff --git a/lib/diagnostics.cpp b/lib/diagnostics.cpp index a0c79ba12d..cb3568f234 100644 --- a/lib/diagnostics.cpp +++ b/lib/diagnostics.cpp @@ -920,3 +920,9 @@ void diagnostics_set_max_file_sizes(int stdout_size, int stderr_size) { if (stderr_size) max_stderr_file_size = stderr_size; } +// Dump string to whatever the platform debuggers +// +#ifndef _WIN32 +int diagnostics_trace_to_debugger(const char*) { +} +#endif \ No newline at end of file diff --git a/lib/diagnostics.h b/lib/diagnostics.h index dd7bf904f2..6ab71d1fbe 100644 --- a/lib/diagnostics.h +++ b/lib/diagnostics.h @@ -108,12 +108,13 @@ extern int diagnostics_update_thread_list(); extern int diagnostics_set_thread_exempt_suspend(); extern int diagnostics_is_thread_exempt_suspend(long thread_id); -// Message Monitoring +// Message Monitoring (debugger viewport) extern int diagnostics_init_message_monitor(); extern int diagnostics_finish_message_monitor(); #ifdef _WIN32 extern UINT WINAPI diagnostics_message_monitor(LPVOID lpParameter); #endif +extern int diagnostics_trace_to_debugger(const char* msg); // Unhandled exception monitor extern int diagnostics_init_unhandled_exception_monitor(); diff --git a/lib/diagnostics_win.cpp b/lib/diagnostics_win.cpp index 1c0c421f8b..e0337b3f46 100644 --- a/lib/diagnostics_win.cpp +++ b/lib/diagnostics_win.cpp @@ -664,7 +664,7 @@ int diagnostics_init_message_monitor() { } diagnostics_monitor_messages.clear(); - // Check the registry to see if we are aloud to capture debugger messages. + // Check the registry to see if we are allowed to capture debugger messages. // Apparently many audio and visual payback programs dump serious // amounts of data to the debugger viewport even on a release build. // When this feature is enabled it slows down the replay of DVDs and CDs @@ -968,6 +968,38 @@ UINT WINAPI diagnostics_message_monitor(LPVOID /* lpParameter */) { } +// Dump a message to the debuggers viewport if we are allowed to. +// +int diagnostics_trace_to_debugger(const char* msg) { + DWORD dwType; + DWORD dwSize; + DWORD dwTraceToViewport; + + // Check the registry to see if we are allowed to dump debugger messages. + // + // We'll turn it off by default, but keep it around just in case we need + // it or want to use it. + // + dwTraceToViewport = 0; + dwType = REG_DWORD; + dwSize = sizeof(dwTraceToViewport); + diagnostics_get_registry_value( + "TraceToViewport", + &dwType, + &dwSize, + (LPBYTE)&dwTraceToViewport + ); + + if (dwTraceToViewport) { + OutputDebugStringA(msg); + } + + return 0; +} + + + + // Structured Exceptions are Windows primary mechanism for dealing with // badly behaved applications or applications where something bad has // happened underneath them and they need to clean up after themselves.