Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Debugging - Exercises

Now that gdb or gdb-multiarch are set up, let's do some exercises.

  1. Access exercises/gdb_hello_world
  2. Inspect the configuration files openocd.cfg (for openocd ) and .gdbinit (for gdb).
  3. Execute cargo run, leave out --release to use the development profile.
    • Without it, cargo will remove / optimise lines.
    • We should debug with --release to ensure the best outcomes.
    • But this examples is just to get started.
  4. Run gdb -x gdbinit -q (or gdb-multiarch on Linux) in one terminal, and openocd in another (at the same directory!).
    • In the image, _peripherals has not yet been assigned. gdb stopped execution there. The window at the bottom half is our (gdb) prompt.
  5. Add a break point where a/=2, then print the resulting value.
  6. Exit with Ctrl+D or Ctrl+C.

Suggested Reading

  • MB2 article on Debugging.