Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
53 Views

Debugger loses synchronization with editor output?

Hi folks, I've got a strange one here:

I'm using Win7/VC++ 2008/ Intel C++ compiler 11 plug-in.

I have a project that was working correctly. It runs well, produces the correct output and I can debug it if need be. I thought I'd make some modifications to the class layout and - being cautious - copied the whole project into another folder and started modifying this duplicate version. When I tried to run in debug mode and stop at a breakpoint, to my astonishment the debugger stopped in a function that I wasn't calling. I double-checked that I was indeed building in debug mode and tried again...same behavior. After fussing for an hour or so (which included several restarts of both the computer and VS 2008) I decided to go back to the original unmodified project that was working properly and try that again. Incredibly, this one now behaves the same when debugging even though on Friday everything was working normally and it hadn't been modified since then (other than being copied). When I run the debug version without actually trying to debug it i.e. no breakpoints, etc it runs all the way through and generates the correct output as usual. When trying to run to a breakpoint or the cursor, it stops in sections of the code that it shouldn't be in in the first place and starts hopping around, landing on blank lines, etc. After a lot of head-scratching - > swearing, I've noticed the following pattern which implies there's some sort of graphical error in what is being shown in my code editor window when trying to debug. Consider two functions in my source code, arranged one above the other:

void Func1(int x)

{

if(x == 0) // <- Put a breakpoint at this conditional statement. At runtime this evaluates to false and it will test the next condition.

{

.

.

}

else if(x == 1)

{

.

.

}

}

void Func2(int y)

{

// Some general code, completely unrelated to the code above.

.

.

. // <- When debugging, debugger stops here (call it "line x") even though this code/function is never invoked!

.

.

.

.

. // <- It then jumps here, as though it were executing the "if-else" block in the above function, which I believe it is since it runs fine.

.

}

It seems like the code block being shown in the code editor while I'm trying to step through under the debugger is not the code block that is actually being interrogated by the debugger. This explains the crazy behavior as I try to step through line by line. One other note...if I try to interrogate the value of a variable by hovering the mouse cursor over it, I get nothing. If I add the variable to the watch window I get an error in the watch window warning me the variable is not in the stack frame, or something like that. Has anyone else seen this? Is my project somehow schmutzed-up and, if so, is there a way to force a total "regeneration" to try and get things back to normal? Thanks in advance!

0 Kudos
21 Replies
Highlighted
Beginner
7 Views

Are you using a debug build or a release build? My experience is that aggressive optimizations (/Qipo, /O3 or /Ox etc.) can cause the debugger to jump back and forth at least between lines within a function - but due to optimizations I could imagine that jumping between functions is also possible. So is missing breakpoints.
0 Kudos
Highlighted
Beginner
7 Views

This is the first thing I checked. I'm using the debug build.
I believe this problem had something to do with moving files around. Before making any large change, I usually make a copy of the solution and put it in another folder, for exampe:
Original:
C:\MySolution\MySolution\...source files...
Temp copy for experiment:
C:\MySolution experiment\MySolution\...source files...
This usually poses no problem, but somehow something failed to "hook-up" with the new folder (that's my theory anyway). I eventually got things back to normal by starting a new solution from scratch, adding new source and header files through the solution explorer window, and copying/pasting the code text from the old project into the new files. It was tedious but it seems to have worked. The only issue now is the lack of any incremental linking capability.
So...no more moving around files for me!
0 Kudos