Sign in to follow this  

losing debug info

Recommended Posts

i'm having trouble with debugging my code ( vc7.1 ) , i'm going trough code and when debugger enters code for some class it displays class declaration ( like 'CA a' ) and not value for class member. after i try to assign value to that class member i get 0x00000005 exception ( quick debug for 'this' says 0x00000000 ??? )
int CSurface::RedrawGFX(CGFX* pGFX)
 if (image != NULL) //<------------------this is the line where code breaks
   image = NULL;

when i move mouse over code for pGFX i get correct address and values for image i get "SDL_Surface* CSurface::image" ???

Share this post

Link to post
Share on other sites
The clue is that your this pointer is 0 (or "null").

To explain why this is important, let me give a little background on how object member functions work. Each function in an object is called using a system known as thiscall. In this system, your function has an invisible parameter, which is a pointer to the object instance that the function should run on. There is only one copy of your function's code for all of the objects you create; the code knows which object to work with by looking at the hidden parameter. That parameter is translated into the this pointer.

The net result is simple, but important:
// This line of code here:
pSomeObject->SomeFunction(a, b);

// Is basically doing this, except with some magic involved:
SomeFunction(pSomeObject, a, b);

Since this is essentially a parameter to the function, it's possible for a bogus value to be sent along. Specifically, it's possible to send in a null pointer instead of an actual object instance.

So... to solve your problem, the place you need to look is wherever your RedrawGFX() function is getting called from. Chances are that code looks like pSurface->RedrawGFX(foo);. Look in that spot - whatever you're using as pSurface is almost certainly going to be null (i.e. a 0 pointer). Find out why that's null, and you'll have the cause of your bug.

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