Fast x86 Debugging: Using GDB On Apple Silicon with Rosetta emulation
Published: December 4, 2023
Overview
This blog post will outline how to setup x86 GDB on M1. This isn’t your run-of-the mill x86 emulation -
this is FAST — using the Rosetta translation engine, instead of QEMU. Thanks to sporks.space for the initial writeup of the ROSETTA_DEBUGSERVER feature!
System Requirements
I am running on a M1 Chip, running MacOS Sonoma 14.0 (Build 23A339). I have had issues with Rosetta crashing on previous versions of MacOS, so I would reccomend using a later, more stable version (and still occasionally have stability issues).
UTM / VM Setup
Download a ARMv8 / aarch64 iso like Ubuntu Desktop 22.04.3 LTS. This can be downloaded here.
Download the UTM DMG from their Github Releases. At the time of writing, this is UTM 4.4.4. If you run into issues, I would recommend using 8GB RAM.
Then, setup your UTM VM.
First, create a New UTM VM.
Then, select Virtualize.
Then, select Linux.
Then, turn on Apple Virtualization, Enable Rosetta, and select your arm64 iso.
Follow the rest of the steps, changing your disk and RAM as you see fit.
Then, boot up into Ubuntu server. Skip/continue past all prompts that require the internet, as it will not have internet access. Additionally, check ‘Install OpenSSH server’.
After you finish and reboot, go back to UTM and remove the ISO Drive so you can boot up into Ubuntu.
Enabling Network Access
Edit the network configuration so that you can access the internet.
sudovim /etc/netplan/00-installer-config.yaml
to the following contents (your network interface may be slightly different):