client & MGR: Make writing trace statements to the debugger viewport something you have to opt into on Windows.

I use it a lot, but other developers using BOINC may not care to see BOINC messages while debugging their own stuff.
This commit is contained in:
Rom Walton 2014-03-25 18:23:58 -04:00
parent 8a6b77ef59
commit ba843869a7
5 changed files with 48 additions and 12 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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();

View File

@ -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.