DebuggingWithValgrind

Differences between revisions 2 and 3
Revision 2 as of 2009-03-28 21:06:45
Size: 1255
Editor: minbar
Comment: braaaaace
Revision 3 as of 2009-03-28 22:44:32
Size: 1257
Editor: minbar
Comment: not sgid either
Deletions are marked like this. Additions are marked like this.
Line 15: Line 15:
$ sudo chmod u-s /usr/bin/X.valgrind-testing $ sudo chmod ug-s /usr/bin/X.valgrind-testing
Line 25: Line 25:
$ sudo chmod u+s /usr/bin/X.valgrind-testing $ sudo chmod ug+s /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 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)