Monday, August 17, 2009

using gdb and gdbserver

Imagine you need to use an embedded system debugger.One of the options is using gdb and gdbserver all together


To do this first you need to setup your toolchain at x86 machine.In that example out embedded system will be in ST.

Install gdbserver your embedded directory.In order to work with gdbserver we can use tcp connection to out x86 machine like that:

/root/gdbserver 192.168.1.136:1234 bin/${ST binary to debug} ${arguments to pass binary}

It's handy to get this command work in a very bottom of a shell script file after all done, environment variables, etc..

with this command we will start debugging session and awaits connection from relevant machine(x86 machine in that case)

Meantime we need to open our tcp connection to gdbserver like:


root@home$ gdb ${EXECUTABLE_FILE}
(gdb)target remote ${ip address of embedded machine}:${tcp port number of embedded machine}

after connection established, we need to enter gdb command c
(gdb) c

c stands for continue, since debugging already started that is the command we should send to gdbserver with our local gdb client.
But before starting gdb client do not forget to set corrent binary executable as well.Otherwise you will not be able to set breakpoints, and other useful stuff inside gdb.


so remote debugging starts

No comments:

Registred Linux User

Registred Linux User

HitCounter