[Bug gcov-profile/87442] Add options to filter files we want to instrument for code coverage

cdenizet at mozilla dot com gcc-bugzilla@gcc.gnu.org
Wed Nov 7 18:02:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87442

--- Comment #9 from calixte <cdenizet at mozilla dot com> ---
(In reply to Martin Liška from comment #8)
> Ok, I've got a patch prototype and I hope I'll be able to sent it before
> the end of this stage1.
> 
> > The idea is to add two options to easily include/exclude some files from
> > being instrumented.
> > Here are two use cases:
> >  1) -coverage-exclude=/usr/include/*: typically we remove the data for such
> > files when post-processing the gcno/gcda so we don't need to instrument them
> > and so we could reduce the overhead due to instrumentation.
> >  2) -coverage-filter=.*/foo.cpp:.*/bar.cpp: here we want to only instrument
> > these two files (for example, to display code coverage data for files
> > appearing in a patch at review phase)
> 
> However, calixte can you please explain me difference in between those two
> options.
> More precisely, one is a white list and the second one is a black list. Will
> you
> mix these together or they will be used exclusively?

Few things:
 i) I use ';' as regex separator (to avoid issues under windows with C:\...)
 ii) if exclude is empty and filename is matching any of the regexes in filter
then instrument it.
 iii) if filter is empty and filename is not matching any of the regexes in
exclude then instrument it.
 iv) if both are not empty and filename is matching any of the regexes in
filter AND is not matching any of the regexes in exclude then instrument it. 

Few examples:
 i) exclude="^/usr/include/;^/usr/local/include/" => a file is instrumented if
and only if it isn't in /usr/include/ nor in /usr/local/include/
 ii) filter="^/home/foo/dev/.*\.cpp;^/home/foo/ved/.*\.cpp" => a file is
instrumented if and only if it's a cpp file somewhere under /home/foo/dev/ or
/home/foo/ved/
 iii) exclude="^/usr/include/.*$" and filter="^/usr/.*$" => a file is
instrumented if and only if it's somewhere under /usr/ but not under
/usr/include

My patch for llvm is here:
https://reviews.llvm.org/D52033

If you see something wrong or have idea to improve, please ping me.


More information about the Gcc-bugs mailing list