DebuggingWithValgrind

Revision 1 as of 2009-03-28 21:04:34

Clear message

Because /usr/bin/X is normally not started directly by the user, and is also setuid root, running it under valgrind for debugging purposes requires some additonal adjustments. Here's a recipe for running your X server under valgrind that might be helpful.

Note: valgrind is a tool for debugging memory allocation bugs. As a result, running a program under valgrind substantially increases the cost of all memory operations. This will make your X server use more memory and run very slowly. You probably don't want to run X under valgrind unless you are specifically trying to debug a memory corruption error!

Enabling valgrind

If you are starting valgrind from a display manager (such as gdm), the following recipe should be sufficient:

{{ $ sudo dpkg-divert --local --rename --divert /usr/bin/X.valgrind-testing /usr/bin/X $ sudo tee /usr/bin/X #!/bin/sh exec valgrind --error-limit=no --log-file=/var/log/Xorg-valgrind.log X.valgrind-testing "$@" ^D $ sudo chmod a+x /usr/bin/X $ sudo chmod u-s /usr/bin/X.valgrind-testing $ }}

Disabling valgrind

To unwind, run:

{{ $ sudo rm /usr/bin/X $ sudo chmod u+s /usr/bin/X.valgrind-testing $ sudo dpkg-divert --remove --local --rename /usr/bin/X $ }}