Some useful debugging tools


Using GDB

See this tutorial on using Gdb.

Debugging with output to stdout (synced)

Use this .gpu to start your game and redirect all your output to the console to stdout.txt / stderr.txt.

Note: uncomment `sync` and `unsync` if you want your log to be written to the sd immediately. You might want to do this if your app crashes the machine.
#sync #all IO operations
#mount /mnt/sd -o remount,sync

#run app, redirect stdout/in
./app.gpe 1>stdout.txt 2>stderr.txt

#unsync #(save battery and whatever)
#mount /mnt/sd -o remount,async

# return to the menu screen
cd /usr/gp2x
exec /usr/gp2x/gp2xmenu

Using the serial cable

Have a look at the serial cable page.

Checking which shared libraries a given program uses

You can set the LD_TRACE_LOADED_OBJECTS environment variable before running the program on your GP2X to list the libraries that are used by a program.


bash-2.05a# cd /usr/gp2x
bash-2.05a# LD_TRACE_LOADED_OBJECTS=1 ./gp2xmenu => /lib/ (0x4001e000) => /lib/ (0x401b7000) => /lib/ (0x40211000) => /lib/ (0x4022f000) => /lib/ (0x4023a000) => /lib/ (0x4026c000) => /lib/ (0x40296000) => /lib/ (0x402ae000) => /lib/ (0x4032e000)
       /lib/ => /lib/ (0x40000000)

If your program actually starts running instead of printing library information, this means that it is statically linked. In that case, the LD_TRACE_LOADED_OBJECTS option will probably apply to gp2xmenu, if your program calls exec() at the end of main().

Personal tools