I am launching cdb.exe (Microsoft Console Debugger) as a child process of my C++ application using the following method:
https://stackoverflow.com/a/66147288/6531253
cdb.exe, in turn, launches a separate application to debug. This mostly works fine and I get the debugging output from cdb, but I do not receive any output from the process it is debugging through the pipe at all.
If I run the same command inside a cmd prompt, it shows the output from the debuggee application fine. For example:
C:\Users\Drago\source\repos\WinDebugQt\WinDebugQt>"C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe" -o "DummyProgram.exe"
Microsoft (R) Windows Debugger Version 10.0.19041.685 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.
CommandLine: "DummyProgram.exe"
************* Path validation summary **************
Response Time (ms) Location
Deferred srv*
Symbol search path is: srv*
Executable search path is:
ModLoad: 00007ff6`ede30000 00007ff6`ede57000 DummyProgram.exe
ModLoad: 00007ffa`dee90000 00007ffa`df085000 ntdll.dll
ModLoad: 00007ffa`ddac0000 00007ffa`ddb7e000 C:\WINDOWS\System32\KERNEL32.DLL
ModLoad: 00007ffa`dc920000 00007ffa`dcbe8000 C:\WINDOWS\System32\KERNELBASE.dll
ModLoad: 00007ffa`9b230000 00007ffa`9b23f000 C:\WINDOWS\SYSTEM32\VCRUNTIME140_1D.dll
ModLoad: 00007ffa`19650000 00007ffa`19732000 C:\WINDOWS\SYSTEM32\MSVCP140D.dll
ModLoad: 00007ffa`19480000 00007ffa`19647000 C:\WINDOWS\SYSTEM32\ucrtbased.dll
ModLoad: 00007ffa`31e00000 00007ffa`31e2b000 C:\WINDOWS\SYSTEM32\VCRUNTIME140D.dll
(8adc.988c): Break instruction exception - code 80000003 (first chance)
ntdll!LdrpDoDebuggerBreak+0x30:
00007ffa`def606b0 cc int 3
0:000> gh
INITIALIZING DUMMY PROGRAM!
00007FF6EDE422A000007FF6EDE4231000007FF6EDE41055(8adc.988c): Break instruction exception - code 80000003 (first chance)
*** WARNING: Unable to verify checksum for DummyProgram.exe
DummyProgram!debuggerCmdSetCallbacks:
00007ff6`ede426b9 cc int 3
0:000>
The output coming from the pipe in my C++ application is missing "INITIALIZING DUMMY PROGRAM" from the debuggee:
Microsoft (R) Windows Debugger Version 10.0.19041.685 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.
CommandLine: DummyProgram.exe
************* Path validation summary **************
Response Time (ms) Location
Deferred srv*
Symbol search path is: srv*
Executable search path is:
ModLoad: 00007ff6`ede30000 00007ff6`ede57000 DummyProgram.exe
ModLoad: 00007ffa`dee90000 00007ffa`df085000 ntdll.dll
ModLoad: 00007ffa`ddac0000 00007ffa`ddb7e000 C:\WINDOWS\System32\KERNEL32.DLL
ModLoad: 00007ffa`dc920000 00007ffa`dcbe8000 C:\WINDOWS\System32\KERNELBASE.dll
ModLoad: 00007ffa`184c0000 00007ffa`18687000 C:\WINDOWS\SYSTEM32\ucrtbased.dll
ModLoad: 00007ffa`18690000 00007ffa`18772000 C:\WINDOWS\SYSTEM32\MSVCP140D.dll
ModLoad: 00007ffa`9b230000 00007ffa`9b23f000 C:\WINDOWS\SYSTEM32\VCRUNTIME140_1D.dll
ModLoad: 00007ffa`32a60000 00007ffa`32a8b000 C:\WINDOWS\SYSTEM32\VCRUNTIME140D.dll
(8be0.8978): Break instruction exception - code 80000003 (first chance)
ntdll!LdrpDoDebuggerBreak+0x30:
00007ffa`def606b0 cc int 3
0:000> gh
(8be0.8978): Break instruction exception - code 80000003 (first chance)
*** WARNING: Unable to verify checksum for DummyProgram.exe
DummyProgram!debuggerCmdSetCallbacks:
00007ff6`ede426b9 cc int 3
0:000>
Does anyone know why the behavior is different than when done in a cmd prompt and how I can get that output from my C++ application?
Everything comes through stdout when running in the cmd prompt case so it's very odd that the debuggee output is missing.