--- lcov 2009-02-25 18:56:39.000000000 +0530 +++ lcov-mod 2009-02-25 18:57:23.000000000 +0530 @@ -67,9 +67,11 @@ our $lcov_version = "LTP GCOV extension version 1.6"; our $lcov_url = "http://ltp.sourceforge.net/coverage/lcov.php"; -# Names of the GCOV kernel module -our @gcovmod = ("gcov-prof", "gcov-proc"); - +# Hash Table which contains gcov module name as well as directory path +our %gcov_module_dir = ( "gcov-prof" => "/proc/gcov", + "gcov-proc" => "/proc/gcov", + "xen-gcov-proc" => "/proc/xen/gcov" ); + # Directory containing gcov kernel files our $gcov_dir = "/proc/gcov"; @@ -736,7 +738,7 @@ sub check_and_load_kernel_module() { - my $module_name; + my $module_name=""; # Is it loaded already? stat("$gcov_dir"); @@ -759,9 +761,14 @@ "kernel coverage data!\n"); } - # Try some possibilities of where the gcov kernel module may be found - foreach $module_name (@gcovmod) + # Try some possibilities of where the gcov module may be found. + # And there is a hash table called %gcov_module_dir which has the module name + # associated with directory path. Based on the $gcov_dir select the + # particular module to load. + while ((my $mod_name, my $gcov_path) = each (%gcov_module_dir)) { + $module_name = $mod_name if($gcov_path eq $gcov_dir); + # Try to load module from system wide module directory # /lib/modules if (system_no_output(3, $modprobe_tool, $module_name) == 0)