A healthy diet for your Java application Devoxx France.pdf
Gdb + gdb server + socat
1. GDB + GDB Server
via socat
by Wei-Chung Wen
@ 2015-05-15
2. Overall Sequence
1. Start socat as proxy
2. Start GDB server
a. GDB server hangs until GDB connects
b. No way to stop GDB server
3. Start GDB
4. Configure GDB sysroot
5. Connect GDB to socat
6. Debug
7. Exit GDB
a. GDB server automatically stops
b. socat automatically stops
3. socat
● Multipurpose relay (SOcket CAT)
● We use it as a proxy bridging GDB on build
server and GDB server on BMC
● socat command
○ Template: socat FROM TO
○ Template: socat TCP4-LISTEN:5566 TCP4:
192.168.1.100:5566
4. GDB Server
● GDB server ~ 263KB
○ An agent complying with GDB’s instruction to debug
programs
● GDB server command
○ Template: gdbserver :PORT CMD ARGS
○ Example: gdbserver :5566 /sbin/fullfw
5. GDB
● GDB ~ 4.2MB
● GDB command
○ Template: gdb CMD ARGS
○ Example: gdb build/rootfs/sbin/fullfw
● Internal comman for debugging via GDB
server
○ set sysroot build/rootfs
○ target remote 192.168.1.100:5566