[英]Visual Studio Breakpoints being automatically disabled while debugging
I am running C++ code in VS 2012. I have set a simple Breakpoint我在 VS 2012 中运行 C++ 代码。我设置了一个简单的断点
int main(int argc, char **argv)
{
time_t start_time;
time(&start_time);
DUALISO_TIME dualiso_time;
IO_TIME io_time = {0.0, 0.0};
IO_INFO io_info;
IJK::ERROR error;
cout <<"DEBUG "<< endl; // I have set a breakpoint.
While debugging the breakpoint briefly turns white (from red) but the debugger does not break at the break point, it just continues on.在调试断点时,断点短暂地变为白色(从红色),但调试器不会在断点处中断,而是继续进行。 (The code is being run because it prints DEBUG in console.) I have searched for a while but I have not found any solution.
(代码正在运行,因为它在控制台中打印 DEBUG。)我已经搜索了一段时间,但没有找到任何解决方案。
Some notes.一些笔记。 The particular project is selected as the startUp Project.
特定项目被选为启动项目。 I have tried cleaning and re-building.
我试过清理和重建。 The part of the code is definitely being run.
代码的一部分肯定正在运行。 I can even see the BreakPoint changing to white from red briefly, but the debugger is not stopping at the point.
我什至可以看到 BreakPoint 短暂地从红色变为白色,但调试器并没有就此停止。 Here is SCREEN SHOT
这是屏幕截图
Some reasons a breakpoint will not to be hit:断点不会被命中的一些原因:
One extra reason, if you work with C# at least (not sure if exactly the same applies to C++ projects):一个额外的原因,如果您至少使用 C#(不确定是否完全相同适用于 C++ 项目):
Your current build configuration is not configured to produce PDB files.您当前的构建配置未配置为生成 PDB 文件。
Go to your project, right click > Properties
> Build
> Advanced...
> Debugging information
.转到您的项目,右键单击 >
Properties
> Build
> Advanced...
> Debugging information
。
Set that to full
.将其设置为
full
。
Here are some reasons that weren't mentioned already:以下是一些尚未提及的原因:
When the breakpoints are white that is the indication that Visual Studio is unable to match up the place in the source file with the application it is being debugged.当断点为白色时,表示 Visual Studio 无法将源文件中的位置与正在调试的应用程序匹配。 Typically this occurs for the following reasons
通常发生这种情况的原因如下
This can happen because of compiler optimizations.这可能是由于编译器优化而发生的。 If you compiled with
gcc -O
then the program will be optimized and Visual Studio breakpoints will become disabled after attaching the program.如果你用
gcc -O
编译,那么程序将被优化,并且在附加程序后 Visual Studio 断点将被禁用。 To solve this, you can disable the compiler optimization with additional 0 following the -O like below.为了解决这个问题,您可以在 -O 后面加上 0 来禁用编译器优化,如下所示。
gcc -O0
You can also use gcc -Og
(available from gcc 4.8).您还可以使用
gcc -Og
(可从 gcc 4.8 获得)。 This should allow both optimization and debugging.这应该允许优化和调试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.