【问题标题】:Visual Studio 2017, C++, pointing a wrong line while stepping through the codeVisual Studio 2017,C++,在单步执行代码时指向错误的行
【发布时间】:2018-02-03 18:58:59
【问题描述】:

在某些文件中,调试器在单步执行代码时指向错误的行。准确地说,它正好是一条线(总是)

我已经尝试过

1) normlized line-endings in all of the files
2) wiped out all of the PDB files
3) wiped out the entire debug folder
4) rebuilt the entire project
5)ensured that optimisation for the entire solution and projects within it it is turned-off (/Od switch enabled)
6)ensured that libraries (*.LIB) to which source code I have access to, have had their optimisation disabled and use the same threading mode as the main executable.
7) rebooted PC / VS

项目设置为 x64 Debug,使用 SQLite3 LIB 和 DLL,OpenCL.lib

错误文件中的示例:

   int a = 0;
   a++;
=> a++; //debugger points at this line, though the value of 'a' is already equal to 2
   a++;

一个文件有问题,而另一个文件可能没有。我没有发现受影响的文件与其内容之间有任何关联。

【问题讨论】:

  • 你试过重启visual studio吗?
  • 刚做了,整机都没用
  • 是不是被一个语句关闭了? VS 经常会指向要执行的 next 语句,尤其是当你切换到调用堆栈中更高的调用时。
  • 它被一个语句关闭,但从某种意义上说,它指向了它应该指向的位置上方的一行(这可能发生并且经常恰好是空行)。当我在代码中添加人为的空行时,它似乎考虑到了这些并且仍然只关闭了一行(因此更新了 PDB 文件)
  • 优化器可能会将多个源代码行折叠成一个机器代码。那么调试器只有一次可能的停止。

标签: c++ visual-studio debugging


【解决方案1】:

事实证明,我使用了中描述的最受好评的方法 stack post 在整个项目中“规范化”行尾。似乎它没有没有工作。 使用 Visual Studio 规范化行尾后一切正常。

因此,对于遇到此问题的其他人,只需重新启用自动行尾修复,如果禁用,请转到 Tools=>Options=>Environment=>Documents 并启用“在加载时检查一致的行尾” .然后重新打开有问题的文件。

【讨论】:

  • 感谢您在这里分享您的解决方案,既然已经解决,您可以将您的回复标记为答案,这样可以帮助遇到相同问题的其他社区成员。祝你有美好的一天:)
  • 没有修复它,我可以选择开始,但它仍然指向错误的行。
【解决方案2】:

在我的情况下,我发现我实际上需要关闭项目,然后删除主 exe 项目文件夹和任何 dll 项目文件夹中的 binobj 文件夹。 Visual Studio 将在下次打开解决方案时自动重新创建空的 binobj 文件夹。届时,重建项目将解决此问题。

【讨论】:

    猜你喜欢
    • 2017-11-02
    • 1970-01-01
    • 1970-01-01
    • 2012-11-02
    • 1970-01-01
    • 2012-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多