I have a process x
that I want to check for leaks with valgrind
. The problem is that x
is run by y
, and y
in turn is run by z
. I can't run x
standalone because y
and z
setup the environment for x
, such as environment variables, command line switches, files needed by x
etc.
- Is there any way I can tell
valgrind
to run onz
but to follow any forks it finds and report them too? - Is there any way I can tell
valgrind
to follow any forks but only report on the process namedx
? - Is there any way I can tell
valgrind
to attach to already-running process, the way I can do with gdb?
I don't know if this matters, but I'm running under SuSE64 linux and valgrind-2.4.0.
Thanks!
- Valgrind follows forked processes when given the
--trace-children=yes
option. - You should be able to achieve this by using suitable filters.
- No. Valgrind hooks into the module loading code using LD_PRELOAD, so attaching to a running process is not possible.
来源:https://stackoverflow.com/questions/301576/how-do-i-tell-valgrind-to-memcheck-forked-processes