using-buildroot-debugger.txt 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // -*- mode:doc; -*-
  2. // vim: set syntax=asciidoc:
  3. ==== Using +gdb+ in Buildroot
  4. Buildroot allows to do cross-debugging, where the debugger runs on the
  5. build machine and communicates with +gdbserver+ on the target to
  6. control the execution of the program.
  7. To achieve this:
  8. * If you are using an _internal toolchain_ (built by Buildroot), you
  9. must enable +BR2_PACKAGE_HOST_GDB+, +BR2_PACKAGE_GDB+ and
  10. +BR2_PACKAGE_GDB_SERVER+. This ensures that both the cross gdb and
  11. gdbserver get built, and that gdbserver gets installed to your target.
  12. * If you are using an _external toolchain_, you should enable
  13. +BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY+, which will copy the
  14. gdbserver included with the external toolchain to the target. If your
  15. external toolchain does not have a cross gdb or gdbserver, it is also
  16. possible to let Buildroot build them, by enabling the same options as
  17. for the _internal toolchain backend_.
  18. Now, to start debugging a program called +foo+, you should run on the
  19. target:
  20. ----------------------------
  21. gdbserver :2345 foo
  22. ----------------------------
  23. This will cause +gdbserver+ to listen on TCP port 2345 for a connection
  24. from the cross gdb.
  25. Then, on the host, you should start the cross gdb using the following
  26. command line:
  27. ----------------------------
  28. <buildroot>/output/host/bin/<tuple>-gdb -x <buildroot>/output/staging/usr/share/buildroot/gdbinit foo
  29. ----------------------------
  30. Of course, +foo+ must be available in the current directory, built
  31. with debugging symbols. Typically you start this command from the
  32. directory where +foo+ is built (and not from +output/target/+ as the
  33. binaries in that directory are stripped).
  34. The +<buildroot>/output/staging/usr/share/buildroot/gdbinit+ file will tell the
  35. cross gdb where to find the libraries of the target.
  36. Finally, to connect to the target from the cross gdb:
  37. ----------------------------
  38. (gdb) target remote <target ip address>:2345
  39. ----------------------------