Sign in to follow this  
The C modest god

Debugging question

Recommended Posts

I have found a bug of an infinite loop in my code. So I fixed it. However, what bothers me is that when I did go in debug mode and then did break. The call stack showed that I was in KERNEL and INPUT8 instead inside the problematic loop. Why does that happen? Is it because of the alt tabbing to go to visual and do the break? Why this happen?

Share this post


Link to post
Share on other sites
It's probably because those functions are called from the infine loop, imagine:



void Draw()
{
SetMatrices();
}
void SetMatrices()
{
VectorStuff();
VectorToMatrix();
}
void VectorStuff(){}
void VectorToMatrix(){}
int main()
{
while(true)
{
Draw();
}
return 0;
}



When you break you might be in VectorToMatrix since the calls go like this;
main->Draw->SetMatrices->VectorToMatrix
You should be able to "jump" down and see what is happening in the main loop by using the callstack, for example if it looks like this:
VectorToMatrix
SetMatrices
Draw
main

You should be able to double-click main and know you are in the loop. At least this is how it works in MSVC7.1

Share this post


Link to post
Share on other sites
You probably broke into the wrong thread. Go to the 'threads' debugger window and you can choose which thread you wish to view the callstack for.

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