gdbserver method


gdbserver is the main tool for embedded development and debugging, which depends on the development board's gdbserver programs and the cross compiler tool chain in the mips-linux-gnu-gdb command. gdbserver can work properly if PC and board share the same network.

this only describes gdbserver's startup and connection methods,related commands follow the standard gdbserver's commands,check the internet for more details.

gdb and gdbserver command position:

1. PC runs gdb

$ mips-linux-gnu-gdb [PC's application path]

example:

$ mips-linux-gnu-gdb sample-Encoder-h264(Application path)
GNU gdb (GDB) 7.6.2
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=mips-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/ykli/work/rvms/development/sdk/release/samples/api-samples/sample-Encoder-h264...done.

Notes:

2. set dynamic library search path

Applications usually use dynamic link libraries such as: libc,ld, ... when break is running in a dynamic library(for example:memcpy)it is often unable to track the location of the current PC. It is because the load address of the dynamic library is not fixed. so it is needed to specify the dynamic library loading path.

method:

set solib-search-path /opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/libc/lib/:/opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/lib

Use ":" for multiple paths. Notes: In the above example, only specify the toolchain's glibc from the libc series library and libstdc++,... as major external libraries.

3. development board starts gdbserver

gdbserver [PC's IP:Port,same Port as the second step] [application path]

example:

gdbserver 192.168.1.100:1234 /tmp/sample-Encoder-h264

4. connect (link) the developoment board

target remote [Board's IP:Port]

example:

target remote 192.168.1.101:1234

5. gdbserver is connected

PC will display such informations:

(gdb) target remote 192.168.1.101:1234
Remote debugging using 192.168.1.101:1234
Reading symbols from /opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/libc/lib/ld.so.1...done.
Loaded symbols for /opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/libc/lib/ld.so.1
0x77fc7070 in __start () from /opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/libc/lib/ld.so.1

At this point, you can run the gdb command on the host.

Notes: gdbserver and local gdb are different, starts a procedure with "c" command(continue).