Skip to content

Debugging

chino edited this page Jan 5, 2013 · 5 revisions

Command line switch

Add -debug to the command line.

There is also a -log switch which will write all debug output to the log file.

Debug Functions

Print debug information to stderr using this printf like function:

DebugPrintf( format, ... )

To create a pop up window for errors that the player should be alerted to before the game bails out:

Msg( format, ... )

Note, that Msg is mapped to DebugPrintf since we need to think about a cross platform way to pop up a window. Supposedly a common technique is to embed a basic low res font into the source it self since most likely you'll still be able to get that basic font rendered to the screen. If not then something so bad happened that the system should provide an alert to the user that the program had an issue running.

Debug Mode

In game you can switch to debug mode which will add a new debug menu that allows you to turn on various debug rendering features such as ability to see collision skins, unspawned enemies, etc..

Profiling

To generate profiling output run, "gprof ./projectx-binary ./gmon.out > gmon.txt"

Using a Debugger (gdb)

Check out the forsaken-libs run.sh which shows how you can call it.

But generally:

gdb --args ./projectx -chdir $px_folder
Clone this wiki locally