Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2017, C++, pointing a wrong line while stepping through the code

In some of the files, debugger is pointing at the wrong line, while stepping through the code. To be precise, it is off by exectly one line (always)

What I have already tried:

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

project is set to x64 Debug,takes use of SQLite3 LIB and DLL, OpenCL.lib

example in the faulty file:

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

One file has the issue, while another might not have it. I haven't found any corelation between affected files and their content.

like image 283
Vega4 Avatar asked Aug 25 '17 16:08

Vega4


People also ask

How do I skip a line while debugging in Visual Studio?

You can also click on the line you want to skip to and hit Ctrl+F10 (Run to Cursor). It will jump directly to that line.

How do I fix breakpoint in Visual Studio?

Hover over the breakpoint symbol, choose the Settings icon, and then select Remove breakpoint once hit in the Breakpoint Settings window.

How do you step over in Visual Studio?

When you are on a line of code that is a function or method call, you can press F10 (Debug > Step Over) instead of F11. F10 advances the debugger without stepping into functions or methods in your app code (the code still executes).


1 Answers

Turns out I've used the most upvoted method described in stack post to 'normalize' line endings in the entire project. Seems like it did not work. After normalising line endings with Visual Studio everything works fine.

So for anyone else with this problem, just re-enable automatic line-ending fix-up ,if disabled, by going to Tools=>Options=>Environment=>Documents and enable 'check for consistient line endings on load'. Then repen problematic file.

like image 185
Vega4 Avatar answered Nov 09 '22 23:11

Vega4