Interrupt

Advanced GDB Usage | Interrupt

About 6 years ago, when I was in my first few months at Pebble as a firmware engineer, I decided to take an entire workday to read through the majority of the GDB manual. It was by far one of my best decisions as an early professional engineer. After that day, I felt like I was 10x faster at debugging the Pebble firmware and our suite of unit tests. I even had a new .gdbinit script with a few macros and configuration flags to boot, which I continue to amend to this day.


This is a companion discussion topic for the original entry at https://interrupt.memfault.com/blog/advanced-gdb

Good article Tyler. I learnt about SVD files and plugin that I was missing in my debug sessions with GDB. I use the TUI mode in GDB, I should try the other GUI options you suggest as well. Maybe even upgrade to VSCode based sessions.

If you are using PyOCD, OpenOCD, or JLink, ensure you are using a gdbserver that is compatible with your RTOS so that you can get the backtraces for all threads.

How can you tell if your gdbserver supports a certain RTOS? Is there is a command line switch that you are use to ask gdbserver what it supports?

As a general note for others new to GDB, GDB support short forms for most commands, very useful if you are not using a wrapper GUI over GDB. For example b, l, n, p, i etc in place of break, list, next, print, info etc.

If the system you are debugging has multiple threads/tasks, then when you run thread apply all backtrace in GDB, it should show all of the threads/tasks and their backtraces. If that doesn’t work, then you need to either switch out the gdbserver with another one or write a plugin to help.

Which RTOS are you using?

FreeRTOS.
I know that there is a command line switch to query if GDB support python. I was wondering if there was something similar to that to find out if GDB server support RTOS threads and which RTOS.