Run valgrind inside a chroot environment on Debian?

1

Is it possible to use valgrind within a chroot environment on Debian? It seems to need to access the proc filesystem, which is unsurprisingly inaccessible.

root@tree:/# valgrind
valgrind: warning (non-fatal): readlink("/proc/self/exe") failed.
valgrind: continuing, however --trace-children=yes will not work.
--6352:0:aspacem  Valgrind: FATAL: can't open /proc/self/maps
--6352:0:aspacem  Exiting now.

I can't install valgrind in my main tree due to some package dependency issues related to the standard libraries, and compiling it from source resulted in an unusable binary, hence my attempt to run it in a clean chroot environment.

Andrew Wagner

Posted 2011-05-14T21:44:07.617

Reputation: 149

Answers

2

Ususal answer:

mount -o bind /proc /path/to/chroot/proc

This will give you a /proc in your chroot environment.

Turbo J

Posted 2011-05-14T21:44:07.617

Reputation: 1 919

Just to state what might not be obvious: You do this before/outside chroot. – MSalters – 2016-05-26T12:15:06.167

0

It's also useful to notice the warning from README:

Important!  Do not move the valgrind installation into a place
different from that specified by --prefix at build time.  This will
cause things to break in subtle ways, mostly when Valgrind handles
fork/exec calls.

Taken from: http://valgrind.org/docs/manual/dist.readme.html

netigger

Posted 2011-05-14T21:44:07.617

Reputation: 141