Jump to content
  • Advertisement
Sign in to follow this  
Fukushuusha

Debugging

This topic is 4333 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

Hello again ! Well I have been above this code of mine for a game for hours.. almost all day.Still I do not understand where is the problem.I get a runtime error.More details of it can be found here. This is not a double post or something.This is almost another question , but if you could help me solve the problem I have I would be grateful.As the title suggests it is about Debugging.I am now above my game's code .. looking at it .. changing it countless times and still I get this Acces Violation error at runtime. I tried outputting strings to a file I called log , in various parts of my code ... but not even the first would print.Which means the program does not even start?I don't get the reason .... any help tips about that or how to debug a program succesfully ? Most of the times I had bugs I could find them in due time , this time it has gone too far.Thanks in advance! :D

Share this post


Link to post
Share on other sites
Advertisement
Well if it compiles I'm sure the game is starting.Depending on your logfile setup it probably is writing to it but the game crashes before the buffer gets flushed to the disk. I can't imagine you got very far if its crashing instantly. If its new behavior what did you change before it started happening? Did you install any new hardware? Programs that your system didn't like? Any other programs acting in a similar or strange way? I would guess if it was a code change you would have known instantly that you did something wrong given the problem, but still make any code changes?

Share this post


Link to post
Share on other sites
Have you reviewed the various articles on debugging available here at gamedev?

For example, Introduction to Debugging, C++ Debugging, Introduction to Debugging (Comments).

An access violation typically indicates that a NULL pointer has been dereferenced. This could be in your code or it could be that an incorrect argument has been passed to an API or library function. When you run the program in the debugger and the fault occurs, the debugger should position the code at the point where the fault occurred - or as close to it as it can get (when the fault occurs in library or API).

Share this post


Link to post
Share on other sites
Yes I know exactly why it happens.It just does not want me to make a pointer of the button Class , no matter what.I am still in a very early stage .. still making the engine of my game , and made a button object pointer inside the menu class , in order for me to draw it from the menu.
No matter which way I try to do it , it jsut won't accept it.Even If I declare this pointer in main and pass it in the draw function later.Something must be wrong with the button class but I have absoluteley no idea what and why?
What do you do in occasions like these?I tried everything that came to mind for the last 6-7 hours but got no results.

Share this post


Link to post
Share on other sites
Have you actually used a debugger? It sounds as if you've tried simply printing values and checkpoints at different points in your code. While this is a handy skill to have, and you pick up an intuition for where something's going wrong, the debugger is still your best friend.

Step through your code, and see where it goes wrong. Then place a watch on any appropriate value which seems dubious, and step through again and see where it changes.

EDIT: Hm, did you write the button class? If so, research the rule of three (if you have dynamically allocated class data members then you need to write an operator=, a copy constructor and a destructor - and if you need any one of those three, you need the other two). This might conceivably lead to an invalid pointer being used after the original object has been deleted but you've still got a copy hanging around somewhere.

Share this post


Link to post
Share on other sites
No , no you are right and thanks to LessBread for those debugger links.I have no idea how to use a debugger and am quite sleepy to try now.Tomorrow morning though I will be back in full force trying to debug my program.
LEarning how to debug will come in handy ... pretty much everywhere :)

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!