如何将WinDbg从非侵入式附加切换为侵入式调试?
问题:VS分离后将WinDbg从非侵入式转为侵入式调试器
我可以使用WinDbg以非侵入式模式附加到进程,此时会收到如下提示:
WARNING: Process 8196 is not attached as a debuggee The process can be examined but debug events will not be received ........ (2004.7558): Wake debugger - code 80000007 (first chance)
当Visual Studio作为主调试器时,我会采用这种方式并行附加WinDbg。现在我已执行VS的「调试/全部分离」操作移除其作为主调试器的身份,希望保留应用当前状态(不想重启进程再重新附加),将WinDbg转为侵入式调试器。比如存在这类场景:应用若继续运行会立即终止,示例代码如下:
#include <iostream> int main() { std::cout << "Hello World!\n"; } // VS breakpoint here
我已尝试以下方法:
- 通过F6(GUI附加)操作
- 使用
.attach命令,执行过程如下:0:000> | . 0 id: 2004 examine name: C:\[...].exe 0:000> .attach 2004 Attach will occur on next execution 0:000> g *** wait with pending attach - 在执行
.attach前冻结所有线程(~*f)
但所有尝试均导致进程以退出码-1073740972(0xc0000354,即STATUS_DEBUGGER_INACTIVE)终止。此情况通常因Visual Studio启动进程时设置了DEBUG_OBJECT_KILL_ON_CLOSE标志或调用了DebugSetProcessKillOnExit()接口,但我理解「分离」操作应能保持进程存活。
内容的提问来源于stack exchange,提问作者Thomas W.
相关产品推荐
相关产品推荐

