Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ LCOV features and capabilities fall into 7 major categories:
--baseline-title, --baseline-date, --current-date,
--flat, --hierarchical,
--show-owners, --show-noncode, --show-navigation, --show-proportion,
--suppress-aliases
--suppress-aliases --simplify-script

d) Data manipulation

Expand Down Expand Up @@ -421,8 +421,10 @@ LCOV features and capabilities fall into 7 major categories:
the changes caused by a particular commit or range of commits,
or to review changes in a particular release.
Sample script: select.pm
vi) keep track of environment and other settings - to aid
vi) keep track of environment and other settings - to aid
infrastructure debugging in more complicated use cases.
vii) compress the 'function detail' table to improve readability
by shortening long C++ template and function names.

The callback may be any desired script or executable - but there
may be performance advantages if it is written as a Perl module.
Expand All @@ -436,6 +438,7 @@ LCOV features and capabilities fall into 7 major categories:
Related options:
--annotate-script, --criteria-script, --version-script
--resolve-script, --select-script, --context-script
--simplify-script

f) Performance

Expand Down
169 changes: 105 additions & 64 deletions bin/genhtml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ sub write_overview(*$$$$);
# External prototype (defined in genpng)
sub gen_png($$$$$@);

sub simplify_function_name($);

package SummaryInfo;

