Debugging egmde

Notes from a debug session

I know this information exists in various places, and I remember most of it. But one day I’ll need a reminder and this is one place for quick reference.

The situation was “when using X-forwarding from a multipass VM egmde segfaults on exit” so I wanted egmde, with debug symbols running in a multipass VM. Because these VMs are pretty “bare bones” there’s a load of dependencies missing that would be on my normal desktop. The recipe for setting those up is what follows.

Setting up the VM

multipass launch -n bug-1938
multipass-enable-ssh bug-1938
multipass-ssh-X bug-1938

This provides a console with access to X11 on the host system (which will be needed later). The rest of these notes are about instructions run from that session.

The build dependencies

sudo apt-add-repository ppa:mir-team/release
sudo apt install pkg-config devscripts equivs git cmake
sudo apt install libmiral-dev libfreetype6-dev libwayland-dev libboost-filesystem-dev

Surprisingly I didn’t need g++, although that’s also a dependency.

This allowed me to checkout and build egmde:

git clone https://github.com/AlanGriffiths/egmde
mkdir egmde/build
cd egmde/build
cmake ..

Runtime dependencies

In addition to the above, the following runtime dependencies are needed:

sudo apt install mir-graphics-drivers-desktop libgl1-mesa-dri fonts-freefont-ttf

This allows egmde to run on the host desktop.

gdb -ex run egmde

Debug symbols

The Ubuntu Wiki for Debug Symbol Packages gives a handy script for adding debug repositories:

echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse
deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse
deb http://ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted universe multiverse" | \
sudo tee -a /etc/apt/sources.list.d/ddebs.list

But this only deals with the main archives, not the Mir ppa.

For that we need to edit /etc/apt/sources.list.d/mir-team-ubuntu-release-focal.list and change:

deb http://ppa.launchpad.net/mir-team/release/ubuntu focal main
# deb-src http://ppa.launchpad.net/mir-team/release/ubuntu focal main

to

deb http://ppa.launchpad.net/mir-team/release/ubuntu focal main
deb http://ppa.launchpad.net/mir-team/release/ubuntu focal main/debug
deb-src http://ppa.launchpad.net/mir-team/release/ubuntu focal main

Next we need to figure out the symbol packages we need. There’s a handy script mentioned on that page:

apt install debian-goodies
find-dbgsym-packages [core_path|running_pid|binary_path]

And running find-dbgsym-packages egmde provides a helpful list of packages to be pasted onto sudo apt install.

Source package

As the problem I was hunting turned out to be in the egmde code I didn’t get around to loading any source packages, so that is left as an exercise for my future self. (Hint apt source libmiral-dev will get the Mir source.)