From: Peter O. <obe...@us...> - 2012-07-06 09:03:30
|
Update of /cvsroot/ltp/utils/analysis/lcov/bin In directory vz-cvs-4.sog:/tmp/cvs-serv11533 Modified Files: geninfo lcov Log Message: geninfo: improve detection of gcc 4.7 function records Suggestions by ga...@go...: - perform detection only once - add warning in case detection is off but overlong strings are found Misc: - add help text for --compat - isolate detection heuristic into separate function - rename corresponding compatibility setting to "gcc_4_7" - allow "android_4_4_0" as alias for "gcc_4_7" Index: geninfo =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/geninfo,v retrieving revision 1.98 retrieving revision 1.99 diff -C2 -d -r1.98 -r1.99 *** geninfo 4 Jul 2012 16:06:10 -0000 1.98 --- geninfo 6 Jul 2012 09:03:27 -0000 1.99 *************** *** 104,108 **** 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 --- 104,108 ---- our $COMPAT_FLAG_LIBTOOL = 1 << 0; our $COMPAT_FLAG_HAMMER = 1 << 1; ! our $COMPAT_FLAG_GCC_4_7 = 1 << 2; # Compatibility setting flag names *************** *** 110,114 **** "libtool" => $COMPAT_FLAG_LIBTOOL, "hammer" => $COMPAT_FLAG_HAMMER, ! "android_4_4_0" => $COMPAT_FLAG_ANDROID_4_4_0, ); --- 110,122 ---- "libtool" => $COMPAT_FLAG_LIBTOOL, "hammer" => $COMPAT_FLAG_HAMMER, ! "android_4_4_0" => $COMPAT_FLAG_GCC_4_7, ! "gcc_4_7" => $COMPAT_FLAG_GCC_4_7, ! ); ! ! # Map flags to names ! our %COMPAT_FLAG_TO_NAME = ( ! $COMPAT_FLAG_LIBTOOL => "libtool", ! $COMPAT_FLAG_HAMMER => "hammer", ! $COMPAT_FLAG_GCC_4_7 => "gcc_4_7/android_4_4_0", ); *************** *** 117,121 **** $COMPAT_FLAG_LIBTOOL => $COMPAT_VALUE_ON, $COMPAT_FLAG_HAMMER => $COMPAT_VALUE_OFF, ! $COMPAT_FLAG_ANDROID_4_4_0 => $COMPAT_VALUE_AUTO, ); --- 125,129 ---- $COMPAT_FLAG_LIBTOOL => $COMPAT_VALUE_ON, $COMPAT_FLAG_HAMMER => $COMPAT_VALUE_OFF, ! $COMPAT_FLAG_GCC_4_7 => $COMPAT_VALUE_AUTO, ); *************** *** 124,128 **** our %COMPAT_FLAG_AUTO = ( $COMPAT_FLAG_HAMMER => \&compat_hammer_autodetect, ! $COMPAT_FLAG_ANDROID_4_4_0 => 1, ); --- 132,136 ---- our %COMPAT_FLAG_AUTO = ( $COMPAT_FLAG_HAMMER => \&compat_hammer_autodetect, ! $COMPAT_FLAG_GCC_4_7 => 1, ); *************** *** 233,236 **** --- 241,245 ---- our $opt_compat; our %compat_value; + our $gcno_fmt_4_7; our $cwd = `pwd`; *************** *** 539,542 **** --- 548,552 ---- --(no-)external Include (ignore) data for external files --config-file FILENAME Specify configuration file location + --compat MODE=on|off|auto Set compat MODE (libtool, hammer, gcc_4_7) For more information see: $lcov_url *************** *** 3028,3031 **** --- 3038,3086 ---- # + # determine_gcno_fmt(handle, big_endian, rec_length) + # + # Determine if HANDLE refers to a .gcno file with a gcc 4.7 format function + # record. Return non-zero in case of gcc 4.7 format, zero otherwise, + # undef in case of read error. + # + + sub determine_gcno_fmt($$$) + { + my ($handle, $big_endian, $rec_length) = @_; + my $strlen; + my $overlong_string; + + return 1 if ($gcov_version >= $GCOV_VERSION_4_7_0); + return 1 if (is_compat($COMPAT_FLAG_GCC_4_7)); + + # Heuristic: + # Decide format based on contents of next word in record: + # - pre-gcc 4.7 + # This is the function name length / 4 which should be + # less than the remaining record length + # - gcc 4.7 + # This is a checksum, likely with high-order bits set, + # resulting in a large number + $strlen = read_gcno_value($handle, $big_endian, undef, 1); + return undef if (!defined($strlen)); + $overlong_string = 1 if ($strlen * 4 >= $rec_length - 12); + + if (!is_compat_auto($COMPAT_FLAG_GCC_4_7)) { + # Sanity check + if ($overlong_string) { + warn("Found overlong string in function record: ". + "try --compat gcc_4_7\n"); + } + return 0; + } elsif (!$overlong_string) { + return 0; + } + + info("Auto-detected compatibility mode for GCC 4.7\n"); + + return 1; + } + + # # read_gcno_function_record(handle, graph, base, big_endian, rec_length) # *************** *** 3041,3045 **** my $lineno; my $lines; - my $is_4_7; graph_expect("function record"); --- 3096,3099 ---- *************** *** 3047,3081 **** graph_skip($handle, 8, "function ident and checksum") or return undef; # Determine if this is a gcc 4.7 format function record ! if ($gcov_version >= $GCOV_VERSION_4_7_0) { ! $is_4_7 = 1; ! } elsif (is_compat($COMPAT_FLAG_ANDROID_4_4_0)) { ! $is_4_7 = 1; ! } elsif (is_compat_auto($COMPAT_FLAG_ANDROID_4_4_0)) { ! my $strlen = read_gcno_value($handle, $big_endian, undef, 1); ! ! return undef if (!defined($strlen)); ! ! # Heuristic: ! # - pre-gcc 4.7 ! # This is the function name length / 4 which should be ! # less than the remaining record length ! # - gcc 4.7 ! # This is a checksum, likely with high-order bits set, ! # resulting in a large number ! if ($strlen * 4 > $rec_length - 12) { ! if ($debug) { ! print(STDERR "DEBUG: found overlong string ". ! "length - assuming gcc 4.7 format\n"); ! } ! $is_4_7 = 1; ! } elsif ($debug) { ! print(STDERR "DEBUG: found strlen=".($strlen * 4). ! " and rec_length=".($rec_length - 12)."\n"); ! } } # Skip cfg checksum word in case of gcc 4.7 format function record ! if ($is_4_7) { ! graph_skip($handle, 4, "function cfg checksum"); ! } # Read function name graph_expect("function name"); --- 3101,3111 ---- graph_skip($handle, 8, "function ident and checksum") or return undef; # Determine if this is a gcc 4.7 format function record ! if (!defined($gcno_fmt_4_7)) { ! $gcno_fmt_4_7 = determine_gcno_fmt($handle, $big_endian, ! $rec_length); ! return undef if (!defined($gcno_fmt_4_7)); } # Skip cfg checksum word in case of gcc 4.7 format function record ! graph_skip($handle, 4, "function cfg checksum") if ($gcno_fmt_4_7); # Read function name graph_expect("function name"); *************** *** 3304,3311 **** { my ($flag) = @_; - foreach my $name (keys(%COMPAT_NAME_TO_FLAG)) { - return $name if ($COMPAT_NAME_TO_FLAG{$name} eq $flag); - } return "<unknown>"; } --- 3334,3341 ---- { my ($flag) = @_; + my $name = $COMPAT_FLAG_TO_NAME{$flag}; + + return $name if (defined($name)); return "<unknown>"; } Index: lcov =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/lcov,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** lcov 20 Jan 2012 11:53:57 -0000 1.81 --- lcov 6 Jul 2012 09:03:27 -0000 1.82 *************** *** 525,528 **** --- 525,529 ---- --(no-)external Include (ignore) data for external files --config-file FILENAME Specify configuration file location + --compat MODE=on|off|auto Set compat MODE (libtool, hammer, gcc_4_7) For more information see: $lcov_url |