Remote debugging creates the possibility to debug applications on a remote device.
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
- Build the app on the host with debug symbols [Host]
g++ app.cpp -o my_app
- Deploy that debug app on the target with scp [Host]
scp my_app root@192.168.1.4:/usr/bin
- Open a port and start gdbserver on the app [Target]
iptables -A INPUT -p tcp --dport 4444 -j ACCEPT gdbserver localhost:4444 my_app &
- Setup gdb session with running gdbserver [Host]
gdb my_app (gdb) target remote 192.168.1.4:4444
- Debug the app via the created gdb session [Host]
(gdb) b main (gdb) r ...
- Finish gdb session with running gdbserver [Host]
(gdb) q