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
docs:guide-developer:gdb [2018/06/08 18:45] – link fixed tmomasdocs:guide-developer:gdb [2023/03/09 10:15] (current) – [GNU Debugger] update GDB documnetation link tatami
Line 1: Line 1:
 ====== GNU Debugger ====== ====== 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/]]+  * **''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: [[https://sourceware.org/gdb/documentation/]]
  
  
 ===== Compiling Tools ===== ===== Compiling Tools =====
-in [[docs:guide-developer:build-system:use-buildsystem#image_configuration|menuconfig]] enable gdb+in [[docs:guide-developer:toolchain:use-buildsystem#image_configuration|menuconfig]] enable gdb
  
-Advanced configuration options (for developers) -> Toolchain Options ->  Build gdb |+  Advanced configuration options (for developers) -> Toolchain Options ->  Build gdb
  
 and gdbserver and gdbserver
  
-Development -> gdbserver |+  Development -> gdbserver
  
  
 ===== Add debugging to a package ===== ===== Add debugging to a package =====
 Add CFLAGS to the package Makefile and recompile it. Add CFLAGS to the package Makefile and recompile it.
-TARGET_CFLAGS += -ggdb3 |+  TARGET_CFLAGS += -ggdb3
 Alternatively recompile the package with ''CONFIG_DEBUG'' set Alternatively recompile the package with ''CONFIG_DEBUG'' set
-make package/busybox/{clean,compile} V=99 CONFIG_DEBUG=y | +  make package/busybox/{clean,compile} V=CONFIG_DEBUG=y 
-Or you can enable debug info in [[docs:guide-developer:build-system:use-buildsystem#image_configuration|menuconfig]] +Or you can enable debug info in [[docs:guide-developer:toolchain:use-buildsystem#image_configuration|menuconfig]] 
-Global build settings > Compile packages with debugging info |+  Global build settings > Compile packages with debugging info
  
 ===== Starting GNU Debugger ===== ===== Starting GNU Debugger =====
 Start gdbserver on target (router) Start gdbserver on target (router)
-gdbserver :9000 /bin/ping example.org |+  gdbserver :9000 /bin/ping example.org
  
 Start gdb on host (in compiling tree) Start gdb on host (in compiling tree)
-./scripts/remote-gdb 192.168.1.1:9000 ./build_dir/target-*/busybox-*/busybox |+  ./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. now you have a gdb shell. Set breakpoints, start program, backtrace etc.
  
-(gdb) b source-file.c:123 | +  (gdb) b source-file.c:123 
-(gdb) c | +  (gdb) c 
-(gdb) bt |+  (gdb) bt 
 + 
 +If you want to restart the program, you'll need to set the remote path and arguments 
 + 
 +  (gdb) set remote exec-file /usr/bin/blah 
 +  (gdb) set args -v -x -merry-fishing 
 +  (gdb) run 
  • Last modified: 2018/06/08 18:45
  • by tmomas