Skip to content

yugr/valgrind-preload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License Build Status codecov Total alerts Coverity Scan

What's this?

Valgrind-preload (AKA Pregrind) is a simple LD_PRELOAD-able library which will cause all spawned processes to be started under Valgrind.

It's functionality is similar to Valgrind's standard --trace-children=yes but fixes few disadvantages:

  • avoids intrumenting setuid processes (Valgrind doesn't handle them so you have to laboriously blacklist all of them via --trace-children-skip which is unreliable and disables instrumentation of grandchildren)
  • can easily be enabled for the whole distro or chroot via ld.so.preload (no need to search for init and replace it with a wrapper)

The tool seems to be pretty stable now, e.g. I was able to instrument complete Debian package builds and even found several new errors.

Usage

To use, just preload libpregrind.so to your app:

$ LD_PRELOAD=path/to/libpregrind.so app arg1 ...

You can also use a simple wrapper script:

$ path/to/pregrind app arg1 ...

Finally, if you want to instrument whole system, preload libpregrind.so globally:

$ echo path/to/libpregrind.so >> /etc/ld.so.preload

Note that in this mode libpregrind.so will be preloaded to all newly started processes so any malfunction may permanently break your system. It's thus highly recommended to only do this in a chroot or VM.

Library can be customized through environment variables:

  • PREGRIND_LOG_PATH - log to files inside this directory, rather than to stderr
  • PREGRIND_FLAGS - additional flags for Valgrind (e.g. --track-origins=yes)
  • PREGRIND_VERBOSE - print diagnostic info
  • PREGRIND_DISABLE - disable instrumentation
  • PREGRIND_BLACKLIST - name of file with wildcard patterns of files which should not be instrumented

Build

To build the tool, simply run make from top directory.

Trophies

Known issues

Various TODO and FIXME are scattered all over the codebase but tool should be quite robust. Ping me if you need more features.

About

LD_PRELOAD-able library which runs all spawned processes under Valgrind.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published