Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions lcov-1.12/bin/copy_dates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
#
# Usage: copy_dates.sh SOURCE TARGET
#
# For each file found in SOURCE, set the modification time of the copy of that
# file in TARGET to either the time of the latest Git commit (if SOURCE contains
# a Git repository and the file was not modified after the last commit), or the
# modification time of the original file.

SOURCE="$1"
TARGET="$2"

if [ -z "$SOURCE" -o -z "$TARGET" ] ; then
echo "Usage: $0 SOURCE TARGET" >&2
exit 1
fi

[ -d "$SOURCE/.git" ] ; NOGIT=$?

echo "Copying modification/commit times from $SOURCE to $TARGET"

cd "$SOURCE" || exit 1
find * -type f | while read FILENAME ; do
[ ! -e "$TARGET/$FILENAME" ] && continue

# Copy modification time
touch -m "$TARGET/$FILENAME" -r "$FILENAME"

[ $NOGIT -eq 1 ] && continue # No Git
git diff --quiet -- "$FILENAME" || continue # Modified
git diff --quiet --cached -- "$FILENAME" || continue # Modified

# Apply modification time from Git commit time
TIME=$(git log --pretty=format:%cd -n 1 --date=iso -- "$FILENAME")
[ -n "$TIME" ] && touch -m "$TARGET/$FILENAME" --date "$TIME"
done
16 changes: 13 additions & 3 deletions lcov-1.12/bin/genhtml
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ if (defined($opt_config_file)) {
elsif (-r "/etc/lcovrc")
{
$config = read_config("/etc/lcovrc");
} elsif (-r "/usr/local/etc/lcovrc")
{
$config = read_config("/usr/local/etc/lcovrc");
}

if ($config || %opt_rc)
Expand Down Expand Up @@ -3848,8 +3851,8 @@ sub fmt_centered($$)
{
my ($width, $text) = @_;
my $w0 = length($text);
my $w1 = int(($width - $w0) / 2);
my $w2 = $width - $w0 - $w1;
my $w1 = $width > $w0 ? int(($width - $w0) / 2) : 0;
my $w2 = $width > $w0 ? $width - $w0 - $w1 : 0;

return (" "x$w1).$text.(" "x$w2);
}
Expand Down Expand Up @@ -5325,6 +5328,7 @@ sub demangle_list($)
my $tmpfile;
my $handle;
my %demangle;
my $demangle_arg = "";
my %versions;

# Write function names to file
Expand All @@ -5333,8 +5337,14 @@ sub demangle_list($)
print($handle join("\n", @$list));
close($handle);

# Extra flag necessary on OS X so that symbols listed by gcov get demangled
# properly.
if ($^O eq "darwin") {
$demangle_arg = "--no-strip-underscores";
}

# Build translation hash from c++filt output
open($handle, "-|", "c++filt < $tmpfile") or
open($handle, "-|", "c++filt $demangle_arg < $tmpfile") or
die("ERROR: could not run c++filt: $!\n");
foreach my $func (@$list) {
my $translated = <$handle>;
Expand Down
109 changes: 67 additions & 42 deletions lcov-1.12/bin/geninfo
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ sub solve_relative_path($$);
sub read_gcov_header($);
sub read_gcov_file($);
sub info(@);
sub map_llvm_version($);
sub version_to_str($);
sub get_gcov_version();
sub system_no_output($@);
sub read_config($);
Expand Down Expand Up @@ -304,6 +306,9 @@ if (defined($opt_config_file)) {
elsif (-r "/etc/lcovrc")
{
$config = read_config("/etc/lcovrc");
} elsif (-r "/usr/local/etc/lcovrc")
{
$config = read_config("/usr/local/etc/lcovrc");
}

if ($config || %opt_rc)
Expand Down Expand Up @@ -1898,6 +1903,36 @@ sub read_gcov_file($)
}


# Map LLVM versions to the version of GCC gcov which they emulate.

sub map_llvm_version($)
{
my ($ver) = @_;

return 0x040200 if ($ver >= 0x030400);

warn("WARNING: This version of LLVM's gcov is unknown. ".
"Assuming it emulates GCC gcov version 4.2.\n");

return 0x040200;
}


# Return a readable version of encoded gcov version.

sub version_to_str($)
{
my ($ver) = @_;
my ($a, $b, $c);

$a = $ver >> 16 & 0xff;
$b = $ver >> 8 & 0xff;
$c = $ver & 0xff;

return "$a.$b.$c";
}


#
# Get the GCOV tool version. Return an integer number which represents the
# GCOV version. Version numbers can be compared using standard integer
Expand All @@ -1909,58 +1944,48 @@ sub get_gcov_version()
local *HANDLE;
my $version_string;
my $result;
my $pipe_next_line;
my ($a, $b, $c) = (4, 2, 0); # Fallback version

# Examples for gcov version output:
#
# gcov (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
#
# gcov (crosstool-NG 1.18.0) 4.7.2
#
# LLVM (http://llvm.org/):
# LLVM version 3.4svn
#
# Apple LLVM version 8.0.0 (clang-800.0.38)
# Optimized build.
# Default target: x86_64-apple-darwin16.0.0
# Host CPU: haswell

open(GCOV_PIPE, "-|", "$gcov_tool --version")
or die("ERROR: cannot retrieve gcov version!\n");
local $/;
$version_string = <GCOV_PIPE>;
# LLVM gcov keeps version information on the second line.
# For example, gcov --version yields:
# LLVM (http://llvm.org/):
# LLVM version 3.4svn

$pipe_next_line = <GCOV_PIPE>;
# In case version information is on first line.
# For example, with Xcode 7.0 gcov --version yields:
# Apple LLVM 7.0.0 (clang-700.0.65)

$version_string = $pipe_next_line if ($pipe_next_line && $version_string =~ /LLVM/);
close(GCOV_PIPE);

# Remove version information in parenthesis to cope with the following:
# - gcov (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
# - gcov (crosstool-NG 1.18.0) 4.7.2
# Remove all bracketed information
$version_string =~ s/\([^\)]*\)//g;

$result = 0;
if ($version_string =~ /(\d+)\.(\d+)(\.(\d+))?/)
{
if (defined($4))
{
info("Found gcov version: $1.$2.$4\n");
$result = $1 << 16 | $2 << 8 | $4;
}
else
{
info("Found gcov version: $1.$2\n");
$result = $1 << 16 | $2 << 8;
}
if ($version_string =~ /(\d+)\.(\d+)(\.(\d+))?/) {
($a, $b, $c) = ($1, $2, $4);
$c = 0 if (!defined($c));
} else {
warn("WARNING: cannot determine gcov version - ".
"assuming $a.$b.$c\n");
}
if ($version_string =~ /LLVM/)
{
# Map LLVM versions to the version of GCC gcov which
# they emulate
if ($result >= 0x030400)
{
info("Found LLVM gcov version 3.4, which emulates gcov version 4.2\n");
$result = 0x040200;
}
else
{
warn("This version of LLVM's gcov is unknown. Assuming it emulates GCC gcov version 4.2.\n");
$result = 0x040200;
}
$result = $a << 16 | $b << 8 | $c;

if ($version_string =~ /LLVM/) {
$result = map_llvm_version($result);
info("Found LLVM gcov version $a.$b.$c, which emulates gcov ".
"version ".version_to_str($result)."\n");
} else {
info("Found gcov version: ".version_to_str($result)."\n");
}

return ($result, $version_string);
}

Expand Down
13 changes: 13 additions & 0 deletions lcov-1.12/bin/get_changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
#
# Usage: get_changes.sh
#
# Print lcov change log information as provided by Git

TOOLDIR=$(cd $(dirname $0) ; pwd)

cd $TOOLDIR

if ! git --no-pager log --no-merges --decorate=short --color=never 2>/dev/null ; then
cat "$TOOLDIR/../CHANGES" 2>/dev/null
fi
71 changes: 71 additions & 0 deletions lcov-1.12/bin/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash
#
# install.sh [--uninstall] sourcefile targetfile [install options]
#


# Check for uninstall option
if test "x$1" == "x--uninstall" ; then
UNINSTALL=true
SOURCE=$2
TARGET=$3
shift 3
else
UNINSTALL=false
SOURCE=$1
TARGET=$2
shift 2
fi

# Check usage
if test -z "$SOURCE" || test -z "$TARGET" ; then
echo Usage: install.sh [--uninstall] source target [install options] >&2
exit 1
fi


#
# do_install(SOURCE_FILE, TARGET_FILE)
#

do_install()
{
local SOURCE=$1
local TARGET=$2
local PARAMS=$3

install -p -D $PARAMS $SOURCE $TARGET
}


#
# do_uninstall(SOURCE_FILE, TARGET_FILE)
#

do_uninstall()
{
local SOURCE=$1
local TARGET=$2

# Does target exist?
if test -r $TARGET ; then
# Is target of the same version as this package?
if diff -I '^our \$lcov_version' -I '^\.TH ' $SOURCE $TARGET >/dev/null; then
rm -f $TARGET
else
echo WARNING: Skipping uninstall for $TARGET - versions differ! >&2
fi
else
echo WARNING: Skipping uninstall for $TARGET - not installed! >&2
fi
}


# Call sub routine
if $UNINSTALL ; then
do_uninstall $SOURCE $TARGET
else
do_install $SOURCE $TARGET "$*"
fi

exit 0
6 changes: 4 additions & 2 deletions lcov-1.12/bin/lcov
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ if (defined($opt_config_file)) {
elsif (-r "/etc/lcovrc")
{
$config = read_config("/etc/lcovrc");
} elsif (-r "/usr/local/etc/lcovrc")
{
$config = read_config("/usr/local/etc/lcovrc");
}

if ($config || %opt_rc)
Expand Down Expand Up @@ -2915,7 +2918,7 @@ sub remove()

foreach $pattern (@pattern_list)
{
$match_found ||= ($filename =~ (/$pattern$/));
$match_found ||= ($filename =~ (/^$pattern$/));
}


Expand Down Expand Up @@ -4250,7 +4253,6 @@ sub warn_handler($)
{
my ($msg) = @_;

temp_cleanup();
warn("$tool_name: $msg");
}

Expand Down
Loading