Jump to content
  • Advertisement
Sign in to follow this  
miodragsm

losing debug info

This topic is 4529 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 (pGFX == NULL) return ERR_SURFACEREDRAWGFX;
 if (image != NULL) //<------------------this is the line where code breaks
 {
   SDL_FreeSurface(image);
   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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!