@@ -287,6 +287,7 @@ our @opt_ignore_errors; # Ignore certain error classes during processing
287
287
our @ignore ;
288
288
our $opt_config_file ; # User-specified configuration file location
289
289
our %opt_rc ;
290
+ our $opt_missed ; # List/sort lines by missed counts
290
291
our $charset = " UTF-8" ; # Default charset for HTML pages
291
292
our @fileview_sortlist ;
292
293
our @fileview_sortname = (" " , " -sort-l" , " -sort-f" , " -sort-b" );
@@ -374,6 +375,7 @@ if ($config || %opt_rc)
374
375
" genhtml_charset" => \$charset ,
375
376
" genhtml_desc_html" => \$rc_desc_html ,
376
377
" genhtml_demangle_cpp" => \$demangle_cpp ,
378
+ " genhtml_missed" => \$opt_missed ,
377
379
" lcov_function_coverage" => \$lcov_func_coverage ,
378
380
" lcov_branch_coverage" => \$lcov_branch_coverage ,
379
381
});
@@ -420,6 +422,7 @@ if (!GetOptions("output-directory|o=s" => \$output_directory,
420
422
" config-file=s" => \$opt_config_file ,
421
423
" rc=s%" => \%opt_rc ,
422
424
" precision=i" => \$default_precision ,
425
+ " missed" => \$opt_missed ,
423
426
))
424
427
{
425
428
print (STDERR " Use $tool_name --help to get usage information\n " );
@@ -621,6 +624,7 @@ HTML output:
621
624
--(no-)sort Enable (disable) sorted coverage views
622
625
--demangle-cpp Demangle C++ function names
623
626
--precision NUM Set precision of coverage rate
627
+ --missed Show miss counts as negative numbers
624
628
625
629
For more information see: $lcov_url
626
630
END_OF_USAGE
@@ -3732,6 +3736,10 @@ END_OF_HTML
3732
3736
$class = $rate_name [classify_rate($found , $hit ,
3733
3737
$med , $hi )];
3734
3738
}
3739
+ if ($opt_missed ) {
3740
+ # Show negative number of items without coverage
3741
+ $hit = -($found - $hit );
3742
+ }
3735
3743
write_html($handle , <<END_OF_HTML );
3736
3744
<td class="coverPer$class ">$rate </td>
3737
3745
<td class="coverNum$class ">$hit / $found </td>
@@ -4632,10 +4640,57 @@ END_OF_HTML
4632
4640
write_header_epilog(*HTML_HANDLE, $base_dir );
4633
4641
}
4634
4642
4643
+ sub get_sorted_by_rate ($$)
4644
+ {
4645
+ my ($hash , $type ) = @_ ;
4646
+
4647
+ if ($type == $SORT_LINE ) {
4648
+ # Sort by line coverage
4649
+ return sort ({$hash -> {$a }[7] <=> $hash -> {$b }[7]} keys (%{$hash }));
4650
+ } elsif ($type == $SORT_FUNC ) {
4651
+ # Sort by function coverage;
4652
+ return sort ({$hash -> {$a }[8] <=> $hash -> {$b }[8]} keys (%{$hash }));
4653
+ } elsif ($type == $SORT_BRANCH ) {
4654
+ # Sort by br coverage;
4655
+ return sort ({$hash -> {$a }[9] <=> $hash -> {$b }[9]} keys (%{$hash }));
4656
+ }
4657
+ }
4658
+
4659
+ sub get_sorted_by_missed ($$)
4660
+ {
4661
+ my ($hash , $type ) = @_ ;
4662
+
4663
+ if ($type == $SORT_LINE ) {
4664
+ # Sort by number of instrumented lines without coverage
4665
+ return sort (
4666
+ {
4667
+ ($hash -> {$b }[0] - $hash -> {$b }[1]) <=>
4668
+ ($hash -> {$a }[0] - $hash -> {$a }[1])
4669
+ } keys (%{$hash }));
4670
+ } elsif ($type == $SORT_FUNC ) {
4671
+ # Sort by number of instrumented functions without coverage
4672
+ return sort (
4673
+ {
4674
+ ($hash -> {$b }[2] - $hash -> {$b }[3]) <=>
4675
+ ($hash -> {$a }[2] - $hash -> {$a }[3])
4676
+ } keys (%{$hash }));
4677
+ } elsif ($type == $SORT_BRANCH ) {
4678
+ # Sort by number of instrumented branches without coverage
4679
+ return sort (
4680
+ {
4681
+ ($hash -> {$b }[4] - $hash -> {$b }[5]) <=>
4682
+ ($hash -> {$a }[4] - $hash -> {$a }[5])
4683
+ } keys (%{$hash }));
4684
+ }
4685
+ }
4635
4686
4636
4687
#
4637
4688
# get_sorted_keys(hash_ref, sort_type)
4638
4689
#
4690
+ # hash_ref: filename -> stats
4691
+ # stats: [ lines_found, lines_hit, fn_found, fn_hit, br_found, br_hit,
4692
+ # link_name, line_rate, fn_rate, br_rate ]
4693
+ #
4639
4694
4640
4695
sub get_sorted_keys ($$)
4641
4696
{
@@ -4644,15 +4699,10 @@ sub get_sorted_keys($$)
4644
4699
if ($type == $SORT_FILE ) {
4645
4700
# Sort by name
4646
4701
return sort (keys (%{$hash }));
4647
- } elsif ($type == $SORT_LINE ) {
4648
- # Sort by line coverage
4649
- return sort ({$hash -> {$a }[7] <=> $hash -> {$b }[7]} keys (%{$hash }));
4650
- } elsif ($type == $SORT_FUNC ) {
4651
- # Sort by function coverage;
4652
- return sort ({$hash -> {$a }[8] <=> $hash -> {$b }[8]} keys (%{$hash }));
4653
- } elsif ($type == $SORT_BRANCH ) {
4654
- # Sort by br coverage;
4655
- return sort ({$hash -> {$a }[9] <=> $hash -> {$b }[9]} keys (%{$hash }));
4702
+ } elsif ($opt_missed ) {
4703
+ return get_sorted_by_missed($hash , $type );
4704
+ } else {
4705
+ return get_sorted_by_rate($hash , $type );
4656
4706
}
4657
4707
}
4658
4708
0 commit comments