Close

GDB all the way down!

A project log for Raspberry Pi Pico Emulator

Live-coding an Open-Source Pico Emulator from Scratch

uri-shakedUri Shaked 03/27/2021 at 15:180 Comments

In this week's episode we leveled-up our debugging capabilities. Continuing our last week effort to plug GDB into the emulator, we added single-stepping breakpoints, and memory/register writes.

This means we'll be harness the full power of GDB to debug the emulated code: step through the lines of source code, break at certain locations, travel through the stack trace and inspect/modify the values of local and global variables.

To sweeten the deal, we even managed to hook the Visual Studio Code debugger into the simulator, allowing us to use a modern and convenient user-interface for debugging.

In the episode recording you will see all the work that led into that magical moment: how our naïve implementation of the gdbserver "c" command failed to work with stepping and breakpoints, the intensive troubleshooting and debugging that followed, and how eventually comparing our implementation with the physicals Pi Pico's debugger revealed the answer.

The first 22 minutes of the episode show how I review a pull-request from Brain Popeck, adding 3 new instructions: sxtb, asrs, eors, and uncovering a sneaky bug in our signExtend implementation. Then we dive right into hacking on gdbserver!

The next episode will air on Tuesday. If you want the link right in your inbox, you can sign up for email updates.

Discussions