Sign in to follow this  
formalproof

Debugging game code

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
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
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

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