Remote debugging (gdbserver)

Remote debugging creates the possibility to debug applications on a remote device.
Setup: Host system (gdb) <---[serial/network]---> Target system (gdbserver)

Precondition
– Installed gcc/g++ and gdb on the host
– Installed gdbserver on the target
– Connection between host and target

Procedure
1. Build the app on the host with debug symbols [Host]

g++ app.cpp -o my_app

2. Deploy that debug app on the target with scp [Host]

scp my_app root@192.168.1.4:/usr/bin

3. Open a port and start gdbserver on the app [Target]

iptables -A INPUT -p tcp --dport 4444 -j ACCEPT
gdbserver localhost:4444 my_app &

4. Setup gdb session with running gdbserver [Host]

gdb my_app
(gdb) target remote 192.168.1.4:4444

5. Debug the app via the created gdb session [Host]

(gdb) b main
(gdb) r
...

6. Finish gdb session with running gdbserver [Host]

(gdb) q