summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2009-08-31 15:02:01 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2009-08-31 15:02:01 +0000
commit54a5ad0c6feefe2147f04d370a19b6e34b79f99e (patch)
tree471ccb4a5bacac8b1c3df8d433b8c9ec6822e198 /pkgs/development
parent11e09ffad161583e16825aaf26a710fe64ddd6a6 (diff)
downloadnixlib-54a5ad0c6feefe2147f04d370a19b6e34b79f99e.tar
nixlib-54a5ad0c6feefe2147f04d370a19b6e34b79f99e.tar.gz
nixlib-54a5ad0c6feefe2147f04d370a19b6e34b79f99e.tar.bz2
nixlib-54a5ad0c6feefe2147f04d370a19b6e34b79f99e.tar.lz
nixlib-54a5ad0c6feefe2147f04d370a19b6e34b79f99e.tar.xz
nixlib-54a5ad0c6feefe2147f04d370a19b6e34b79f99e.tar.zst
nixlib-54a5ad0c6feefe2147f04d370a19b6e34b79f99e.zip
* Hacked up a patch to let lcov find source files referenced by a
  path relative to some arbitrary parent of the .gcno file.  For
  instance, this happens when building Subversion with coverage.

svn path=/nixpkgs/trunk/; revision=16902
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/tools/analysis/lcov/default.nix2
-rw-r--r--pkgs/development/tools/analysis/lcov/find-source.patch140
2 files changed, 142 insertions, 0 deletions
diff --git a/pkgs/development/tools/analysis/lcov/default.nix b/pkgs/development/tools/analysis/lcov/default.nix
index 439238b524f6..d611f92d0516 100644
--- a/pkgs/development/tools/analysis/lcov/default.nix
+++ b/pkgs/development/tools/analysis/lcov/default.nix
@@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "1cx3haizs0rw6wjsn486qcn50f3qpybflkkb1780cg6s8jzcwdin";
   };
 
+  patches = [ ./find-source.patch ];
+
   preBuild = ''
     makeFlagsArray=(PREFIX=$out BIN_DIR=$out/bin MAN_DIR=$out/share/man)
   '';
diff --git a/pkgs/development/tools/analysis/lcov/find-source.patch b/pkgs/development/tools/analysis/lcov/find-source.patch
new file mode 100644
index 000000000000..015e255824c9
--- /dev/null
+++ b/pkgs/development/tools/analysis/lcov/find-source.patch
@@ -0,0 +1,140 @@
+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}))
+  					{