4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # This file incorporates work covered by the following license notice:
12 # Licensed to the Apache Software Foundation (ASF) under one or more
13 # contributor license agreements. See the NOTICE file distributed
14 # with this work for additional information regarding copyright
15 # ownership. The ASF licenses this file to you under the Apache
16 # License, Version 2.0 (the "License"); you may not use this file
17 # except in compliance with the License. You may obtain a copy of
18 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 # GCOV_RESULTINTERPRETER
23 # Helper, to interpret the result
33 our $version_info = 'gcov helper: 1.3 ';
35 our $help; # Help option flag
36 our $version; # Version option flag
39 our $usedFunctions; # show all functions, which have a value > 0
40 our $nonusedFunctions; # show all functions, which have a value == 0
41 our $nPercent; # show all functions, which have a value > $nPercent
42 our $complete; # show all functions, which have a value == 100
43 our $incomplete; # show all functions, which have a value > 0 && < 100
47 sub read_gcov_function_file
($);
49 # Parse command line options
51 "usedfunctions" => \
$usedFunctions,
52 "nonusedfunctions" => \
$nonusedFunctions,
53 "percent=s" => \
$nPercent,
54 "complete" => \
$complete,
55 "incomplete" => \
$incomplete,
57 "version" => \
$version
64 # Check for help option
71 # Check for version option
74 print("$version_info\n");
78 # check if enough parameters
81 print("No input filename specified\n");
90 # ------------------------------------------------------------------------------
92 my %list = read_gcov_function_file
($ARGV[0]);
97 while (($key, $value) = each %list)
99 # print "function: $key = $value\n";
100 if ($nonusedFunctions)
107 elsif ($usedFunctions)
111 print "$key, $value\n";
116 if ($value >= $nPercent)
118 print "$key, $value\n";
123 if ($value > 0.00 && $value < 100.00)
125 print "$key, $value\n";
130 print "$key, $value\n";
134 # --------------------------------------------------------------------------------
135 # Read the gcov function (gcov -f) file
136 # and compare line by line with the export function list
137 # so we get a list of functions, which are only exported, and not all stuff.
139 sub read_gcov_function_file
($)
146 open(INPUT_HANDLE
, $file)
147 or die("ERROR: cannot open $file!\n");
149 while ($line = <INPUT_HANDLE
>)
152 # sample line (for reg exp:)
153 # 100.00 rtl_ustr_toDouble
154 if ($line =~ /^(.*) (\w+)$/ )
159 $list{$value} = $percent;
166 # ----------------------------------------------------------------------------
169 local *HANDLE
= $_[0];
170 my $tool_name = basename
($0);
172 print(HANDLE
<<END_OF_USAGE);
174 Usage: $tool_name [OPTIONS] INPUTFILE
176 -u, --usedFunctions show all functions, which have a value > 0
177 -n, --nonusedFunctions show all functions, which have a value == 0
178 -p, --percent show all functions, which have a value > percent
179 -c, --complete show all functions, which have a value == 100
180 -i, --incomplete show all functions, which have a value > 0 && < 100
182 -h, --help Print this help, then exit
183 -v, --version Print version number, then exit