当前发布的版本(valgrind 3.5.0)无法跟踪某些但不是所有子项.
但是,如果您愿意使用
the latest code from the SVN repository,它包含一个
new option –trace-children-skip用于此目的:
--trace-children-skip=patt1,patt2
This option only has an effect when --trace-children=yes
is specified. It allows for some children to be skipped. The option takes a comma separated list of patterns for the names of child executables that Valgrind should not trace into. Patterns may include the metacharacters ?
and *
,which have the usual meaning.
This can be useful for pruning uninteresting branches from a tree of processes being run on Valgrind. But you should be careful when using it. When Valgrind skips tracing into an executable,it doesn’t just skip tracing that executable,it also skips tracing any of that executable’s child processes. In other words,the flag doesn’t merely cause tracing to stop at the specified executables — it skips tracing of entire process subtrees rooted at any of the specified executables.
较旧的方法是省略–trace-children = yes,对于您想要跟踪的子项,将其替换为在valgrind下运行实际程序的简单脚本:
#!/bin/sh
exec valgrind --log-file=myprog.vg.%p myprog-real "$@"
即使使用新选项,如果您有这样的脚本,这种脚本也很有用.你想在valgrind下追踪但想跳过它的父亲的孙子.