Wednesday, November 12, 2008

Never underestimate the power of crash dumps

Warning: programming jargon ahead...

Let me set this picture up for you. I've got a loop in the wad file loader (the main loop) that , among other things, constantly "paints" the wad files on the screen. This repeats until the user hits a button to start up Doom. At the bottom of this loop I check for various button presses (select wad, quit to wii menu, load wiidoom, etc..). I've had this code running for a few weeks. Last week I start to add one line of code to check to see if the DPad-right button is pressed. One simple line of code.

And WiiDoom crashes. If you haven't seen the Wii crash, picture a BSOD in Windows, but no blue. A black and white screen that pisses me off because now I have to get off the couch, reboot the wii, restart Twilight Princess, and get ready to boot the hack again.

I checked the code I just added, and it looks exactly like the other button press tests. I change the button I'm checking for, and..... another crash. I change it to a button I'm already checking for (like A). Crash. WTF?

One week later, while taking some long needed advice, I analyze the crash dump information, and find out the game is crashing due to some code I've got to write the wad filenames to the screen. WAAAAY up further in the procedure. The same code that's been running for quite a while (development-wise, anyway). I correct the bug, and everything starts to work.

[EDIT] Here's the page that helped me -

That is one of those slap-yourself-in-the-face moments where you wish you'd thought of that earlier. If you've seen any of my code in WiiDoom, you'd probably see my method of debugging on the Wii.
  1. Print out a debug message
  2. Suspend (sleep) the program
  3. Resume
That's still the best method in my opinion if you don't debug via gecko (or whatever that device is), but I now will be checking the crash dump a little more often (as opposed to never!).

Anyways, now that it's not crashing, maybe I can get enough done to crank out a screenshot...

1 comment:

vin said...

whoa. Yeah, I've done some programming and had to really go back when I couldn't find the source of the bug. Good that you found it at least.

can't wait to see it!