Product Documentation


Previous Topic

Next Topic

gdb Remote Debugging

This section shows an example of how to remote debug using gdb, the GNU Project Debugger, on a different system architecture. In this example:

  • Host=x86 Linux
  • Target =ARM linux

The gdbserver must be compiled and run on the target system. The gdb must be specially compiled to be aware of the target architecture.


To build gdb with auto-detect host (x86) and ARM-Linux target:

$ cd gdb-6.3

$ ./configure --target=arm-linux

$ make

$ file gdb/gdb

gdb/gdb: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for

GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped

$ cd gdb/gdbserver

$ export CC=/usr/local/bin/arm-linux-gcc

$ ./configure --host=arm-linux

$ make

$ file gdbserver

gdbserver: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux

2.4.3, dynamically linked (uses shared libs), not stripped

Copy gdbserver to the target and run your program on the target using TCP/IP. This alternate syntax can be used for the COM port:

# gdbserver host:2345 ./ctsrvr

On the host, start your special gdb version and issue the following commands:

#local copy of binary to debug

(gdb) file ./ctsrvr

#path to local "root" for resolving system libraries with absolute paths

(gdb) set sysroot /usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/arm-linux

#path to any local copies of libraries using relative paths

(gdb) set solib-search-path /usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/arm-linux/lib

#attach to remote process host:port

(gdb) target remote ts7200:2345