From: Mauro Carvalho Chehab <mauro.chehab@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 10/12] code_cov_parse_info: filter out branches from headers by default
Date: Tue, 17 Jan 2023 15:06:05 +0100 [thread overview]
Message-ID: <20230117140607.2759816-11-mauro.chehab@linux.intel.com> (raw)
In-Reply-To: <20230117140607.2759816-1-mauro.chehab@linux.intel.com>
From: Mauro Carvalho Chehab <mchehab@kernel.org>
It is really tricky to handle branches on header files at the Linux
Kernel. Filter them out by default, allowing the user to override it.
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
scripts/code_cov_parse_info | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/scripts/code_cov_parse_info b/scripts/code_cov_parse_info
index 5a6a4a407359..4aed3d67bd98 100755
--- a/scripts/code_cov_parse_info
+++ b/scripts/code_cov_parse_info
@@ -27,6 +27,7 @@ my @src_include_regexes;
my @src_exclude_regexes;
my $can_filter_lines = 1;
my $ignore_lines_without_functions = 1;
+my $ignore_branches_on_headers = 1;
my $verbose = 0;
my $ignore_unused = 0;
@@ -182,6 +183,10 @@ sub parse_json_gcov_v1($$)
}
$all_line{$source}{$ln} += $line_ref->{'count'};
+ if ($ignore_branches_on_headers) {
+ next if ($source =~ m/.h$/);
+ }
+
my $i = 0;
for my $branch_ref (@{$line_ref->{'branches'}}) {
my $where = sprintf "%d,%d,%d", $ln, 0, $i;
@@ -527,6 +532,10 @@ sub read_info($)
my $branch = $3;
my $taken = $4;
+ if ($ignore_branches_on_headers) {
+ next if ($source =~ m/.h$/);
+ }
+
if ($block != 0) {
print "Warning: unexpected block $block at line $.\n";
}
@@ -1314,6 +1323,7 @@ GetOptions(
"include-source=s" => \@src_include_regexes,
"exclude-source=s" => \@src_exclude_regexes,
"ignore-lines-without-functions!" => \$ignore_lines_without_functions,
+ "ignore-branches-on-headers!" => \$ignore_branches_on_headers,
"show-files|show_files" => \$show_files,
"show-lines|show_lines" => \$show_lines,
"report|r=s" => \$gen_report,
@@ -1708,6 +1718,30 @@ Use B<--no-ignore-lines-without-functions> to disable it.
Disables filtering out branches that are not associated with any functions
inside the source file, but were imported via includes.
+See B<--ignore-lines-without-functions> for more details.
+
+=item B<--ignore-branches-on-headers>
+
+Branches on header files are really tricky to parse, as they depend
+on how gcc optimizes the output code. That's specially hard to use on
+Linux Kernel, as there are lots of complex macros that can be optimized
+on different ways. There are even some cases where the same macro sometimes
+have zero branches, while on other cases it can contain dozen ones.
+
+When this option is selected, all branches inside header files will be
+ignored.
+
+Please notice that this is enabled by default.
+
+Use B<--no-ignore-branches-on-headers> to disable this filter, preserving
+data from all branches.
+
+=item B<--no-ignore-branches-on-headers>
+
+Disables filtering out branches that are inside header files.
+
+See B<--ignore-branches-on-headers> for more details.
+
=back
=item B<--show-files> or B<--show_files>
--
2.39.0
next prev parent reply other threads:[~2023-01-17 14:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 14:05 [igt-dev] [PATCH i-g-t 00/12] Improve code coverage tool Mauro Carvalho Chehab
2023-01-17 14:05 ` [igt-dev] [PATCH i-g-t 01/12] code_cov_parse_info: silent some messages by default Mauro Carvalho Chehab
2023-01-17 14:05 ` [igt-dev] [PATCH i-g-t 02/12] code_cov_parse_info: do some renames to make it more coherent Mauro Carvalho Chehab
2023-01-17 14:05 ` [igt-dev] [PATCH i-g-t 03/12] code_cov_parse_info: use numberic sort for line numbers Mauro Carvalho Chehab
2023-01-17 14:05 ` [igt-dev] [PATCH i-g-t 04/12] code_cov_parse_info: better handle include regexes Mauro Carvalho Chehab
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 05/12] code_cov_parse_info: add a tool to analyze branch coverage Mauro Carvalho Chehab
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 06/12] code_cov_parse_info: add support for parsing JSON files Mauro Carvalho Chehab
2023-01-25 14:18 ` Kamil Konieczny
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 07/12] code_cov_parse_info: add support for compressed files Mauro Carvalho Chehab
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 08/12] code_cov_parse_info: allow specifying the source directory Mauro Carvalho Chehab
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 09/12] code_cov_parse_info: better handle branch filtering Mauro Carvalho Chehab
2023-01-17 14:06 ` Mauro Carvalho Chehab [this message]
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 11/12] code_cov_parse_info: add support for filtering branches Mauro Carvalho Chehab
2023-01-17 14:06 ` [igt-dev] [PATCH i-g-t 12/12] code_cov_parse_info: add support for filtering Xe driver data Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230117140607.2759816-11-mauro.chehab@linux.intel.com \
--to=mauro.chehab@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox