From 76ecf9dc375b602d5798550cd93e04faf4aa1d2d Mon Sep 17 00:00:00 2001 From: Ivan K Date: Fri, 8 Dec 2023 14:43:13 +0300 Subject: [PATCH 1/2] debugOptions.no_debug_string and catchsegv flag Some applications (MSYS compilers, MiKTeX) output a lot of distracting information via OutputDebugString(). Add a flag to catchsegv to silence it. --- src/catchsegv/catchsegv.cpp | 8 ++++++-- src/common/debugger.cpp | 1 + src/common/debugger.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/catchsegv/catchsegv.cpp b/src/catchsegv/catchsegv.cpp index 88ec6a3..d99b941 100644 --- a/src/catchsegv/catchsegv.cpp +++ b/src/catchsegv/catchsegv.cpp @@ -151,7 +151,8 @@ Usage(void) " -m ignore modal dialogs\n" " -z write minidumps\n" " -Z DIRECTORY write minidumps to specified directory\n" - " -H use debug heap\n", + " -H use debug heap\n" + " -q silence OutputDebugString output\n", stderr); } @@ -264,7 +265,7 @@ wmain(int argc, wchar_t **argv) bool debugHeap = false; while (1) { - int opt = getoptW(argc, argv, L"?1dhHmt:zZ:v"); + int opt = getoptW(argc, argv, L"?1dhHmt:zZ:vq"); switch (opt) { case L'h': @@ -295,6 +296,9 @@ wmain(int argc, wchar_t **argv) debugOptions.minidump = true; debugOptions.minidumpDir = optarg; break; + case L'q': + debugOptions.no_debug_string = true; + break; case L'?': if (optopt == L'?') { Usage(); diff --git a/src/common/debugger.cpp b/src/common/debugger.cpp index 3322f06..3b4d087 100644 --- a/src/common/debugger.cpp +++ b/src/common/debugger.cpp @@ -736,6 +736,7 @@ DebugMainLoop(void) lprintf("OUTPUT_DEBUG_STRING PID=%lu TID=%lu\n", DebugEvent.dwProcessId, DebugEvent.dwThreadId); } + if (debugOptions.no_debug_string) break; pProcessInfo = &g_Processes[DebugEvent.dwProcessId]; diff --git a/src/common/debugger.h b/src/common/debugger.h index ae386f4..7857536 100644 --- a/src/common/debugger.h +++ b/src/common/debugger.h @@ -31,6 +31,7 @@ struct DebugOptions { const wchar_t *minidumpDir = nullptr; HANDLE hEvent = nullptr; // Signal an event after process is attached DWORD dwThreadId = 0; // Resume thread after process is attached + bool no_debug_string = false; // Silence OutputDebugString messages }; EXTERN_C DebugOptions debugOptions; From cff83ba2a19c38a0a2a22e5828d22683e4526141 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Fri, 8 Dec 2023 16:10:35 +0300 Subject: [PATCH 2/2] Reword the -q option description, update README --- README.md | 1 + src/catchsegv/catchsegv.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b3271d0..551b588 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,7 @@ Here's the how to use it: -z write minidumps -Z DIRECTORY write minidumps to specified directory -H use debug heap + -q silence messages from OutputDebugString ## Frequently Asked Questions diff --git a/src/catchsegv/catchsegv.cpp b/src/catchsegv/catchsegv.cpp index d99b941..aa76c24 100644 --- a/src/catchsegv/catchsegv.cpp +++ b/src/catchsegv/catchsegv.cpp @@ -152,7 +152,7 @@ Usage(void) " -z write minidumps\n" " -Z DIRECTORY write minidumps to specified directory\n" " -H use debug heap\n" - " -q silence OutputDebugString output\n", + " -q silence messages from OutputDebugString\n", stderr); }