windows DebugBreak 没有中断
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1044103/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
DebugBreak not breaking
提问by Dror Helper
I'm writing a class in C++ that I cannot debug by using F5. The code will run from another "service" that will invoke it.
In the past I've used __debugbreak()
and when I got a window telling me that an exception was thrown selected to debug it.
我正在用 C++ 编写一个无法使用 F5 调试的类。代码将从另一个调用它的“服务”运行。过去我使用过__debugbreak()
,当我收到一个窗口时,告诉我选择了一个异常来调试它。
Recently I've updated to windows 7 and it kept working for a while.
最近我更新到 Windows 7,它继续工作了一段时间。
Today when I've tried to debug a piece of my code instead of shown the regular dialog that tells me that VSTestHost has stopped working and enable me to to debug the application I got a different dialog suggesting I send the data to microsoft for analysis.
今天,当我试图调试我的一段代码而不是显示告诉我 VSTestHost 已停止工作并使我能够调试应用程序的常规对话框时,我得到了一个不同的对话框,建议我将数据发送给微软进行分析。
Does anyone knows how can I fix this issue so I'll be able to debug my code?
有谁知道我该如何解决这个问题,以便我能够调试我的代码?
回答by Dror Helper
Finally I found the cause of the issue. It's a Vista/Win7 cause:
最后我找到了问题的原因。这是 Vista/Win7 的原因:
- Open The Action center control
- Goto Action Center settings
- Goto Problem Reporting Settings
- Choose "Each time a problem occurs, ask me before checking for solution"
- 打开操作中心控件
- 转到操作中心设置
- 转到问题报告设置
- 选择“每次出现问题时,在检查解决方案之前先问我”
Although this is more of IT solution/question I've been plagued with this problem all day and wanted to share the solution with other developers who encounter this problem.
虽然这更多是 IT 解决方案/问题,但我一整天都被这个问题困扰,并希望与遇到此问题的其他开发人员分享解决方案。
回答by jp48
I finally found the solution for Windows 10 here: https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/enabling-postmortem-debugging
我终于在这里找到了 Windows 10 的解决方案:https: //docs.microsoft.com/en-us/windows-hardware/drivers/debugger/enabling-postmortem-debugging
And also: https://docs.microsoft.com/en-us/windows/desktop/Debug/configuring-automatic-debugging
还有:https: //docs.microsoft.com/en-us/windows/desktop/Debug/configuring-automatic-debugging
To enable automatic debugger launch, you should add a registry value:
要启用自动调试器启动,您应该添加一个注册表值:
- key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug
, valueAuto
=1
(of typeREG_DWORD
)
- 键
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug
,值Auto
=1
(类型REG_DWORD
)
The configured debugger is set the by the value Debugger
(type REG_SZ
); a Visual Studio installation sets this to:
配置的调试器由值Debugger
(类型REG_SZ
)设置;Visual Studio 安装将其设置为:
"C:\WINDOWS\system32\vsjitdebugger.exe" -p %ld -e %ld
Note that on 64 bit OS this only works for 64 bitexecutables. To enable the same behaviour in 32 bitexecutables set the same values in this key:
请注意,在 64 位操作系统上,这仅适用于64 位可执行文件。要在32 位可执行文件中启用相同的行为,请在此键中设置相同的值:
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug
回答by Erix
In that case...
在这种情况下...
Here is the quick overview of what you need to-do to enable debugging on a Microsoft Windows 7 machine:
以下是在 Microsoft Windows 7 机器上启用调试所需要做的快速概述:
Update the Just-In-Time debugger setting DbgJITDebugLaunchSetting. The setting is found in the registry at [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework].
Set the value of DbgJITDebugLaunchSetting to 2.
If you are using a 64bit operating system then you must also set the same key (DbgJITDebugLaunchSetting) in this folder [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft.NETFramework] to 2.
If you run into any issues try running CodeSmith Studio and Visual Studio as an administrator.
Now when CodeSmith enters a break point you will see something like this:
更新 Just-In-Time 调试器设置 DbgJITDebugLaunchSetting。该设置位于 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework] 的注册表中。
将 DbgJITDebugLaunchSetting 的值设置为 2。如果您使用的是 64 位操作系统,那么您还必须将此文件夹 [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft.NETFramework] 中的相同密钥 (DbgJITDebugLaunchSetting) 设置为 2。如果您遇到任何问题尝试以管理员身份运行 CodeSmith Studio 和 Visual Studio。现在,当 CodeSmith 进入断点时,您将看到如下内容:
回答by Erix
You could try debug > attach to process.
您可以尝试调试 > 附加到进程。