Close

Hardcore GDB Debuggin'

A project log for Raspberry Pi Pico Emulator

Live-coding an Open-Source Pico Emulator from Scratch

uri-shakedUri Shaked 03/22/2021 at 23:360 Comments

How do you debug the code that is running in your emulator? 

In the previous episodes, we printed a trace log of every single instruction that the emulator executes. This allowed us to find various bugs in our virtual RP2040 chip. This method worked, but was a very slow and inefficient: we had to go back and forth between the trace file, the assembly listing and the source code.

The last episode started as usual, hacking on a few more instructions. But midway it totally changed course: we tried to make it possible to connect GDB, the GNU debugger, into the emulator.

It took us about an hour of coding, but eventually we got it to work: GDB connected and was able to read the CPU state, registers, and even show us what line of code the emulated MCU was running!

You can watch the whole process here. GDB hacking starts at 1:24:12 👇

This week I'm planning to continue hacking on the GDB integration. We'll also take a look at a pull request some nice guy sent us, and hopefully also merge it. It adds the few missing instructions: sxtb, asrs, eors.

You can watch the stream on YouTube.

Discussions