I’ve been developing Gameboy emulators off and on for some years. They’re all broken in one way or another. Part of my debugging process is to run

A multi-emulator Gameboy tracer

submited by
Style Pass
2024-11-22 07:00:06

I’ve been developing Gameboy emulators off and on for some years. They’re all broken in one way or another. Part of my debugging process is to run a test ROM like the blargg suite. That gives me some positive signal—if the tests pass, I’ve done something right—but it doesn’t help me narrow down a bug if they fail.

For this, I’ve added a dump() function to my emulators that logs the state in some well-known format and then done a side-by-side comparison against a known-correct log. That’s all fine and good but:

I figured this would be a good opportunity to write sidecar program, gbtracer. This program dlopens an emulator and then runs it, logging the state to a tempfile. How does it know the state? The emulator calls some well-known functions:

These functions are empty in the emulator but have definitions in the tracer. This feels like it takes advantage of something broken or undefined, so if you know more about this, please let me know.

Leave a Comment