Bug 218689

Summary: Need finer control of which child processes to trace
Product: [Developer tools] valgrind Reporter: Dan Kegel <dank>
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: wishlist CC: bart.vanassche+kde, leiz
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: patch to add option for skip tracing children
patch to try matching against all arguments and not just the exe name

Description Dan Kegel 2009-12-14 20:30:47 UTC
Version:            (using Devel)
OS:                Linux
Installed from:    Compiled sources

http://blog.mozilla.com/nnethercote/2009/04/30/making-valgrind-easier-to-use-with-multi-process-programs/
describes proposals for finer control of which child
processes to trace.

In my case, I would like to exclude tracing /bin/sh,
but also wine valgrind.  i.e. the decision can't be
made just on argv[0], but has to take argv[1] into
account, too.   Perhaps if the blacklist and whitelist
options accepted regexps, and operated on the whole
commandline somehow, that would do.

Having this would make my runs considerably faster.
I may hack in a hardcoded "don't valgrind python" kludge
of my own in the meantime.
Comment 1 leiz 2010-01-15 23:16:06 UTC
Created attachment 39929 [details]
patch to add option for skip tracing children

Here is a patch that adds --trace-skip=STR. This disables --trace-chidren for cases where the child's argv contains an argument that's equal to STR. The matching is just a simple strcmp(), no fancy regexp. You can pass multiple --trace-skip arguments to valgrind the same way you pass --suppression.
Comment 2 Julian Seward 2010-01-15 23:28:35 UTC
(In reply to comment #1)
> Created an attachment (id=39929) [details]
> patch to add option for skip tracing children
> 
> Here is a patch that adds --trace-skip=STR. This disables --trace-chidren for
> cases where the child's argv contains an argument that's equal to STR. 

Er, I think we already have this functionality in the trunk now:

    --trace-children-skip=patt1,patt2,...    specifies a list of executables
                              that --trace-children=yes should not trace into

Is that what you were after?  Or do I misunderstand?
Comment 3 leiz 2010-01-15 23:38:43 UTC
Yes, that's what I'm after. I guess Dan K should close this bug as a duplicate of bug 148932.
Comment 4 leiz 2010-01-16 00:56:16 UTC
Oh, looks like--trace-children-skip doesn't quite do what I want. In our test case, we're running the command:

/path/to/wine-preloader /path/to/wine Z:\\path\\to\\python.exe.

My patch examines all the arguments whereas --trace-children-skip only examines the first argument. That's not fine-grained enough because every command is /path/to/wine-preloader /path/to/wine foo.exe.
Comment 5 leiz 2010-01-16 04:02:52 UTC
Created attachment 39931 [details]
patch to try matching against all arguments and not just the exe name
Comment 6 Bart Van Assche 2011-03-02 12:50:51 UTC
(In reply to comment #4)
> Oh, looks like--trace-children-skip doesn't quite do what I want. In our test
> case, we're running the command:
> 
> /path/to/wine-preloader /path/to/wine Z:\\path\\to\\python.exe.
> 
> My patch examines all the arguments whereas --trace-children-skip only examines
> the first argument. That's not fine-grained enough because every command is
> /path/to/wine-preloader /path/to/wine foo.exe.

I guess that --trace-children-skip-by-arg=... does provide the desired functionality ?
Comment 7 Dan Kegel 2011-03-02 15:56:05 UTC
Yes, probably, thanks.