Skip to content

Commit

Permalink
Add an option to silence OutputDebugString output (#88)
Browse files Browse the repository at this point in the history
Some applications (MSYS compilers, MiKTeX) output a lot of distracting
information via OutputDebugString(). Add a flag to catchsegv to silence
it.
  • Loading branch information
aitap authored Dec 9, 2023
1 parent 76d8f7e commit c0e5849
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions src/catchsegv/catchsegv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 messages from OutputDebugString\n",
stderr);
}

Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/common/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
1 change: 1 addition & 0 deletions src/common/debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c0e5849

Please sign in to comment.