1 Add option to filter gcov source errors
3 Add "--gcov-filter-source-errors" to apply filters to the source
4 files in the errors from gcov. If all source files in the errors
5 are filtered, then the error is ignored so that the file will be
6 processed. This enables the usecase of running on a target where
7 only the source tree for a binary is available, but not all of the
8 external source headers are.
10 Upstream-Status: pending
12 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
14 diff --git a/gcovr/configuration.py b/gcovr/configuration.py
15 index 1356097..083532c 100644
16 --- a/gcovr/configuration.py
17 +++ b/gcovr/configuration.py
18 @@ -915,6 +915,14 @@ GCOVR_CONFIG_OPTIONS = [
19 "Default: {default!s}.",
23 + "gcov_filter_source_errors", ['--gcov-filter-source-errors'],
24 + group="gcov_options",
25 + help="Apply filters to missing source file errors in GCOV files "
26 + "instead of exiting with an error. "
27 + "Default: {default!s}.",
28 + action="store_true",
31 "objdir", ['--object-directory'],
33 diff --git a/gcovr/gcov.py b/gcovr/gcov.py
34 index de79215..171d68d 100644
37 @@ -667,11 +667,27 @@ def run_gcov_and_process_files(
42 if source_re.search(err):
43 - # gcov tossed errors: try the next potential_wd
48 + if options.gcov_filter_source_errors:
49 + # Check if errors are all from source that is filtered
51 + for line in err.splitlines():
52 + src_fname = line.split()[-1]
53 + filtered, excluded = apply_filter_include_exclude(
54 + src_fname, options.filter, options.exclude)
55 + if not (filtered or excluded):
60 + # gcov tossed errors: try the next potential_wd
66 # Process *.gcov files
67 for fname in active_gcov_files:
68 process_gcov_data(fname, covdata, abs_filename, options)