Game Development Reference
In-Depth Information
'
'
That
t find themselves in an unrecoverable situation. If a
game runs out of memory, you ' re hosed. You have no choice but to bring up a dialog
and say,
s not to say that games can
re lucky,
your exit code might be able to save the game into a temporary file, much like Micro-
soft Word sometimes does when it crashes. When the game reloads, it can read the
temporary file and attempt to begin again just before everything went down the toi-
let. If this fails, you can exit again and lose the temporary file. All hope is lost. If it
succeeds, your players will worship the ground you walk on. Trust me, as many times
as Microsoft Word has recovered pieces of this topic after my laptop ' s batteries ran
out of electrons, I can appreciate a little data recovery.
Sorry dude. You
'
re hosed,
and start throwing exceptions. If you
'
Use @err,hr in Your Watch Window
If a Windows function fails, you must usually call GetLastError() to determine the exact nature of
the error. Instead, simply put @err,hr in your debugger
'
s watch window. This will show you a string-
formatted version of the error.
Debugging Basics
Before you learn some debugging tricks, you should know a little about how the
debugger works and how to use it. Almost every computer has special assembly lan-
guage instructions or CPU features that enable debugging. The Intel platform is no
exception. A debugger works by stopping execution of a target program and
associating memory locations and values with variable names. This association is pos-
sible through symbolic information that is generated by the compiler. One human
readable form of this information is a MAP file. Here
'
s an example of a MAP file
generated by the linker in Visual Studio:
Sample
Timestamp is 3c0020f3 (Sat Nov 24 16:36:35 2001)
Preferred load address is 00400000
Start
Length
Name
Class
0001:00000000 000ab634H .text
CODE
0001:000ab640 00008b5fH .text$AFX_AUX
CODE
0001:000b41a0 0000eec3H .text$AFX_CMNCTL
CODE
0002:00000000 000130caH .rdata
DATA
0002:000130d0 00006971H .rdata$r
DATA
0002:000275d0 00000000H .edata
DATA
0003:00000000 00000104H .CRT$XCA
DATA
0003:00000104 00000109H .CRT$XCC
DATA
0003:00001120 00026e6aH .data
DATA
0003:00027f90 00011390H .bss
DATA
 
 
Search WWH ::




Custom Search