1 1.7 mrg @c Copyright (C) 2014-2022 Free Software Foundation, Inc. 2 1.1 mrg @c This is part of the GCC manual. 3 1.1 mrg @c For copying conditions, see the file gcc.texi. 4 1.1 mrg 5 1.1 mrg @ignore 6 1.1 mrg @c man begin COPYRIGHT 7 1.7 mrg Copyright @copyright{} 2014-2022 Free Software Foundation, Inc. 8 1.1 mrg 9 1.1 mrg Permission is granted to copy, distribute and/or modify this document 10 1.1 mrg under the terms of the GNU Free Documentation License, Version 1.3 or 11 1.1 mrg any later version published by the Free Software Foundation; with the 12 1.1 mrg Invariant Sections being ``GNU General Public License'' and ``Funding 13 1.1 mrg Free Software'', the Front-Cover texts being (a) (see below), and with 14 1.1 mrg the Back-Cover Texts being (b) (see below). A copy of the license is 15 1.1 mrg included in the gfdl(7) man page. 16 1.1 mrg 17 1.1 mrg (a) The FSF's Front-Cover Text is: 18 1.1 mrg 19 1.1 mrg A GNU Manual 20 1.1 mrg 21 1.1 mrg (b) The FSF's Back-Cover Text is: 22 1.1 mrg 23 1.1 mrg You have freedom to copy and modify this GNU Manual, like GNU 24 1.1 mrg software. Copies published by the Free Software Foundation raise 25 1.1 mrg funds for GNU development. 26 1.1 mrg @c man end 27 1.1 mrg @c Set file name and title for the man page. 28 1.1 mrg @setfilename gcov-tool 29 1.1 mrg @settitle offline gcda profile processing tool 30 1.1 mrg @end ignore 31 1.1 mrg 32 1.1 mrg @node Gcov-tool 33 1.1 mrg @chapter @command{gcov-tool}---an Offline Gcda Profile Processing Tool 34 1.1 mrg 35 1.1 mrg @command{gcov-tool} is a tool you can use in conjunction with GCC to 36 1.1 mrg manipulate or process gcda profile files offline. 37 1.1 mrg 38 1.1 mrg @menu 39 1.1 mrg * Gcov-tool Intro:: Introduction to gcov-tool. 40 1.1 mrg * Invoking Gcov-tool:: How to use gcov-tool. 41 1.1 mrg @end menu 42 1.1 mrg 43 1.1 mrg @node Gcov-tool Intro 44 1.1 mrg @section Introduction to @command{gcov-tool} 45 1.1 mrg @c man begin DESCRIPTION 46 1.1 mrg 47 1.1 mrg @command{gcov-tool} is an offline tool to process gcc's gcda profile files. 48 1.1 mrg 49 1.1 mrg Current gcov-tool supports the following functionalities: 50 1.1 mrg 51 1.1 mrg @itemize @bullet 52 1.1 mrg @item 53 1.1 mrg merge two sets of profiles with weights. 54 1.1 mrg 55 1.1 mrg @item 56 1.1 mrg read one set of profile and rewrite profile contents. One can scale or 57 1.1 mrg normalize the count values. 58 1.1 mrg @end itemize 59 1.1 mrg 60 1.1 mrg Examples of the use cases for this tool are: 61 1.1 mrg @itemize @bullet 62 1.1 mrg @item 63 1.1 mrg Collect the profiles for different set of inputs, and use this tool to merge 64 1.1 mrg them. One can specify the weight to factor in the relative importance of 65 1.1 mrg each input. 66 1.1 mrg 67 1.1 mrg @item 68 1.1 mrg Rewrite the profile after removing a subset of the gcda files, while maintaining 69 1.1 mrg the consistency of the summary and the histogram. 70 1.1 mrg 71 1.1 mrg @item 72 1.1 mrg It can also be used to debug or libgcov code as the tools shares the majority 73 1.1 mrg code as the runtime library. 74 1.1 mrg @end itemize 75 1.1 mrg 76 1.1 mrg Note that for the merging operation, this profile generated offline may 77 1.1 mrg contain slight different values from the online merged profile. Here are 78 1.1 mrg a list of typical differences: 79 1.1 mrg 80 1.1 mrg @itemize @bullet 81 1.1 mrg @item 82 1.1 mrg histogram difference: This offline tool recomputes the histogram after merging 83 1.1 mrg the counters. The resulting histogram, therefore, is precise. The online 84 1.1 mrg merging does not have this capability -- the histogram is merged from two 85 1.1 mrg histograms and the result is an approximation. 86 1.1 mrg 87 1.1 mrg @item 88 1.1 mrg summary checksum difference: Summary checksum uses a CRC32 operation. The value 89 1.1 mrg depends on the link list order of gcov-info objects. This order is different in 90 1.1 mrg gcov-tool from that in the online merge. It's expected to have different 91 1.1 mrg summary checksums. It does not really matter as the compiler does not use this 92 1.1 mrg checksum anywhere. 93 1.1 mrg 94 1.1 mrg @item 95 1.1 mrg value profile counter values difference: Some counter values for value profile 96 1.1 mrg are runtime dependent, like heap addresses. It's normal to see some difference 97 1.1 mrg in these kind of counters. 98 1.1 mrg @end itemize 99 1.1 mrg 100 1.1 mrg @c man end 101 1.1 mrg 102 1.1 mrg @node Invoking Gcov-tool 103 1.1 mrg @section Invoking @command{gcov-tool} 104 1.1 mrg 105 1.1 mrg @smallexample 106 1.1 mrg gcov-tool @r{[}@var{global-options}@r{]} SUB_COMMAND @r{[}@var{sub_command-options}@r{]} @var{profile_dir} 107 1.1 mrg @end smallexample 108 1.1 mrg 109 1.1 mrg @command{gcov-tool} accepts the following options: 110 1.1 mrg 111 1.1 mrg @ignore 112 1.1 mrg @c man begin SYNOPSIS 113 1.1 mrg gcov-tool [@option{-v}|@option{--version}] [@option{-h}|@option{--help}] 114 1.1 mrg 115 1.1 mrg gcov-tool merge [merge-options] @var{directory1} @var{directory2} 116 1.3 mrg [@option{-o}|@option{--output} @var{directory}] 117 1.1 mrg [@option{-v}|@option{--verbose}] 118 1.1 mrg [@option{-w}|@option{--weight} @var{w1,w2}] 119 1.1 mrg 120 1.1 mrg gcov-tool rewrite [rewrite-options] @var{directory} 121 1.3 mrg [@option{-n}|@option{--normalize} @var{long_long_value}] 122 1.1 mrg [@option{-o}|@option{--output} @var{directory}] 123 1.1 mrg [@option{-s}|@option{--scale} @var{float_or_simple-frac_value}] 124 1.3 mrg [@option{-v}|@option{--verbose}] 125 1.1 mrg 126 1.1 mrg gcov-tool overlap [overlap-options] @var{directory1} @var{directory2} 127 1.1 mrg [@option{-f}|@option{--function}] 128 1.1 mrg [@option{-F}|@option{--fullname}] 129 1.3 mrg [@option{-h}|@option{--hotonly}] 130 1.1 mrg [@option{-o}|@option{--object}] 131 1.1 mrg [@option{-t}|@option{--hot_threshold}] @var{float} 132 1.3 mrg [@option{-v}|@option{--verbose}] 133 1.1 mrg 134 1.1 mrg @c man end 135 1.1 mrg @c man begin SEEALSO 136 1.1 mrg gpl(7), gfdl(7), fsf-funding(7), gcc(1), gcov(1) and the Info entry for 137 1.1 mrg @file{gcc}. 138 1.1 mrg @c man end 139 1.1 mrg @end ignore 140 1.1 mrg 141 1.1 mrg @c man begin OPTIONS 142 1.1 mrg @table @gcctabopt 143 1.1 mrg @item -h 144 1.1 mrg @itemx --help 145 1.1 mrg Display help about using @command{gcov-tool} (on the standard output), and 146 1.1 mrg exit without doing any further processing. 147 1.1 mrg 148 1.1 mrg @item -v 149 1.1 mrg @itemx --version 150 1.1 mrg Display the @command{gcov-tool} version number (on the standard output), 151 1.1 mrg and exit without doing any further processing. 152 1.1 mrg 153 1.1 mrg @item merge 154 1.1 mrg Merge two profile directories. 155 1.1 mrg @table @gcctabopt 156 1.1 mrg 157 1.1 mrg @item -o @var{directory} 158 1.1 mrg @itemx --output @var{directory} 159 1.1 mrg Set the output profile directory. Default output directory name is 160 1.1 mrg @var{merged_profile}. 161 1.1 mrg 162 1.3 mrg @item -v 163 1.3 mrg @itemx --verbose 164 1.3 mrg Set the verbose mode. 165 1.3 mrg 166 1.1 mrg @item -w @var{w1},@var{w2} 167 1.1 mrg @itemx --weight @var{w1},@var{w2} 168 1.1 mrg Set the merge weights of the @var{directory1} and @var{directory2}, 169 1.1 mrg respectively. The default weights are 1 for both. 170 1.1 mrg @end table 171 1.1 mrg 172 1.1 mrg @item rewrite 173 1.1 mrg Read the specified profile directory and rewrite to a new directory. 174 1.3 mrg @table @gcctabopt 175 1.1 mrg 176 1.3 mrg @item -n @var{long_long_value} 177 1.3 mrg @itemx --normalize <long_long_value> 178 1.3 mrg Normalize the profile. The specified value is the max counter value 179 1.3 mrg in the new profile. 180 1.1 mrg 181 1.1 mrg @item -o @var{directory} 182 1.1 mrg @itemx --output @var{directory} 183 1.1 mrg Set the output profile directory. Default output name is @var{rewrite_profile}. 184 1.1 mrg 185 1.1 mrg @item -s @var{float_or_simple-frac_value} 186 1.1 mrg @itemx --scale @var{float_or_simple-frac_value} 187 1.1 mrg Scale the profile counters. The specified value can be in floating point value, 188 1.1 mrg or simple fraction value form, such 1, 2, 2/3, and 5/3. 189 1.1 mrg 190 1.3 mrg @item -v 191 1.3 mrg @itemx --verbose 192 1.3 mrg Set the verbose mode. 193 1.1 mrg @end table 194 1.1 mrg 195 1.1 mrg @item overlap 196 1.3 mrg Compute the overlap score between the two specified profile directories. 197 1.1 mrg The overlap score is computed based on the arc profiles. It is defined as 198 1.1 mrg the sum of min (p1_counter[i] / p1_sum_all, p2_counter[i] / p2_sum_all), 199 1.1 mrg for all arc counter i, where p1_counter[i] and p2_counter[i] are two 200 1.1 mrg matched counters and p1_sum_all and p2_sum_all are the sum of counter 201 1.1 mrg values in profile 1 and profile 2, respectively. 202 1.1 mrg 203 1.1 mrg @table @gcctabopt 204 1.1 mrg @item -f 205 1.1 mrg @itemx --function 206 1.1 mrg Print function level overlap score. 207 1.1 mrg 208 1.1 mrg @item -F 209 1.1 mrg @itemx --fullname 210 1.1 mrg Print full gcda filename. 211 1.1 mrg 212 1.3 mrg @item -h 213 1.3 mrg @itemx --hotonly 214 1.3 mrg Only print info for hot objects/functions. 215 1.3 mrg 216 1.1 mrg @item -o 217 1.1 mrg @itemx --object 218 1.1 mrg Print object level overlap score. 219 1.1 mrg 220 1.1 mrg @item -t @var{float} 221 1.1 mrg @itemx --hot_threshold <float> 222 1.1 mrg Set the threshold for hot counter value. 223 1.3 mrg 224 1.3 mrg @item -v 225 1.3 mrg @itemx --verbose 226 1.3 mrg Set the verbose mode. 227 1.1 mrg @end table 228 1.1 mrg 229 1.1 mrg @end table 230 1.1 mrg 231 1.1 mrg @c man end 232