You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将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.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 05:52:35