[host] windows: add OutputDebugString capture for diagnostics

This commit is contained in:
Geoffrey McRae
2024-03-07 11:34:46 +11:00
parent 545e736389
commit eb31815b46
4 changed files with 227 additions and 0 deletions

View File

@@ -21,6 +21,7 @@
#include "platform.h"
#include "service.h"
#include "windows/mousehook.h"
#include "ods.h"
#include <windows.h>
#include <shellapi.h>
@@ -403,6 +404,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
.type = OPTION_TYPE_STRING,
.value.x_string = ""
},
{
.module = "os",
.name = "ods",
.description = "Capture and log OutputDebugString messages",
.type = OPTION_TYPE_BOOL,
.value.x_bool = false
},
{0}
};
@@ -504,6 +512,8 @@ finish:
if (app.taskHandle)
AvRevertMmThreadCharacteristics(app.taskHandle);
ods_stop();
if (app.stdErrFile)
fclose(app.stdErrFile);
@@ -559,6 +569,7 @@ void CALLBACK exitEventCallback(PVOID opaque, BOOLEAN timedOut)
bool app_init(void)
{
const char * logFile = option_get_string("os", "logFile");
const bool ods = option_get_bool ("os", "ods" );
// redirect stderr to a file
if (logFile && strcmp(logFile, "stderr") != 0)
@@ -598,6 +609,9 @@ bool app_init(void)
// always flush stderr
setbuf(stderr, NULL);
if (ods && !ods_start())
DEBUG_WARN("Failed to setup capture of debug messages");
windowsSetTimerResolution();
// get the performance frequency for spinlocks