DebuggingWithValgrind

Differences between revisions 3 and 4
Revision 3 as of 2009-03-28 22:44:32
Size: 1257
Editor: minbar
Comment: not sgid either
Revision 4 as of 2014-05-07 14:04:09
Size: 1266
Comment: added missing path to X in valgrind
Deletions are marked like this. Additions are marked like this.
Line 12: Line 12:
exec valgrind --error-limit=no --log-file=/var/log/Xorg-valgrind.log X.valgrind-testing "$@" exec valgrind --error-limit=no --log-file=/var/log/Xorg-valgrind.log /usr/bin/X.valgrind-testing "$@"

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 /usr/bin/X.valgrind-testing "$@"
^D
$ sudo chmod a+x /usr/bin/X
$ sudo chmod ug-s /usr/bin/X.valgrind-testing
$

Disabling valgrind

To unwind, run:

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

X/DebuggingWithValgrind (last edited 2014-05-07 14:04:09 by albertomilone)