our @selectCallbackScript;
Expand Down Expand Up @@ -5471,7 +5473,7 @@ sub _computeAge
if ($then > $now) {
if (lcovutil::warn_once($lcovutil::ERROR_INCONSISTENT_DATA, $path)) {
# issue annotation warning at most once per file
# also attempt to clarify where the date comes from
# also attempt to clarify where the date comes from
my $data =
exists($ENV{SOURCE_DATE_EPOCH}) ?
(
Expand Down Expand Up @@ -6853,10 +6855,14 @@ our @rate_png = ("ruby.png", "amber.png", "emerald.png");
our $rc_desc_html = 0; # lcovrc: genhtml_desc_html
our $deprecated_highlight; # ignored former option

our $cwd = cwd(); # Current working directory
# simplify/shorten names in 'function detail table'
our @simplifyFunctionScript; # the arg list
our $simplifyFunctionCallback; # the actual callback

our $cwd = cwd(); # Current working directory

# for debugging
our $verboseScopeRegexp; # dump categorization processing if match
our $verboseScopeRegexp; # dump categorization processing if match

#
# Code entry point
Expand All @@ -6869,7 +6875,8 @@ STDERR->autoflush;
STDOUT->autoflush;

my @datebins;
my (@rc_date_bins, @rc_annotate_script, @rc_select_script, @rc_date_labels);
my (@rc_date_bins, @rc_annotate_script, @rc_select_script, @rc_date_labels,
@rc_simplifyFunctionScript);

my %genhtml_rc_opts = (
"genhtml_css_file" => \$css_filename,
Expand Down Expand Up @@ -6925,6 +6932,7 @@ my %genhtml_rc_opts = (
'genhtml_annotate_script' => \@rc_annotate_script,
'genhtml_annotate_tooltip' => \$SourceFile::annotateTooltip,
"select_script" => \@rc_select_script,
"simplify_function" => \@rc_simplifyFunctionScript,
'num_context_lines' => \$InInterestingRegion::num_context_lines,
'genhtml_date_bins' => \@rc_date_bins,
'genhtml_date_labels' => \@rc_date_labels,
Expand All @@ -6938,60 +6946,62 @@ my $save;
my $serialize;
my $validateHTML = exists($ENV{LCOV_VALIDATE});

my %genhtml_options = ("output-directory|o=s" => \$output_directory,
"header-title=s" => \$header_title,
"footer=s" => \$footer,
"title|t=s" => \$test_title,
"description-file|d=s" => \$desc_filename,
"keep-descriptions|k" => \$keep_descriptions,
"css-file|c=s" => \$css_filename,
"baseline-file|b=s" => \@base_filenames,
"baseline-title=s" => \$baseline_title,
"baseline-date=s" => \$baseline_date,
"current-date=s" => \$current_date,
"diff-file=s" => \$diff_filename,
"annotate-script=s" => \@SourceFile::annotateScript,
"select-script=s" => \@selectCallbackScript,
"new-file-as-baseline" => \$treatNewFileAsBaseline,
'elide-path-mismatch' => \$elide_path_mismatch,
'synthesize-missing' => \$synthesizeMissingFile,
# if 'show-owners' is set: generate the owner table
# if it is passed a value: show all the owners,
# regardless of whether they have uncovered code or not
'show-owners:s' => \$show_ownerBins,
'show-noncode' => \$show_nonCodeOwners,
'show-zero-columns' => \$show_zeroTlaColumns,
'simplified-colors' => \$show_simplifiedColors,
"date-bins=s" => \@datebins,
'date-labels=s' => \@SummaryInfo::ageGroupHeader,
"prefix|p=s" => \@opt_dir_prefix,
"num-spaces=i" => \$tab_size,
"no-prefix" => \$no_prefix,
"no-sourceview" => \$no_sourceview,
'no-html' => \$no_html,
"show-details|s" => \$show_details,
"frames|f" => \$frames,
"highlight" => \$deprecated_highlight,
"legend" => \$legend,
'save' => \$save,
'serialize=s' => \$serialize,
'scheduler+' => \$debugScheduler,
"html-prolog=s" => \$html_prolog_file,
"html-epilog=s" => \$html_epilog_file,
"html-extension=s" => \$html_ext,
"html-gzip" => \$html_gzip,
"hierarchical" => \$hierarchical,
"flat" => \$flat,
"sort-tables" => \$sort_tables,
"no-sort" => \$no_sort,
"precision=i" => \$lcovutil::default_precision,
"missed" => \$opt_missed,
"dark-mode" => \$dark_mode,
"show-navigation" => \$show_tla,
"show-proportion" => \$show_functionProportions,
"merge-aliases" => \$merge_function_aliases,
"suppress-aliases" => \$suppress_function_aliases,
'validate' => \$validateHTML,);
my %genhtml_options = (
"output-directory|o=s" => \$output_directory,
"header-title=s" => \$header_title,
"footer=s" => \$footer,
"title|t=s" => \$test_title,
"description-file|d=s" => \$desc_filename,
"keep-descriptions|k" => \$keep_descriptions,
"css-file|c=s" => \$css_filename,
"baseline-file|b=s" => \@base_filenames,
"baseline-title=s" => \$baseline_title,
"baseline-date=s" => \$baseline_date,
"current-date=s" => \$current_date,
"diff-file=s" => \$diff_filename,
"annotate-script=s" => \@SourceFile::annotateScript,
"select-script=s" => \@SummaryInfo::selectCallbackScript,
"simplify-script=s" => \@simplifyFunctionScript,
"new-file-as-baseline" => \$treatNewFileAsBaseline,
'elide-path-mismatch' => \$elide_path_mismatch,
'synthesize-missing' => \$synthesizeMissingFile,
# if 'show-owners' is set: generate the owner table
# if it is passed a value: show all the owners,
# regardless of whether they have uncovered code or not
'show-owners:s' => \$show_ownerBins,
'show-noncode' => \$show_nonCodeOwners,
'show-zero-columns' => \$show_zeroTlaColumns,
'simplified-colors' => \$show_simplifiedColors,
"date-bins=s" => \@datebins,
'date-labels=s' => \@SummaryInfo::ageGroupHeader,
"prefix|p=s" => \@opt_dir_prefix,
"num-spaces=i" => \$tab_size,
"no-prefix" => \$no_prefix,
"no-sourceview" => \$no_sourceview,
'no-html' => \$no_html,
"show-details|s" => \$show_details,
"frames|f" => \$frames,
"highlight" => \$deprecated_highlight,
"legend" => \$legend,
'save' => \$save,
'serialize=s' => \$serialize,
'scheduler+' => \$debugScheduler,
"html-prolog=s" => \$html_prolog_file,
"html-epilog=s" => \$html_epilog_file,
"html-extension=s" => \$html_ext,
"html-gzip" => \$html_gzip,
"hierarchical" => \$hierarchical,
"flat" => \$flat,
"sort-tables" => \$sort_tables,
"no-sort" => \$no_sort,
"precision=i" => \$lcovutil::default_precision,
"missed" => \$opt_missed,
"dark-mode" => \$dark_mode,
"show-navigation" => \$show_tla,
"show-proportion" => \$show_functionProportions,
"merge-aliases" => \$merge_function_aliases,
"suppress-aliases" => \$suppress_function_aliases,
'validate' => \$validateHTML,);

# remove ambiguous entry from common table -
# (genhtml has '--sort-inputs' and '--sort-tables')
Expand Down Expand Up @@ -7041,18 +7051,28 @@ $frames = undef unless (defined($frames) && $frames);
foreach my $rc ([\@datebins, \@rc_date_bins],
[\@SummaryInfo::ageGroupHeader, \@rc_date_labels],
[\@SourceFile::annotateScript, \@rc_annotate_script],
[\@selectCallbackScript, \@rc_select_script]
[\@SummaryInfo::selectCallbackScript, \@rc_select_script],
[\@simplifyFunctionScript, \@rc_simplifyFunctionScript],

) {
@{$rc->[0]} = @{$rc->[1]} unless (@{$rc->[0]});
}

foreach my $cb ([\$SourceFile::annotateCallback, \@SourceFile::annotateScript],
[\$selectCallback, \@selectCallbackScript]) {
[\$SummaryInfo::selectCallback,
\@SummaryInfo::selectCallbackScript
],
[\$simplifyFunctionCallback, \@simplifyFunctionScript],
) {
lcovutil::configure_callback($cb->[0], @{$cb->[1]})
if scalar(@{$cb->[1]});
}

# we won't apply simplifications if we don't generate the table
# (we still check that the callback is valid - even though we don't use it)
$simplifyFunctionCallback = undef
if $no_sourceview;

if (defined($lcovutil::stop_on_error) &&
!$lcovutil::stop_on_error) {
# in the spirit of "don't stop" - don't worry about missing files.
Expand Down Expand Up @@ -8384,7 +8404,7 @@ sub read_testfile($)
local *TEST_HANDLE;

open(TEST_HANDLE, "<", $file) or
die("cannot open $file]: $!\n");
die("cannot open description file '$file': $!\n");

while (<TEST_HANDLE>) {
chomp($_);
Expand Down Expand Up @@ -13322,7 +13342,7 @@ sub write_source($$$$$$$$)
my $cbdata = PrintCallback->new($srcfile, $fileCovInfo);

my ($region, $empty);
if ($selectCallback) {
if ($SummaryInfo::selectCallback) {
$region = InInterestingRegion->new($srcfile, $fileCovInfo->lineMap());
$empty = '';
if ($srcfile->isProjectFile()) {
Expand Down Expand Up @@ -13583,7 +13603,7 @@ END_OF_HTML
next
if grep(/^$tla$/, ('DUB', 'DCB')); # don't display deleted functions
my $startline = $funcEntry->line() - $func_offset;
my $name = $func;
my $name = simplify_function_name($func);
my $countstyle;

# Escape special characters
Expand Down Expand Up @@ -13701,7 +13721,7 @@ END_OF_HTML
}

# Escape special characters
$alias = escape_html($alias);
$alias = escape_html(simplify_function_name($alias));

write_html(*HTML_HANDLE, <<END_OF_HTML);
<tr>
Expand Down Expand Up @@ -13878,3 +13898,24 @@ sub parse_dir_prefix(@)
}
}
}

#
# simplify_function_name($name)
#
# apply @function_simplify_patterns to $name and return
# goal is to shorten really long demangled names/template expansions
#
sub simplify_function_name($)
{
my $name = shift;
if ($simplifyFunctionCallback) {

eval { $name = $simplifyFunctionCallback->simplify($name); };
if ($@) {
my $context = MessageContext::context();
lcovutil::ignorable_error($lcovutil::ERROR_CALLBACK,
"simplify($name) failed$context: $@");
}
}
return $name;
}
25 changes: 15 additions & 10 deletions bin/llvm2lcov
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ sub parse
}
if ($mcdc && $json_version < version->parse("3.0.1")) {
my $mcdcData = $fileInfo->testcase_mcdc($testname);
my @mcdcBranches; # array (start line, start column, expression)
my @mcdcBranches
; # array (start line, start column, expression)
foreach my $branch (@$branches) {
die("unexpected branch data")
unless scalar(@$branch) == 9;
Expand Down Expand Up @@ -273,8 +274,8 @@ sub parse
if (($brLine > $line ||
($brLine == $line && $brCol >= $startCol))
&&
($brLine < $endLine ||
($brLine == $endLine && $brCol <= $endCol))
( $brLine < $endLine ||
($brLine == $endLine && $brCol <= $endCol))
) {
push(@brExprs, [$brLine, $brCol, $brExpr]);
}
Expand Down Expand Up @@ -344,8 +345,10 @@ sub parse
$functionMap->add_count($name, $count);
}

my @mcdcBranches; # array (fileId, start line, start column, expression)
my %expanded_mcdcBranches; # hash of branch's fileId -> branch's start line
my @mcdcBranches
; # array (fileId, start line, start column, expression)
my %expanded_mcdcBranches
; # hash of branch's fileId -> branch's start line

if ($branchData) {
my $funcBranchData = BranchData->new();
Expand Down Expand Up @@ -451,15 +454,17 @@ sub parse
if (($brLine > $line ||
($brLine == $line && $brCol >= $col))
&&
($brLine < $endLine ||
($brLine == $endLine && $brCol <= $endCol))
( $brLine < $endLine ||
($brLine == $endLine &&
$brCol <= $endCol))
) {
push(@brExprs, [$brLine, $brCol, $brExpr]);
}
}
@brExprs = sort {$a->[0] <=> $b->[0] ||
$a->[1] <=> $b->[1]
} @brExprs;
@brExprs = sort {
$a->[0] <=> $b->[0] ||
$a->[1] <=> $b->[1]
} @brExprs;
$expr =
$srcReader->getExpr($line, $col,
$endLine, $endCol)
Expand Down
Loading