User Tools

Site Tools


doc:devel:gdb

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:devel:gdb [2012/11/08 12:36]
jow add alternative approach to recompile package with debugging
doc:devel:gdb [2015/05/31 14:07] (current)
jow old revision restored (2015/05/30 20:54)
Line 1: Line 1:
 +====== GNU Debugger ======
 +  * **''​Note:''​** This guide is by no means a Howto, just some short instructions to use GDB on OpenWrt.\\ Please look upstream for multilingual instructions and manuals, like e.g. here: [[http://​sourceware.org/​gdb/​current/​onlinedocs/​gdb/​]]
  
 +
 +===== Compiling Tools =====
 +in [[doc:​howto:​build#​configuration|menuconfig]] enable gdb
 +
 +| Advanced configuration options (for developers) -> Toolchain Options ->  Build gdb |
 +
 +and gdbserver
 +
 +| Development -> gdbserver |
 +
 +
 +===== Add debugging to a package =====
 +Add CFLAGS to the package Makefile and recompile it.
 +| TARGET_CFLAGS += -ggdb3 |
 +Alternatively recompile the package with ''​CONFIG_DEBUG''​ set
 +| make package/​busybox/​{clean,​compile} V=99 CONFIG_DEBUG=y |
 +Or you can enable debug info in [[doc:​howto:​build#​configuration|menuconfig]]
 +| Global build settings > Compile packages with debugging info |
 +
 +===== Starting GNU Debugger =====
 +Start gdbserver on target (router)
 +| gdbserver :9000 /bin/ping example.org |
 +
 +Start gdb on host (in compiling tree)
 +| ./​scripts/​remote-gdb 192.168.1.1:​9000 ./​build_dir/​target-*/​busybox-*/​busybox |
 +
 +now you have a gdb shell. Set breakpoints,​ start program, backtrace etc.
 +
 +| (gdb) b source-file.c:​123 |
 +| (gdb) c |
 +| (gdb) bt |