Kevin
Kevin

Reputation: 1009

Visual Studio Skipping (And Moving) Breakpoint When Debugging (C++ / CMake)

I have a CMake project which I created on Ubuntu that I'm loading on Visual Studio now (for dual booting development).

The project can be seen here: http://github.com/KiloMikeCodesStuff/Gravity

The following image displays the problem: image

Notice how on the left I've clearly set the breakpoint on line 5. When I run it, the breakpoint MOVES and stops on line 8.

I've tried:

In all cases, the result is the same. What I'm thinking is perhaps there is some code optimisation (as I've selected to build for x64-release, because those are the only DLL's I have for SFML).

Would this be the culprit? If so, how can I disable the optimisations (remembering it's a CMake project, not a typical VS project)?

Upvotes: 2

Views: 892

Answers (1)

1201ProgramAlarm
1201ProgramAlarm

Reputation: 32732

The most likely cause is simply that there is no assembly code associated with line 5, and the first line after that with code is line 8. This can happen when code is being optimized. The command line flag to disable optimizations is Visual C++ is /Od. Since the first few lines are simple variable assignments, those variables could have been optimized into registers or deferred until later.

This is harmless in the sense that when you set the breakpoint on line 5, execution is still stopping at the first code within the function. The usual problems with trying to debug an optimized build apply (strange variable values, execution jumping around, etc.).

Upvotes: 6

Related Questions