How to Use GDB and GDBServer

GDBServer is a program that allows you to run GDB on a different machine than the one running the program being debugged.


  • Toolchain
    • GDB
      • Web Factory: Enabled by default
      • Desktop Factory: Enable in Toolchain Configuration --> GDB
    • GDB Server (will be installed to RFS)
      • Web Factory: Enable the gdbserver package (Development category)
      • Desktop Factory: Enable in Toolchain Configuration --> GDB --> GDB Server for target
  • Program to be debugged
    • copy on host including debug information (no stripping, compiled with -g)
    • copy on target RFS to run

If you are using Factory on your desktop, then you can run "make checktool-gdb" to check your platform for compatibility with GDB/GDBServer.


  • On the target:
    • Run GDBServer with your target program
      gdbserver localhost:10000 <program> <args>
  • On the host
    • Start GDB
    • Load the symbols from your unstripped copy of the binary
      file <program>
    • Connect to the target GDBServer
      target remote <ip-of-target>:10000
    • Optionally set your target sysroot
      set sysroot <path to unstripped rfs>
    • Debug as normal. Note that instead of issuing the run command to begin, you need to enter continue as the program will already be running on the target.


  • Target:
    bash-3.1# gdbserver localhost:10000 vim /etc/network/interfaces 
    Process vim created; pid = 335
    Listening on port 10000
  • Host:
    $ ~/timesys/omap3530zoom/toolchain/bin/armv7l-timesys-linux-gnueabi-gdb
    GNU gdb 6.8
    Copyright (C) 2008 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <>
    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=i486-linux-gnu --target=armv7l-timesys-linux-gnueabi".
    (gdb) file vim
    Reading symbols from /home/timesys/factory/build_armv7l-timesys-linux-gnueabi/vim-7.2/vim72/src/vim...done.
    (gdb) target remote
    Remote debugging using
    [New Thread 335]
    0x400007c0 in _start ()
       from ~/timesys/omap3530zoom/toolchain/lib/

Additional Resources