Sign in to follow this  
Solance

C++ skipping parts of code?

Recommended Posts

Solance    102
in my game sometime its just like the program skips parts of code when i break and step through it, it is in fact just jumping into the middle or so of a function any idea what causes this and how to fix it?

Share this post


Link to post
Share on other sites
technomancer    199
I have seen this occur when you haven't got your debug mode set correctly, that is if you still have any compiler optimisations switched on. The actual code that is generated by the compiler sometimes gets changed during optimisation process and thus doesn't match your displayed code anymore and can jump around and miss instructions entirely.

Make sure you have your debug mode set to no optimisation at all so all instructions are compiled into the resulting executable.

Share this post


Link to post
Share on other sites
oliii    2196
1) check out the compiler warnings. It might say "unreachable code" or something similar.

2) the code could do nothing and be weeded out of the binaries.

3) is the code inside a #ifdef / #endif block?

4) If it's a release build, I don't think it would skip parts of the code, you would not be able to step into inline functions.

5) rebuild all. paying attention to compiler warnings. Always good to fix EVERY warnings you encouter too, so that stuff doesn;t get lost in the output spam.

Share this post


Link to post
Share on other sites
Nemesis2k2    1045
If you're stepping through a release build, it may jump over things in an unpredictable manner, as things get cut and reshuffled by the optimizer. If you want to step through code, make sure you're using a debug build.

Share this post


Link to post
Share on other sites
sordid    246
That's the reason it happens for me. Have you tried a complete clean/rebuild of the entire project and all its dependencies?

Share this post


Link to post
Share on other sites
jregan    140
It is as indicated by other posters generally caused by the PDB file not matching up with the current state of the files --> The executable doesn't match the text version kept by the PDB. Sometimes though even if you do a make clean or what not it will not solve it, as the PDB may not be rebuilt . I am not saying I'm a total expert on how or when the PDB's for a given component are created, but in the case that it's skipping it even after you make clean and rebuild a component, you should just re-fetch the source from wherever you got it and start the build from there. HTH! =)

ack! sorry, I just thought of something else. if you just put a breakpoint in the method that is being called that it should be stepping into, then it will stop there.. you may still have to do make clean before that tho. usually I would just add that file to the project and then put a breakpoint in there.

[Edited by - jregan on June 5, 2005 9:15:39 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this