Can't Capture cdb.exe Debuggee Output With LaunchProcess

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.


As a workaround, I found a way to at least get the output. Rather than having cdb.exe launch the process, I launch the process myself in the same program that I am launching cdb.exe from. I am then having the launched cdb.exe attach to the already running process.

When done this way, I can read from the pipe I set up for the original process and the output comes through that way. I can also elect to not set up the pipes for the debuggee process, in which case they come through normally through the cmd window opened for it. That way they can be seen in the separate window as usual (which wasn't happening when launched from the programmatically launched cdb.exe).

This is not as ideal as all the output coming through the same pipe, but it's a lot better than nothing.