There are times when a simple 'printf' is not enough to debug an application
Fortunately for us, Booboo included all the necessary tools in the toolchain and rootfs.
We just had to figure how to use them
For this I use KDbg (ubuntu package: KDbg) as I'm not fond of using the command line GDB
For this I'm going to assume 2 things:
- Toolchain installed in /opt/mipsel-linux-uclibc
- Application in /usr/local/apps/myapp
It works like this, basically:
KDbg ----> mipsel-linux-gdb ----- TCP/IP port 2222----> gdbserver ----> myappPreparation:
Start KDbg and go to Settings -> Global options. 'How to invoke GDB' should look like:
gdb --fullname --nx
Change it to:
/opt/mipsel-linux-uclibc/usr/bin/mipsel-linux-gdb --fullname --nx
To interface KDbg with the MIPS version of KDbg included with the toolchain.
We add a menu entry to DMenu to start gdbserver on the dingoo :
Icon = "res/apps.png"
Name = " MyApp (Debug)"
Executable = "gdbserver 10.1.0.1:2222 ./myapp"
WorkDir = "/usr/local/apps/myapp"
- Compile your application in debug mode.
This usually mean:
- Adding the '-g' option.
- Disabling optimizations '-O0'.
- Removing '-fomit-frame-pointer' as it interferes with debugging.
- Not stripping the resulting executable. (No '-s' in the LDFLAGS).
- Transfer the executable to the Dingoo. (See here: http://boards.dingoonity.org/dingux-development/ftping-files-to-the-dingoo/)
- Start gdbserver from DMenu. You should see something like this on the Dingoo :
Process ./myapp created; pid = <number>
Listening on port 2222
- Start KDbg, telling it to connect to gdbserver:
kdbg -r 10.1.0.2:2222 myapp
You will see something like this on the Dingoo:
Remote debugging from host 10.1.0.1
- Last step: Load the source code! File->Open source or CTRL+O.
You can now set breakpoints, execute the code step by step and look at all the variables.
Try not to step into library functions (like SDL_*) hangs the debugger for me.
Sample debug compiled app for lazy people : http://www.mediafire.com/?hdkgmxoz254