From: Peter O. <obe...@us...> - 2012-01-20 11:54:00
|
Update of /cvsroot/ltp/utils/analysis/lcov/bin In directory vz-cvs-4.sog:/tmp/cvs-serv12248 Modified Files: geninfo lcov Log Message: lcov: add new command line option --compat Add new option to lcov and geninfo to specify compatibility settings. Supported settings: libtool: same as --compat-libtool hammer: gcc3.3 hammer patch compatibility android_4_4_0: android toolchain 4_4_0 compatibility Index: geninfo =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/geninfo,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** geninfo 11 Aug 2011 08:29:21 -0000 1.94 --- geninfo 20 Jan 2012 11:53:57 -0000 1.95 *************** *** 74,79 **** our $BBG_FILE_MAGIC = 0x67626267; - our $COMPAT_HAMMER = "hammer"; - # Error classes which users may specify to ignore during processing our $ERROR_GCOV = 0; --- 74,77 ---- *************** *** 90,93 **** --- 88,128 ---- our $EXCL_LINE = "LCOV_EXCL_LINE"; + # Compatibility setting values + our $COMPAT_VALUE_OFF = 0; + our $COMPAT_VALUE_ON = 1; + our $COMPAT_VALUE_AUTO = 2; + + # Compatibility setting value names + our %COMPAT_NAME_TO_VALUE = ( + "off" => $COMPAT_VALUE_OFF, + "on" => $COMPAT_VALUE_ON, + "auto" => $COMPAT_VALUE_AUTO, + ); + + # Compatiblity setting flags + our $COMPAT_FLAG_LIBTOOL = 1 << 0; + our $COMPAT_FLAG_HAMMER = 1 << 1; + our $COMPAT_FLAG_ANDROID_4_4_0 = 1 << 2; + + # Compatibility setting flag names + our %COMPAT_NAME_TO_FLAG = ( + "libtool" => $COMPAT_FLAG_LIBTOOL, + "hammer" => $COMPAT_FLAG_HAMMER, + "android_4_4_0" => $COMPAT_FLAG_ANDROID_4_4_0, + ); + + # Compatibility setting default values + our %COMPAT_FLAG_DEFAULTS = ( + $COMPAT_FLAG_LIBTOOL => $COMPAT_VALUE_ON, + $COMPAT_FLAG_HAMMER => $COMPAT_VALUE_OFF, + $COMPAT_FLAG_ANDROID_4_4_0 => $COMPAT_VALUE_OFF, + ); + + # Compatibility setting autodetection routines + sub compat_hammer_autodetect(); + our %COMPAT_FLAG_AUTO = ( + $COMPAT_FLAG_HAMMER => \&compat_hammer_autodetect, + ); + our $BR_LINE = 0; our $BR_BLOCK = 1; *************** *** 154,161 **** --- 189,200 ---- sub parse_ignore_errors(@); sub is_external($); + sub compat_name($); + sub parse_compat_flags($); + sub is_compat($); # Global variables our $gcov_version; + our $gcov_version_string; our $graph_file_extension; our $data_file_extension; *************** *** 170,179 **** our $checksum; our $no_checksum; ! our $compat_libtool; ! our $no_compat_libtool; our $adjust_testname; our $config; # Configuration file contents - our $compatibility; # Compatibility version flag - used to indicate - # non-standard GCOV data format versions our @ignore_errors; # List of errors to ignore (parameter) our @ignore; # List of errors to ignore (array) --- 209,216 ---- our $checksum; our $no_checksum; ! our $opt_compat_libtool; ! our $opt_no_compat_libtool; our $adjust_testname; our $config; # Configuration file contents our @ignore_errors; # List of errors to ignore (parameter) our @ignore; # List of errors to ignore (array) *************** *** 191,194 **** --- 228,233 ---- our $opt_config_file; our $opt_gcov_all_blocks = 1; + our $opt_compat; + our %compat_value; our $cwd = `pwd`; *************** *** 236,242 **** "geninfo_checksum" => \$checksum, "geninfo_no_checksum" => \$no_checksum, # deprecated ! "geninfo_compat_libtool" => \$compat_libtool, "geninfo_external" => \$opt_external, "geninfo_gcov_all_blocks" => \$opt_gcov_all_blocks, }); --- 275,282 ---- "geninfo_checksum" => \$checksum, "geninfo_no_checksum" => \$no_checksum, # deprecated ! "geninfo_compat_libtool" => \$opt_compat_libtool, "geninfo_external" => \$opt_external, "geninfo_gcov_all_blocks" => \$opt_gcov_all_blocks, + "geninfo_compat" => \$opt_compat, }); *************** *** 259,264 **** "help|h|?" => \$help, "follow|f" => \$follow, ! "compat-libtool" => \$compat_libtool, ! "no-compat-libtool" => \$no_compat_libtool, "gcov-tool=s" => \$gcov_tool, "ignore-errors=s" => \@ignore_errors, --- 299,304 ---- "help|h|?" => \$help, "follow|f" => \$follow, ! "compat-libtool" => \$opt_compat_libtool, ! "no-compat-libtool" => \$opt_no_compat_libtool, "gcov-tool=s" => \$gcov_tool, "ignore-errors=s" => \@ignore_errors, *************** *** 270,273 **** --- 310,314 ---- "external" => \$opt_external, "no-external" => \$opt_no_external, + "compat=s" => \$opt_compat, )) { *************** *** 284,291 **** } ! if (defined($no_compat_libtool)) { ! $compat_libtool = ($no_compat_libtool ? 0 : 1); ! $no_compat_libtool = undef; } --- 325,332 ---- } ! if (defined($opt_no_compat_libtool)) { ! $opt_compat_libtool = ($opt_no_compat_libtool ? 0 : 1); ! $opt_no_compat_libtool = undef; } *************** *** 312,315 **** --- 353,375 ---- } + # Check gcov tool + if (system_no_output(3, $gcov_tool, "--help") == -1) + { + die("ERROR: need tool $gcov_tool!\n"); + } + + ($gcov_version, $gcov_version_string) = get_gcov_version(); + + # Determine gcov options + $gcov_caps = get_gcov_capabilities(); + push(@gcov_options, "-b") if ($gcov_caps->{'branch-probabilities'}); + push(@gcov_options, "-c") if ($gcov_caps->{'branch-counts'}); + push(@gcov_options, "-a") if ($gcov_caps->{'all-blocks'} && + $opt_gcov_all_blocks); + push(@gcov_options, "-p") if ($gcov_caps->{'preserve-paths'}); + + # Determine compatibility flags + parse_compat_flags($opt_compat); + # Determine which errors the user wants us to ignore parse_ignore_errors(@ignore_errors); *************** *** 356,370 **** } - # Determine libtool compatibility mode - if (defined($compat_libtool)) - { - $compat_libtool = ($compat_libtool? 1 : 0); - } - else - { - # Default is on - $compat_libtool = 1; - } - # Determine max depth for recursion if ($no_recursion) --- 416,419 ---- *************** *** 395,408 **** } - if (system_no_output(3, $gcov_tool, "--help") == -1) - { - die("ERROR: need tool $gcov_tool!\n"); - } - - $gcov_version = get_gcov_version(); - if ($gcov_version < $GCOV_VERSION_3_4_0) { ! if (defined($compatibility) && $compatibility eq $COMPAT_HAMMER) { $data_file_extension = ".da"; --- 444,450 ---- } if ($gcov_version < $GCOV_VERSION_3_4_0) { ! if (is_compat($COMPAT_FLAG_HAMMER)) { $data_file_extension = ".da"; *************** *** 421,432 **** } - # Determine gcov options - $gcov_caps = get_gcov_capabilities(); - push(@gcov_options, "-b") if ($gcov_caps->{'branch-probabilities'}); - push(@gcov_options, "-c") if ($gcov_caps->{'branch-counts'}); - push(@gcov_options, "-a") if ($gcov_caps->{'all-blocks'} && - $opt_gcov_all_blocks); - push(@gcov_options, "-p") if ($gcov_caps->{'preserve-paths'}); - # Check output filename if (defined($output_filename) && ($output_filename ne "-")) --- 463,466 ---- *************** *** 793,797 **** # avoid files from .libs dirs ! if ($compat_libtool && $da_dir =~ m/(.*)\/\.libs$/) { $source_dir = $1; } else { --- 827,831 ---- # avoid files from .libs dirs ! if (is_compat($COMPAT_FLAG_LIBTOOL) && $da_dir =~ m/(.*)\/\.libs$/) { $source_dir = $1; } else { *************** *** 851,855 **** if ($gcov_version < $GCOV_VERSION_3_4_0) { ! if (defined($compatibility) && $compatibility eq $COMPAT_HAMMER) { ($instr, $graph) = read_bbg($bb_filename, $base_dir); --- 885,889 ---- if ($gcov_version < $GCOV_VERSION_3_4_0) { ! if (is_compat($COMPAT_FLAG_HAMMER)) { ($instr, $graph) = read_bbg($bb_filename, $base_dir); *************** *** 1779,1789 **** } } ! if ($version_string =~ /suse/i && $result == 0x30303 || ! $version_string =~ /mandrake/i && $result == 0x30302) ! { ! info("Using compatibility mode for GCC 3.3 (hammer)\n"); ! $compatibility = $COMPAT_HAMMER; ! } ! return $result; } --- 1813,1817 ---- } } ! return ($result, $version_string); } *************** *** 2117,2121 **** # avoid files from .libs dirs ! if ($compat_libtool && $graph_dir =~ m/(.*)\/\.libs$/) { $source_dir = $1; } else { --- 2145,2149 ---- # avoid files from .libs dirs ! if (is_compat($COMPAT_FLAG_LIBTOOL) && $graph_dir =~ m/(.*)\/\.libs$/) { $source_dir = $1; } else { *************** *** 2135,2139 **** if ($gcov_version < $GCOV_VERSION_3_4_0) { ! if (defined($compatibility) && $compatibility eq $COMPAT_HAMMER) { ($instr, $graph) = read_bbg($graph_filename, $base_dir); --- 2163,2167 ---- if ($gcov_version < $GCOV_VERSION_3_4_0) { ! if (is_compat($COMPAT_FLAG_HAMMER)) { ($instr, $graph) = read_bbg($graph_filename, $base_dir); *************** *** 2996,2999 **** --- 3024,3031 ---- # Skip ident and checksum graph_skip($handle, 8, "function ident and checksum") or return undef; + if (is_compat($COMPAT_FLAG_ANDROID_4_4_0)) { + # Skip extra word added by android 4.4.0 toolchain. + graph_skip($handle, 4, "android_4_4_0 extra word"); + } # Read function name graph_expect("function name"); *************** *** 3211,3212 **** --- 3243,3369 ---- return 1; } + + # + # compat_name(flag) + # + # Return the name of compatibility flag FLAG. + # + + sub compat_name($) + { + my ($flag) = @_; + + foreach my $name (keys(%COMPAT_NAME_TO_FLAG)) { + return $name if ($COMPAT_NAME_TO_FLAG{$name} eq $flag); + } + return "<unknown>"; + } + + # + # parse_compat_flags(opt) + # + # Determine compatibility flag settings. + # + + sub parse_compat_flags($) + { + my ($opt) = @_; + my @opt_list; + my %specified; + + # Initialize with defaults + %compat_value = %COMPAT_FLAG_DEFAULTS; + + # Add old style specifications + if (defined($opt_compat_libtool)) { + $compat_value{$COMPAT_FLAG_LIBTOOL} = + $opt_compat_libtool ? $COMPAT_VALUE_ON + : $COMPAT_VALUE_OFF; + } + + # Parse settings + if (defined($opt)) { + @opt_list = split(/,/, $opt); + } + foreach my $directive (@opt_list) { + my ($flag, $value); + + # Either + # flag=off|on|auto or + # flag (implies auto) + if ($directive !~ /^(\w+)=(\w+)$/ && + $directive !~ /^(\w+)$/) { + die("ERROR: Unknown compatibility setting format: ". + "$directive!\n"); + } + # Determine flag + $flag = $COMPAT_NAME_TO_FLAG{lc($1)}; + if (!defined($flag)) { + die("ERROR: Unknown compatibility setting: $1!\n"); + } + $specified{$flag} = 1; + # Determine value + if (defined($2)) { + $value = $COMPAT_NAME_TO_VALUE{lc($2)}; + if (!defined($value)) { + die("ERROR: Unknown compatibility setting ". + "value: $2!\n"); + } + } else { + $value = $COMPAT_VALUE_ON; + } + $compat_value{$flag} = $value; + } + # Perform autodetection + foreach my $flag (sort(keys(%compat_value))) { + my $value = $compat_value{$flag}; + my $is_autodetect = ""; + my $name = compat_name($flag); + + if ($value == $COMPAT_VALUE_AUTO) { + my $autodetect = $COMPAT_FLAG_AUTO{$flag}; + + if (!defined($autodetect)) { + die("ERROR: No automatic detection for ". + "setting '$name' available!\n"); + } + $value = &$autodetect(); + $compat_value{$flag} = $value; + $is_autodetect = " (autodetected)"; + } + if ($specified{$flag}) { + if ($value == $COMPAT_VALUE_ON) { + info("Enabling compatibility setting ". + "'$name'$is_autodetect\n"); + } else { + info("Disabling compatibility setting ". + "'$name'$is_autodetect\n"); + } + } + } + } + + sub compat_hammer_autodetect() + { + if ($gcov_version_string =~ /suse/i && $gcov_version == 0x30303 || + $gcov_version_string =~ /mandrake/i && $gcov_version == 0x30302) + { + info("Autodetected compatibility mode for GCC 3.3 (hammer)\n"); + return $COMPAT_VALUE_ON; + } + return $COMPAT_VALUE_OFF; + } + + # + # is_compat(flag) + # + # Return non-zero if compatibility setting for FLAG is enabled. + # + + sub is_compat($) + { + my ($flag) = @_; + + return 1 if ($compat_value{$flag} == $COMPAT_VALUE_ON); + return 0; + } Index: lcov =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/lcov,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** lcov 19 Nov 2010 15:45:01 -0000 1.80 --- lcov 20 Jan 2012 11:53:57 -0000 1.81 *************** *** 192,195 **** --- 192,196 ---- our $opt_config_file; our @opt_summary; + our $opt_compat; our $ln_overall_found; our $ln_overall_hit; *************** *** 285,288 **** --- 286,290 ---- "no-external" => \$opt_no_external, "summary=s" => \@opt_summary, + "compat=s" => \$opt_compat, )) { *************** *** 859,862 **** --- 861,867 ---- @param = (@param, "--no-external"); } + if (defined($opt_compat)) { + @param = (@param, "--compat", $opt_compat); + } system(@param) and exit($? >> 8); } |