Skip to content

Commit

Permalink
Fix lcov.pl to work with the new gcov-kernel module
Browse files Browse the repository at this point in the history
... ,documentation fixes in readme.txt
  • Loading branch information
Paul Larson authored and oberpar committed Jun 10, 2014
1 parent e70d9ab commit ec94ed7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
29 changes: 18 additions & 11 deletions lcov.pl
Expand Up @@ -28,6 +28,10 @@
# IBM Lab Boeblingen
# 2002-09-05 / Peter Oberparleiter: implemented --kernel-directory + multiple
# directories
# 2003-03-07 / Paul Larson: Changed to make it work with the latest gcov
# kernel patch. This will break it with older
# gcov-kernel patches unless you change
# the value of $gcovmod in this script
#

use strict;
Expand All @@ -38,6 +42,9 @@
# Global constants
our $version_info = "LTP GCOV extension version 1.0";
our $url = "http://ltp.sourceforge.net/lcov.php";
# Uncomment for older versions of gcov-kernel with gcov-proc.o as the module
#our $gcovmod = "gcov-proc";
our $gcovmod = "gcov-prof";

# The location of the insmod tool
our $insmod_tool = "/sbin/insmod";
Expand Down Expand Up @@ -74,7 +81,7 @@
our $quiet = ""; # If set, suppress information messages
our $help; # Help option flag
our $version; # Version option flag
our $need_unload; # If set, unload gcov-proc module
our $need_unload; # If set, unload gcov-prof module
our $temp_dir_name; # Name of temporary directory
our $cwd = `pwd`; # Current working directory
chomp($cwd);
Expand Down Expand Up @@ -210,7 +217,7 @@ (*)
Usage: $tool_name [OPTIONS]
Access GCOV code coverage data. By default, tries to access kernel coverage
data (requires kernel module gcov-proc to be installed separately). Use the
data (requires kernel module gcov-prof to be installed separately). Use the
--directory option to get coverage data from a user space program.
-h, --help Print this help, then exit
Expand Down Expand Up @@ -396,7 +403,7 @@ (@)


#
# Check if kernel module gcov-proc.o is loaded. If it is, exit, if not, try
# Check if kernel module gcov-prof.ko is loaded. If it is, exit, if not, try
# to load it.
#
# Die on error.
Expand All @@ -408,7 +415,7 @@ ()
stat("/proc/gcov");
if (-r _) { return(); }

info("Load required kernel module gcov-proc.o\n");
info("Load required kernel module gcov-prof.ko\n");

# Do we have access to the insmod tool?
stat($insmod_tool);
Expand All @@ -418,15 +425,15 @@ ()
}

# Try to load module from system wide module directory /lib/modules
if (!system("$insmod_tool gcov-proc 2>/dev/null >/dev/null"))
if (!system("$insmod_tool $gcovmod 2>/dev/null >/dev/null"))
{
# Suceeded
$need_unload = 1;
return();
}

# Try to load module from tool directory
if (!system("$insmod_tool $tool_dir/gcov-proc.o 2>/dev/null ".
if (!system("$insmod_tool $tool_dir/$gcovmod.ko 2>/dev/null ".
">/dev/null"))
{
# Succeeded
Expand All @@ -440,14 +447,14 @@ ()
die("ERROR: need root to load kernel module!\n");
}

die("ERROR: cannot load required kernel module gcov-proc.o!\n");
die("ERROR: cannot load required kernel module $gcovmod.ko!\n");
}


#
# unload_module()
#
# Unload the gcov-proc module.
# Unload the gcov-prof module.
#

sub unload_module()
Expand All @@ -462,9 +469,9 @@ ()
"module still laoded!\n");
}

# Unload gcov-proc
system("$rmmod_tool gcov-proc 2>/dev/null")
and warn("WARNING: cannot unload kernel module gcov-proc!\n");
# Unload gcov-prof
system("$rmmod_tool gcov_prof 2>/dev/null")
and warn("WARNING: cannot unload kernel module $gcovmod!\n");
}


Expand Down
12 changes: 6 additions & 6 deletions readme.txt
@@ -1,6 +1,6 @@
-------------------------------------------------
- README file for the LTP GCOV extension (lcov) -
- Last changes: 2002-09-05 -
- Last changes: 2003-03-07 -
-------------------------------------------------


Expand Down Expand Up @@ -49,7 +49,7 @@ Requirements: get and install the gcov-kernel package from

http://sourceforge/projects/lse

The resulting gcov-proc.o file should be located in the same directory as the
The resulting gcov-prof.ko file should be located in the same directory as the
PERL scripts. As root do the following:

a) Resetting counters
Expand All @@ -58,7 +58,7 @@ PERL scripts. As root do the following:

b) Capturing the current counter state to a file

lcov.pl --capture --output-filename kernel.info
lcov.pl --capture --output-file kernel.info

c) Getting HTML output

Expand Down Expand Up @@ -101,9 +101,9 @@ Access GCOV code coverage data. By default, tries to access kernel coverage
data. Use the --directory option to get coverage data from a user space
program. Unless --output-file is used, coverage data is written to STDOUT.

To access kernel coverage data, the gcov-proc kernel module is required.
To access kernel coverage data, the gcov-prof kernel module is required.
It may be obtained from http://sourceforge/projects/lse (files section,
package "gcov-kernel"). For ease of use, once you have the gcov-proc.o file
package "gcov-kernel"). For ease of use, once you have the gcov-prof.ko file
compiled, copy it to the same directory as lcov.pl. Note that you will need
root to access kernel coverage data.

Expand Down Expand Up @@ -494,5 +494,5 @@ Options:
-------------------------

Please email you questions or comments to the LTP Mailing list at
ltp-list@lists.sourceforge.net
ltp-coverage@lists.sourceforge.net

0 comments on commit ec94ed7

Please sign in to comment.