nixpkgs/pkgs/development/tools/analysis/lcov/find-source.patch

141 lines
3.5 KiB
Diff
Raw Normal View History

diff -x '*~' -rc lcov-1.7-orig/bin/geninfo lcov-1.7/bin/geninfo
*** lcov-1.7-orig/bin/geninfo 2008-11-17 14:50:26.000000000 +0100
--- lcov-1.7/bin/geninfo 2009-08-28 18:33:21.000000000 +0200
***************
*** 51,56 ****
--- 51,57 ----
use strict;
use File::Basename;
+ use Cwd qw(abs_path);
use Getopt::Long;
use Digest::MD5 qw(md5_base64);
***************
*** 81,86 ****
--- 82,88 ----
sub solve_ambiguous_match($$$);
sub split_filename($);
sub solve_relative_path($$);
+ sub find_source_file($$);
sub get_dir($);
sub read_gcov_header($);
sub read_gcov_file($);
***************
*** 724,730 ****
if (defined($source))
{
! $source = solve_relative_path($base_dir, $source);
}
# gcov will happily create output even if there's no source code
--- 726,732 ----
if (defined($source))
{
! $source = find_source_file($base_dir, $source);
}
# gcov will happily create output even if there's no source code
***************
*** 741,758 ****
die("ERROR: could not read source file $source\n");
}
! @matches = match_filename(defined($source) ? $source :
! $gcov_file, keys(%bb_content));
# Skip files that are not mentioned in the graph file
! if (!@matches)
! {
! warn("WARNING: cannot find an entry for ".$gcov_file.
! " in $graph_file_extension file, skipping ".
! "file!\n");
! unlink($gcov_file);
! next;
! }
# Read in contents of gcov file
@result = read_gcov_file($gcov_file);
--- 743,764 ----
die("ERROR: could not read source file $source\n");
}
! next if ! -r $source;
!
! #@matches = match_filename(defined($source) ? $source :
! # $gcov_file, keys(%bb_content));
# Skip files that are not mentioned in the graph file
! #if (!@matches)
! #{
! # warn("WARNING: cannot find an entry for ".$gcov_file.
! # " in $graph_file_extension file, skipping ".
! # "file!\n");
! # unlink($gcov_file);
! # next;
! #}
!
! @matches = ($source);
# Read in contents of gcov file
@result = read_gcov_file($gcov_file);
***************
*** 949,954 ****
--- 955,974 ----
}
+ sub find_source_file($$)
+ {
+ my ($base_dir, $source) = @_;
+ my $dir = $base_dir;
+ while (!-e "$dir/$source") {
+ $dir = $dir . "/..";
+ if (length $dir > 1000) {
+ return "$base_dir/$source";
+ }
+ }
+ return abs_path("$dir/$source");
+ }
+
+
#
# match_filename(gcov_filename, list)
#
***************
*** 1478,1484 ****
$function_name =~ s/\W/_/g;
(undef, $filename) =
read_gcno_string(*INPUT, $endianness);
! $filename = solve_relative_path($base_dir, $filename);
read(INPUT, $packed_word, 4);
$lineno = unpack_int32($packed_word, $endianness);
--- 1498,1504 ----
$function_name =~ s/\W/_/g;
(undef, $filename) =
read_gcno_string(*INPUT, $endianness);
! $filename = find_source_file($base_dir, $filename);
read(INPUT, $packed_word, 4);
$lineno = unpack_int32($packed_word, $endianness);
***************
*** 1530,1536 ****
}
if ($blocks > 1)
{
! $filename = solve_relative_path(
$base_dir, $filename);
if (!defined($result{$filename}))
{
--- 1550,1556 ----
}
if ($blocks > 1)
{
! $filename = find_source_file(
$base_dir, $filename);
if (!defined($result{$filename}))
{