Jump to content
  • Advertisement
Sign in to follow this  
formalproof

Debugging game code

This topic is 3629 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 guess I should have asked this question much earlier, because I've been game programming for a long time now and newer really got over this problem. Is it actually possible to run a game program step-by-step, or use breakpoints? For me it has never worked, the game just gets stuck and I have to kill it using alt-ctrl-del. I'm using Allegro, but I assume other libraries have similar problems? What I've usually done is use a logger which records to a file all function calls and their arguments, so when the game crashes I can find out in which function the problem took place. Is there some other/better way to do this?

Share this post


Link to post
Share on other sites
Advertisement
Yes, this is entirely possible, debugger functionality has been around for years. I don't really see any other sane way to debug :) I usualy reserve "printf debugging" for those really desperate cases where the debugger isn't enough.

What IDE are you using? You really need to look into getting debugging working if it doesn't. Generally speaking, you should be able to step through most source code if you have it. Unfortunately, you usually can't debug external libraries unless your have source, but even then the idea is that those libraries are "black boxes" that you shouldn't have to debug anyway!

Share this post


Link to post
Share on other sites
I switched to using a windowed mode, and now it seems to work (almost.) I can step through the code, but I can't restore the game window. It also still seems to crash sometimes. I was testing it just a minute ago, and once it deadlocked so hard I had to restart windows (couldn't even kill the process.)

It probably has something to do with Allegro accessing the hardware directly. Any ideas?

Share this post


Link to post
Share on other sites
The simple answer is dual monitors or remote debugging. I certainly wouldn't expect anyone to be alt+tabbing back and forth between the debugger and a game.

If you don't have the necessary hardware (and even if you do), test as much as you can in isolation from Allegro.

Share this post


Link to post
Share on other sites
Generally I don't think there's usually much problem debugging as long as the game runs in windowed mode. It works ok for us at work, anyway.

Share this post


Link to post
Share on other sites
Debug in windowed mode as much as possible. Also, see if you can run DirectX using debug libraries. It is possible you have some threads running in the background, and not operating properly when debugged.

maybe some interest to you, but if you are using C#, look for ContextSwitchDeadlock.

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!