Hardware & Software & VoCore…

VoCore2: remote debug with GDB

I love command line recently, Eclipse might be easy to use(I do not like Java complex depends), Qt creator looks nice(this is my favorite IDE), but command line, the GDB, is their core.

First, let’s compile gdb…
This article is focus on cross-compile. (I do not think you can compile gdb on VoCore2 magically 🙂

Once you compile openwrt or LEDE on your host linux computer, it already have gdb(mipsel-openwrt-linux-uclibc-gdb), but it has a bug, when you run it later it will report “Remote ‘g’ packet reply is too long”. This is easy to fix, we need to modify gdb Makefile, in openwrt/toolchain/gdb/Makefile, section “Host/Configure”, add “–with-expat” to CFLAGS. Better to delete old compiled gdb file in build_dir.

Now let’s make a simple app to debug
I’d like to use “mem”, this small app is used to read and write to memory directly. I use it to develop driver and do quick hack to the kernel.
Source code is here: Link to Source

Uncompress it and get mem.c

Next step, compile it with debug information
One command line will do this, do not forget -g, it is used to generate debug links.

mipsel-openwrt-linux-uclibc-gcc -g mem.c -o mem

Make gdbserver
In openwrt “make menuconfig”, Development section, select gdbserver.
Compile and install gdbserver to your VoCore.
Also you can copy mem to your VoCore.

r: run the app.
l: show source code list.
b: add break point, parameter is the line number.
ni: step over one line.
si: step in one line.
p: show the parameter value.
d: delete break point.
i b: show current break point.
c: continue and run to next break point.