Debugging

From wiki.gp2x.org

Some useful debugging tools

Contents

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.

Example:

bash-2.05a# cd /usr/gp2x
bash-2.05a# LD_TRACE_LOADED_OBJECTS=1 ./gp2xmenu 
       libunicodefont.so => /lib/libunicodefont.so (0x4001e000)
       libSDL-1.2.so.0 => /lib/libSDL-1.2.so.0 (0x401b7000)
       libpthread.so.0 => /lib/libpthread.so.0 (0x40211000)
       libdl.so.2 => /lib/libdl.so.2 (0x4022f000)
       libSDL_image-1.2.so.0 => /lib/libSDL_image-1.2.so.0 (0x4023a000)
       libpng.so.3 => /lib/libpng.so.3 (0x4026c000)
       libz.so.1 => /lib/libz.so.1 (0x40296000)
       libm.so.6 => /lib/libm.so.6 (0x402ae000)
       libc.so.6 => /lib/libc.so.6 (0x4032e000)
       /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
bash-2.05a#

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