From: <obe...@us...> - 2003-12-19 12:50:31
|
Update of /cvsroot/ltp/utils/analysis/lcov/bin In directory sc8-pr-cvs1:/tmp/cvs-serv2456/bin Modified Files: geninfo lcov Log Message: Added changes by Laurent Deniel: - a small patch to lcov 1.1 that introduces the --follow option (in lcov & geninfo) to control whether or not links should be followed while searching for .da files. - a workaround for a gcov (3.2) bug which aborts with empty .da files (gcov 3.3 is fixed but many distributions include gcc 3.2) Index: geninfo =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/geninfo,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- geninfo 21 Nov 2003 19:34:59 -0000 1.7 +++ geninfo 19 Dec 2003 12:50:28 -0000 1.8 @@ -38,6 +38,8 @@ # 2003-07-03 / Peter Oberparleiter: added line checksum support, added # --no-checksum # 2003-09-18 / Nigel Hinds: capture branch coverage data from GCOV +# 2003-12-11 / Laurent Deniel: added --follow option +# workaround gcov (<= 3.2.x) bug with empty .da files # use strict; @@ -75,6 +77,7 @@ our $help; our $output_filename; our $version; +our $follow; our $nochecksum; our $preserve_paths; @@ -95,7 +98,8 @@ "no-checksum" => \$nochecksum, "version" =>\$version, "quiet" => \$quiet, - "help" => \$help + "help" => \$help, + "follow" => \$follow )) { print_usage(*STDERR); @@ -122,6 +126,16 @@ #$test_name .= "__".`uname -a`; #$test_name =~ s/\W/_/g; +# Check for follow option +if ($follow) +{ + $follow = "-follow" +} +else +{ + $follow = ""; +} + # Check for directory name if (!@data_directory) { @@ -204,6 +218,7 @@ -q, --quiet Do not print progress messages -t, --test-name NAME Use test case name NAME for resulting data -o, --output-filename OUTFILE Write data only to OUTFILE + -f, --follow Follow links when searching .da files -n, --no-checksum Do not calculate checksum for each line See $lcov_url for more information about this tool. @@ -251,7 +266,7 @@ my @file_list; info("Scanning $directory for .da files ...\n"); - @file_list = `find $directory -follow -name \\*.da -type f 2>/dev/null`; + @file_list = `find $directory $follow -name \\*.da -type f 2>/dev/null`; chomp(@file_list); @file_list or die("ERROR: no .da files found in $directory!\n"); @@ -296,6 +311,7 @@ my @unprocessed; # List of unprocessed source code files my @result; my $index; + my $da_renamed; # If .da file is to be renamed local *INFO_HANDLE; # Get path to .da file in absolute and normalized form (begins with /, @@ -312,6 +328,15 @@ die("ERROR: cannot write to directory $da_dir!\n"); } + if (-z $da_filename) + { + $da_renamed = 1; + } + else + { + $da_renamed = 0; + } + # Construct name of .bb file $bb_filename = $da_dir."/".$da_basename.".bb"; @@ -345,6 +370,14 @@ # Change to directory containing .da files and apply GCOV chdir($object_dir); + if ($da_renamed) + { + # Need to rename empty .da file to workaround + # gcov <= 3.2.x bug (Abort) + system_no_output(3, "mv", "$da_filename", "$da_filename.ori") + and die ("ERROR: cannot rename $da_filename"); + } + # Execute gcov command and suppress standard output if ($preserve_paths) { @@ -358,6 +391,12 @@ $gcov_error = system_no_output(1, $gcov_tool, $da_basename.".c", "-o", $object_dir, "-b"); + } + + if ($da_renamed) + { + system_no_output(3, "mv", "$da_filename.ori", "$da_filename") + and die ("ERROR: cannot rename $da_filename.ori"); } # Clean up link Index: lcov =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/lcov,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- lcov 10 Oct 2003 14:18:32 -0000 1.5 +++ lcov 19 Dec 2003 12:50:28 -0000 1.6 @@ -50,6 +50,7 @@ # 2003-06-27 / Peter Oberparleiter: implemented --diff # 2003-07-03 / Peter Oberparleiter: added line checksum support, added # --no-checksum +# 2003-12-11 / Laurent Deniel: added --follow option # use strict; @@ -134,6 +135,7 @@ our $temp_dir_name; # Name of temporary directory our $cwd = `pwd`; # Current working directory our $to_file; # If set, indicates that output is written to a file +our $follow; # If set, indicates that find shall follow links chomp($cwd); our $tool_dir = dirname($0); # Directory where genhtml tool is installed @@ -165,7 +167,8 @@ "zerocounters" => \$reset, "quiet" => \$quiet, "help" => \$help, - "version" => \$version + "version" => \$version, + "follow" => \$follow )) { print_usage(*STDERR); @@ -261,6 +264,11 @@ info("Done.\n"); exit(0); +# Check for follow option +if ($follow) +{ + $follow = "--follow"; +} # # print_usage(handle) @@ -288,6 +296,7 @@ -t, --test-name NAME Specify test name to be stored with data -o, --output-file FILENAME Write data to FILENAME instead of stdout -d, --directory DIR Use .da files in DIR instead of kernel + -f, --follow Follow links when searching .da files -k, --kernel-directory KDIR Capture kernel coverage data only from KDIR -a, --add-tracefile FILE Add contents of tracefiles -e, --extract FILE PATTERN Extract files matching PATTERN from FILE @@ -355,8 +364,16 @@ { info("Deleting all .da files in $current_dir and ". "subdirectories\n"); - @file_list = - `find $current_dir -follow -name \\*.da -type f 2>/dev/null`; + if ($follow) + { + @file_list = + `find $current_dir -follow -name \\*.da -type f 2>/dev/null`; + } + else + { + @file_list = + `find $current_dir -name \\*.da -type f 2>/dev/null`; + } chomp(@file_list); foreach (@file_list) { @@ -385,11 +402,15 @@ if ($output_filename) { @param = (@param, "--output-filename", $output_filename); - }; + } if ($test_name) { @param = (@param, "--test-name", $test_name); } + if ($follow) + { + @param = (@param, "--follow"); + } if ($quiet) { @param = (@param, "--quiet"); @@ -505,10 +526,14 @@ if ($output_filename) { @param = (@param, "--output-filename", $output_filename); - }; + } if ($test_name) { @param = (@param, "--test-name", $test_name); + } + if ($follow) + { + @param = (@param, "--follow"); } if ($quiet) { |