[PATCH] Create reasonable backtraces via gdb automatically

Matthias Hopf mhopf at suse.de
Fri Oct 8 09:25:11 PDT 2010


The following is a patch for the xserver that makes Xorg's stack traces
*tremendously* more useful - by providing exact source location
including source snippets (if -debug{source,info} rpms are installed, in
the case of rpm-based distributions), and local variable contents.

This is done by calling an external script /usr/bin/xorg-backtrace,
which in turn will attach gdb to the server process and parse its
output. Buffer handling is quite tricky, involving invisible temporary
files, as the X process is frozen during this time.

We're using this patch with the also attached xorg-backtrace script
(which will need a little love to make it more distribution-independent,
and to improve STDERR handling) and it seems to work reasonably well for
some time now.


I think this is something X could benefit from (especially for getting
better bug reports from users). Would this reasonable to commit?

The patch makes sure that a stack trace is created in any case.
If /usr/bin/xorg-backtrace does not exist, creates unreasonably short
output, or fails, the original method is used.
The script itself tries to fail gracefully after a timeout of 5 seconds
in case gdb or the parsing locks up.


BTW - the xorg-backtrace script will work on *any* process id supplied.
So it comes in handy for other use cases as well.



More information about the xorg-devel mailing list