One should note that X is responsible for VT switching, meaning
switching between an X session and console terminals. In other words,
Ctrl+Alt+Fn is handled by X. If X is stopped, for example because
it’s running under gdb, one can no longer switch to another
VT. That’s why we’re recommending using a second machine to debug
X. Nevertheless, here are some instructions to attempt debugging X
with a single machine.
One-machine approach
This is a post-mortem approach. The idea is to run X with the
-core option. Once it dies, a core file (/etc/X11/core) is
generated, and can be loaded from gdb.
-
Getting a core file.
-
Loading a core file.
-
Displaying/saving a backtrace.
Two-machine approach
You pay the “need a second machine” price, but that buys you
interactivity. Just log into the first machine from the second one,
using ssh.
-
Attaching/Starting X from gdb.
-
Displaying/saving a backtrace.
Needed packages
Obviously, gdb is needed; xserver-xorg-core-dbg contains the
debugging symbols for the server itself. Other needed packages can be
determined by looking at the backtrace. FIXME: More info about
that.