| 1 |
<html> |
| 2 |
<head> |
| 3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 4 |
<title>6. Callgrind: a call-graph generating cache and branch prediction profiler</title> |
| 5 |
<link rel="stylesheet" type="text/css" href="vg_basic.css"> |
| 6 |
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"> |
| 7 |
<link rel="home" href="index.html" title="Valgrind Documentation"> |
| 8 |
<link rel="up" href="manual.html" title="Valgrind User Manual"> |
| 9 |
<link rel="prev" href="cg-manual.html" title="5. Cachegrind: a high-precision tracing profiler"> |
| 10 |
<link rel="next" href="hg-manual.html" title="7. Helgrind: a thread error detector"> |
| 11 |
</head> |
| 12 |
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| 13 |
<div><table class="nav" width="100%" cellspacing="3" cellpadding="3" border="0" summary="Navigation header"><tr> |
| 14 |
<td width="22px" align="center" valign="middle"><a accesskey="p" href="cg-manual.html"><img src="images/prev.png" width="18" height="21" border="0" alt="Prev"></a></td> |
| 15 |
<td width="25px" align="center" valign="middle"><a accesskey="u" href="manual.html"><img src="images/up.png" width="21" height="18" border="0" alt="Up"></a></td> |
| 16 |
<td width="31px" align="center" valign="middle"><a accesskey="h" href="index.html"><img src="images/home.png" width="27" height="20" border="0" alt="Up"></a></td> |
| 17 |
<th align="center" valign="middle">Valgrind User Manual</th> |
| 18 |
<td width="22px" align="center" valign="middle"><a accesskey="n" href="hg-manual.html"><img src="images/next.png" width="18" height="21" border="0" alt="Next"></a></td> |
| 19 |
</tr></table></div> |
| 20 |
<div class="chapter"> |
| 21 |
<div class="titlepage"><div><div><h1 class="title"> |
| 22 |
<a name="cl-manual"></a>6. Callgrind: a call-graph generating cache and branch prediction profiler</h1></div></div></div> |
| 23 |
<div class="toc"> |
| 24 |
<p><b>Table of Contents</b></p> |
| 25 |
<dl class="toc"> |
| 26 |
<dt><span class="sect1"><a href="cl-manual.html#cl-manual.use">6.1. Overview</a></span></dt> |
| 27 |
<dd><dl> |
| 28 |
<dt><span class="sect2"><a href="cl-manual.html#cl-manual.functionality">6.1.1. Functionality</a></span></dt> |
| 29 |
<dt><span class="sect2"><a href="cl-manual.html#cl-manual.basics">6.1.2. Basic Usage</a></span></dt> |
| 30 |
</dl></dd> |
| 31 |
<dt><span class="sect1"><a href="cl-manual.html#cl-manual.usage">6.2. Advanced Usage</a></span></dt> |
| 32 |
<dd><dl> |
| 33 |
<dt><span class="sect2"><a href="cl-manual.html#cl-manual.dumps">6.2.1. Multiple profiling dumps from one program run</a></span></dt> |
| 34 |
<dt><span class="sect2"><a href="cl-manual.html#cl-manual.limits">6.2.2. Limiting the range of collected events</a></span></dt> |
| 35 |
<dt><span class="sect2"><a href="cl-manual.html#cl-manual.busevents">6.2.3. Counting global bus events</a></span></dt> |
| 36 |
<dt><span class="sect2"><a href="cl-manual.html#cl-manual.cycles">6.2.4. Avoiding cycles</a></span></dt> |
| 37 |
<dt><span class="sect2"><a href="cl-manual.html#cl-manual.forkingprograms">6.2.5. Forking Programs</a></span></dt> |
| 38 |
</dl></dd> |
| 39 |
<dt><span class="sect1"><a href="cl-manual.html#cl-manual.options">6.3. Callgrind Command-line Options</a></span></dt> |
| 40 |
<dd><dl> |
| 41 |
<dt><span class="sect2"><a href="cl-manual.html#cl-manual.options.creation">6.3.1. Dump creation options</a></span></dt> |
| 42 |
<dt><span class="sect2"><a href="cl-manual.html#cl-manual.options.activity">6.3.2. Activity options</a></span></dt> |
| 43 |
<dt><span class="sect2"><a href="cl-manual.html#cl-manual.options.collection">6.3.3. Data collection options</a></span></dt> |
| 44 |
<dt><span class="sect2"><a href="cl-manual.html#cl-manual.options.separation">6.3.4. Cost entity separation options</a></span></dt> |
| 45 |
<dt><span class="sect2"><a href="cl-manual.html#cl-manual.options.simulation">6.3.5. Simulation options</a></span></dt> |
| 46 |
<dt><span class="sect2"><a href="cl-manual.html#cl-manual.options.cachesimulation">6.3.6. Cache simulation options</a></span></dt> |
| 47 |
</dl></dd> |
| 48 |
<dt><span class="sect1"><a href="cl-manual.html#cl-manual.monitor-commands">6.4. Callgrind Monitor Commands</a></span></dt> |
| 49 |
<dt><span class="sect1"><a href="cl-manual.html#cl-manual.clientrequests">6.5. Callgrind specific client requests</a></span></dt> |
| 50 |
<dt><span class="sect1"><a href="cl-manual.html#cl-manual.callgrind_annotate-options">6.6. callgrind_annotate Command-line Options</a></span></dt> |
| 51 |
<dt><span class="sect1"><a href="cl-manual.html#cl-manual.callgrind_control-options">6.7. callgrind_control Command-line Options</a></span></dt> |
| 52 |
</dl> |
| 53 |
</div> |
| 54 |
<p>To use this tool, you must specify |
| 55 |
<code class="option">--tool=callgrind</code> on the |
| 56 |
Valgrind command line.</p> |
| 57 |
<div class="sect1"> |
| 58 |
<div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
| 59 |
<a name="cl-manual.use"></a>6.1. Overview</h2></div></div></div> |
| 60 |
<p>Callgrind is a profiling tool that records the call history among |
| 61 |
functions in a program's run as a call-graph. |
| 62 |
By default, the collected data consists of |
| 63 |
the number of instructions executed, their relationship |
| 64 |
to source lines, the caller/callee relationship between functions, |
| 65 |
and the numbers of such calls. |
| 66 |
Optionally, cache simulation and/or branch prediction (similar to Cachegrind) |
| 67 |
can produce further information about the runtime behavior of an application. |
| 68 |
</p> |
| 69 |
<p>The profile data is written out to a file at program |
| 70 |
termination. For presentation of the data, and interactive control |
| 71 |
of the profiling, two command line tools are provided:</p> |
| 72 |
<div class="variablelist"><dl class="variablelist"> |
| 73 |
<dt><span class="term"><span class="command"><strong>callgrind_annotate</strong></span></span></dt> |
| 74 |
<dd> |
| 75 |
<p>This command reads in the profile data, and prints a |
| 76 |
sorted lists of functions, optionally with source annotation.</p> |
| 77 |
<p>For graphical visualization of the data, try |
| 78 |
<a class="ulink" href="https://kcachegrind.github.io/html/Home.html" target="_top">KCachegrind</a>, which is a KDE/Qt based |
| 79 |
GUI that makes it easy to navigate the large amount of data that |
| 80 |
Callgrind produces.</p> |
| 81 |
</dd> |
| 82 |
<dt><span class="term"><span class="command"><strong>callgrind_control</strong></span></span></dt> |
| 83 |
<dd><p>This command enables you to interactively observe and control |
| 84 |
the status of a program currently running under Callgrind's control, |
| 85 |
without stopping the program. You can get statistics information as |
| 86 |
well as the current stack trace, and you can request zeroing of counters |
| 87 |
or dumping of profile data.</p></dd> |
| 88 |
</dl></div> |
| 89 |
<div class="sect2"> |
| 90 |
<div class="titlepage"><div><div><h3 class="title"> |
| 91 |
<a name="cl-manual.functionality"></a>6.1.1. Functionality</h3></div></div></div> |
| 92 |
<p>Cachegrind collects flat profile data: event counts (data reads, |
| 93 |
cache misses, etc.) are attributed directly to the function they |
| 94 |
occurred in. This cost attribution mechanism is |
| 95 |
called <span class="emphasis"><em>self</em></span> or <span class="emphasis"><em>exclusive</em></span> |
| 96 |
attribution.</p> |
| 97 |
<p>Callgrind extends this functionality by propagating costs |
| 98 |
across function call boundaries. If function <code class="function">foo</code> calls |
| 99 |
<code class="function">bar</code>, the costs from <code class="function">bar</code> are added into |
| 100 |
<code class="function">foo</code>'s costs. When applied to the program as a whole, |
| 101 |
this builds up a picture of so called <span class="emphasis"><em>inclusive</em></span> |
| 102 |
costs, that is, where the cost of each function includes the costs of |
| 103 |
all functions it called, directly or indirectly.</p> |
| 104 |
<p>As an example, the inclusive cost of |
| 105 |
<code class="function">main</code> should be almost 100 percent |
| 106 |
of the total program cost. Because of costs arising before |
| 107 |
<code class="function">main</code> is run, such as |
| 108 |
initialization of the run time linker and construction of global C++ |
| 109 |
objects, the inclusive cost of <code class="function">main</code> |
| 110 |
is not exactly 100 percent of the total program cost.</p> |
| 111 |
<p>Together with the call graph, this allows you to find the |
| 112 |
specific call chains starting from |
| 113 |
<code class="function">main</code> in which the majority of the |
| 114 |
program's costs occur. Caller/callee cost attribution is also useful |
| 115 |
for profiling functions called from multiple call sites, and where |
| 116 |
optimization opportunities depend on changing code in the callers, in |
| 117 |
particular by reducing the call count.</p> |
| 118 |
<p>Callgrind's cache simulation is based on that of Cachegrind. |
| 119 |
Read the documentation for <a class="xref" href="cg-manual.html" title="5. Cachegrind: a high-precision tracing profiler">Cachegrind: a cache and branch-prediction profiler</a> first. The material |
| 120 |
below describes the features supported in addition to Cachegrind's |
| 121 |
features.</p> |
| 122 |
<p>Callgrind's ability to detect function calls and returns depends |
| 123 |
on the instruction set of the platform it is run on. It works best on |
| 124 |
x86 and amd64, and unfortunately currently does not work so well on |
| 125 |
PowerPC, ARM, Thumb or MIPS code. This is because there are no explicit |
| 126 |
call or return instructions in these instruction sets, so Callgrind |
| 127 |
has to rely on heuristics to detect calls and returns.</p> |
| 128 |
</div> |
| 129 |
<div class="sect2"> |
| 130 |
<div class="titlepage"><div><div><h3 class="title"> |
| 131 |
<a name="cl-manual.basics"></a>6.1.2. Basic Usage</h3></div></div></div> |
| 132 |
<p>As with Cachegrind, you probably want to compile with debugging info |
| 133 |
(the <code class="option">-g</code> option) and with optimization turned on.</p> |
| 134 |
<p>To start a profile run for a program, execute: |
| 135 |
</p> |
| 136 |
<pre class="screen">valgrind --tool=callgrind [callgrind options] your-program [program options]</pre> |
| 137 |
<p> |
| 138 |
</p> |
| 139 |
<p>While the simulation is running, you can observe execution with: |
| 140 |
</p> |
| 141 |
<pre class="screen">callgrind_control -b</pre> |
| 142 |
<p> |
| 143 |
This will print out the current backtrace. To annotate the backtrace with |
| 144 |
event counts, run |
| 145 |
</p> |
| 146 |
<pre class="screen">callgrind_control -e -b</pre> |
| 147 |
<p> |
| 148 |
</p> |
| 149 |
<p>After program termination, a profile data file named |
| 150 |
<code class="computeroutput">callgrind.out.<pid></code> |
| 151 |
is generated, where <span class="emphasis"><em>pid</em></span> is the process ID |
| 152 |
of the program being profiled. |
| 153 |
The data file contains information about the calls made in the |
| 154 |
program among the functions executed, together with |
| 155 |
<span class="command"><strong>Instruction Read</strong></span> (Ir) event counts.</p> |
| 156 |
<p>To generate a function-by-function summary from the profile |
| 157 |
data file, use |
| 158 |
</p> |
| 159 |
<pre class="screen">callgrind_annotate [options] callgrind.out.<pid></pre> |
| 160 |
<p> |
| 161 |
This summary is similar to the output you get from a Cachegrind |
| 162 |
run with cg_annotate: the list |
| 163 |
of functions is ordered by exclusive cost of functions, which also |
| 164 |
are the ones that are shown. |
| 165 |
Important for the additional features of Callgrind are |
| 166 |
the following two options:</p> |
| 167 |
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| 168 |
<li class="listitem"><p><code class="option">--inclusive=yes</code>: Instead of using |
| 169 |
exclusive cost of functions as sorting order, use and show |
| 170 |
inclusive cost.</p></li> |
| 171 |
<li class="listitem"><p><code class="option">--tree=both</code>: Interleave into the |
| 172 |
top level list of functions, information on the callers and the callees |
| 173 |
of each function. In these lines, which represents executed |
| 174 |
calls, the cost gives the number of events spent in the call. |
| 175 |
Indented, above each function, there is the list of callers, |
| 176 |
and below, the list of callees. The sum of events in calls to |
| 177 |
a given function (caller lines), as well as the sum of events in |
| 178 |
calls from the function (callee lines) together with the self |
| 179 |
cost, gives the total inclusive cost of the function.</p></li> |
| 180 |
</ul></div> |
| 181 |
<p>By default, you will also get annotated source code |
| 182 |
for all relevant functions for which the source can be found. In |
| 183 |
addition to source annotation as produced by |
| 184 |
<code class="computeroutput">cg_annotate</code>, you will see the |
| 185 |
annotated call sites with call counts. For all other options, |
| 186 |
consult the (Cachegrind) documentation for |
| 187 |
<code class="computeroutput">cg_annotate</code>. |
| 188 |
</p> |
| 189 |
<p>For better call graph browsing experience, it is highly recommended |
| 190 |
to use <a class="ulink" href="https://kcachegrind.github.io/html/Home.html" target="_top">KCachegrind</a>. |
| 191 |
If your code |
| 192 |
has a significant fraction of its cost in <span class="emphasis"><em>cycles</em></span> (sets |
| 193 |
of functions calling each other in a recursive manner), you have to |
| 194 |
use KCachegrind, as <code class="computeroutput">callgrind_annotate</code> |
| 195 |
currently does not do any cycle detection, which is important to get correct |
| 196 |
results in this case.</p> |
| 197 |
<p>If you are additionally interested in measuring the |
| 198 |
cache behavior of your program, use Callgrind with the option |
| 199 |
<code class="option"><a class="link" href="cl-manual.html#clopt.cache-sim">--cache-sim=yes</a></code>. |
| 200 |
For branch prediction simulation, use |
| 201 |
<code class="option"><a class="link" href="cl-manual.html#clopt.branch-sim">--branch-sim=yes</a></code>. |
| 202 |
Expect a further slow down approximately by a factor of 2.</p> |
| 203 |
<p>If the program section you want to profile is somewhere in the |
| 204 |
middle of the run, it is beneficial to |
| 205 |
<span class="emphasis"><em>fast forward</em></span> to this section without any |
| 206 |
profiling, and then enable profiling. This is achieved by using |
| 207 |
the command line option |
| 208 |
<code class="option"><a class="link" href="cl-manual.html#opt.instr-atstart">--instr-atstart=no</a></code> |
| 209 |
and running, in a shell: |
| 210 |
<code class="computeroutput">callgrind_control -i on</code> just before the |
| 211 |
interesting code section is executed. To exactly specify |
| 212 |
the code position where profiling should start, use the client request |
| 213 |
<code class="computeroutput"><a class="link" href="cl-manual.html#cr.start-instr">CALLGRIND_START_INSTRUMENTATION</a></code>.</p> |
| 214 |
<p>If you want to be able to see assembly code level annotation, specify |
| 215 |
<code class="option"><a class="link" href="cl-manual.html#opt.dump-instr">--dump-instr=yes</a></code>. |
| 216 |
This will produce profile data at instruction granularity. |
| 217 |
Note that the resulting profile data |
| 218 |
can only be viewed with KCachegrind. For assembly annotation, it also is |
| 219 |
interesting to see more details of the control flow inside of functions, |
| 220 |
i.e. (conditional) jumps. This will be collected by further specifying |
| 221 |
<code class="option"><a class="link" href="cl-manual.html#opt.collect-jumps">--collect-jumps=yes</a></code>. |
| 222 |
</p> |
| 223 |
</div> |
| 224 |
</div> |
| 225 |
<div class="sect1"> |
| 226 |
<div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
| 227 |
<a name="cl-manual.usage"></a>6.2. Advanced Usage</h2></div></div></div> |
| 228 |
<div class="sect2"> |
| 229 |
<div class="titlepage"><div><div><h3 class="title"> |
| 230 |
<a name="cl-manual.dumps"></a>6.2.1. Multiple profiling dumps from one program run</h3></div></div></div> |
| 231 |
<p>Sometimes you are not interested in characteristics of a full |
| 232 |
program run, but only of a small part of it, for example execution of one |
| 233 |
algorithm. If there are multiple algorithms, or one algorithm |
| 234 |
running with different input data, it may even be useful to get different |
| 235 |
profile information for different parts of a single program run.</p> |
| 236 |
<p>Profile data files have names of the form |
| 237 |
</p> |
| 238 |
<pre class="screen"> |
| 239 |
callgrind.out.<span class="emphasis"><em>pid</em></span>.<span class="emphasis"><em>part</em></span>-<span class="emphasis"><em>threadID</em></span> |
| 240 |
</pre> |
| 241 |
<p> |
| 242 |
</p> |
| 243 |
<p>where <span class="emphasis"><em>pid</em></span> is the PID of the running |
| 244 |
program, <span class="emphasis"><em>part</em></span> is a number incremented on each |
| 245 |
dump (".part" is skipped for the dump at program termination), and |
| 246 |
<span class="emphasis"><em>threadID</em></span> is a thread identification |
| 247 |
("-threadID" is only used if you request dumps of individual |
| 248 |
threads with |
| 249 |
<code class="option"><a class="link" href="cl-manual.html#opt.separate-threads">--separate-threads=yes</a></code>). |
| 250 |
</p> |
| 251 |
<p>There are different ways to generate multiple profile dumps |
| 252 |
while a program is running under Callgrind's supervision. Nevertheless, |
| 253 |
all methods trigger the same action, which is "dump all profile |
| 254 |
information since the last dump or program start, and zero cost |
| 255 |
counters afterwards". To allow for zeroing cost counters without |
| 256 |
dumping, there is a second action "zero all cost counters now". |
| 257 |
The different methods are:</p> |
| 258 |
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| 259 |
<li class="listitem"><p><span class="command"><strong>Dump on program termination.</strong></span> |
| 260 |
This method is the standard way and doesn't need any special |
| 261 |
action on your part.</p></li> |
| 262 |
<li class="listitem"> |
| 263 |
<p><span class="command"><strong>Spontaneous, interactive dumping.</strong></span> Use |
| 264 |
</p> |
| 265 |
<pre class="screen">callgrind_control -d [hint [PID/Name]]</pre> |
| 266 |
<p> to |
| 267 |
request the dumping of profile information of the supervised |
| 268 |
application with PID or Name. <span class="emphasis"><em>hint</em></span> is an |
| 269 |
arbitrary string you can optionally specify to later be able to |
| 270 |
distinguish profile dumps. The control program will not terminate |
| 271 |
before the dump is completely written. Note that the application |
| 272 |
must be actively running for detection of the dump command. So, |
| 273 |
for a GUI application, resize the window, or for a server, send a |
| 274 |
request.</p> |
| 275 |
<p>If you are using <a class="ulink" href="https://kcachegrind.github.io/html/Home.html" target="_top">KCachegrind</a> |
| 276 |
for browsing of profile information, you can use the toolbar |
| 277 |
button <span class="command"><strong>Force dump</strong></span>. This will request a dump |
| 278 |
and trigger a reload after the dump is written.</p> |
| 279 |
</li> |
| 280 |
<li class="listitem"><p><span class="command"><strong>Periodic dumping after execution of a specified |
| 281 |
number of basic blocks</strong></span>. For this, use the command line |
| 282 |
option <code class="option"><a class="link" href="cl-manual.html#opt.dump-every-bb">--dump-every-bb=count</a></code>. |
| 283 |
</p></li> |
| 284 |
<li class="listitem"> |
| 285 |
<p><span class="command"><strong>Dumping at enter/leave of specified functions.</strong></span> |
| 286 |
Use the |
| 287 |
option <code class="option"><a class="link" href="cl-manual.html#opt.dump-before">--dump-before=function</a></code> |
| 288 |
and <code class="option"><a class="link" href="cl-manual.html#opt.dump-after">--dump-after=function</a></code>. |
| 289 |
To zero cost counters before entering a function, use |
| 290 |
<code class="option"><a class="link" href="cl-manual.html#opt.zero-before">--zero-before=function</a></code>.</p> |
| 291 |
<p>You can specify these options multiple times for different |
| 292 |
functions. Function specifications support wildcards: e.g. use |
| 293 |
<code class="option"><a class="link" href="cl-manual.html#opt.dump-before">--dump-before='foo*'</a></code> to |
| 294 |
generate dumps before entering any function starting with |
| 295 |
<span class="emphasis"><em>foo</em></span>.</p> |
| 296 |
</li> |
| 297 |
<li class="listitem"><p><span class="command"><strong>Program controlled dumping.</strong></span> |
| 298 |
Insert |
| 299 |
<code class="computeroutput"><a class="link" href="cl-manual.html#cr.dump-stats">CALLGRIND_DUMP_STATS</a>;</code> |
| 300 |
at the position in your code where you want a profile dump to |
| 301 |
happen. Use |
| 302 |
<code class="computeroutput"><a class="link" href="cl-manual.html#cr.zero-stats">CALLGRIND_ZERO_STATS</a>;</code> to only |
| 303 |
zero profile counters. |
| 304 |
See <a class="xref" href="cl-manual.html#cl-manual.clientrequests" title="6.5. Callgrind specific client requests">Client request reference</a> for more information on |
| 305 |
Callgrind specific client requests.</p></li> |
| 306 |
</ul></div> |
| 307 |
<p>If you are running a multi-threaded application and specify the |
| 308 |
command line option |
| 309 |
<code class="option"><a class="link" href="cl-manual.html#opt.separate-threads">--separate-threads=yes</a></code>, |
| 310 |
every thread will be profiled on its own and will create its own |
| 311 |
profile dump. Thus, the last two methods will only generate one dump |
| 312 |
of the currently running thread. With the other methods, you will get |
| 313 |
multiple dumps (one for each thread) on a dump request.</p> |
| 314 |
</div> |
| 315 |
<div class="sect2"> |
| 316 |
<div class="titlepage"><div><div><h3 class="title"> |
| 317 |
<a name="cl-manual.limits"></a>6.2.2. Limiting the range of collected events</h3></div></div></div> |
| 318 |
<p>By default, whenever events are happening (such as an |
| 319 |
instruction execution or cache hit/miss), Callgrind is aggregating |
| 320 |
them into event counters. However, you may be interested only in |
| 321 |
what is happening within a given function or starting from a given |
| 322 |
program phase. To this end, you can disable event aggregation for |
| 323 |
uninteresting program parts. While attribution of events to |
| 324 |
functions as well as producing separate output per program phase |
| 325 |
can be done by other means (see previous section), there are two |
| 326 |
benefits by disabling aggregation. First, this is very |
| 327 |
fine-granular (e.g. just for a loop within a function). Second, |
| 328 |
disabling event aggregation for complete program phases allows to |
| 329 |
switch off time-consuming cache simulation and allows Callgrind to |
| 330 |
progress at much higher speed with an slowdown of around factor 2 |
| 331 |
(identical to <code class="computeroutput">valgrind |
| 332 |
--tool=none</code>). |
| 333 |
</p> |
| 334 |
<p>There are two aspects which influence whether Callgrind is |
| 335 |
aggregating events at some point in time of program execution. |
| 336 |
First, there is the <span class="emphasis"><em>collection state</em></span>. If this |
| 337 |
is off, no aggregation will be done. By changing the collection |
| 338 |
state, you can control event aggregation at a very fine |
| 339 |
granularity. However, there is not much difference in regard to |
| 340 |
execution speed of Callgrind. By default, collection is switched |
| 341 |
on, but can be disabled by different means (see below). Second, |
| 342 |
there is the <span class="emphasis"><em>instrumentation mode</em></span> in which |
| 343 |
Callgrind is running. This mode either can be on or off. If |
| 344 |
instrumentation is off, no observation of actions in the program |
| 345 |
will be done and thus, no actions will be forwarded to the |
| 346 |
simulator which could trigger events. In the end, no events will |
| 347 |
be aggregated. The huge benefit is the much higher speed with |
| 348 |
instrumentation switched off. However, this only should be used |
| 349 |
with care and in a coarse fashion: every mode change resets the |
| 350 |
simulator state (ie. whether a memory block is cached or not) and |
| 351 |
flushes Valgrinds internal cache of instrumented code blocks, |
| 352 |
resulting in latency penalty at switching time. Also, cache |
| 353 |
simulator results directly after switching on instrumentation will |
| 354 |
be skewed due to identified cache misses which would not happen in |
| 355 |
reality (if you care about this warm-up effect, you should make |
| 356 |
sure to temporarly have collection state switched off directly |
| 357 |
after turning instrumentation mode on). However, switching |
| 358 |
instrumentation state is very useful to skip larger program phases |
| 359 |
such as an initialization phase. By default, instrumentation is |
| 360 |
switched on, but as with the collection state, can be changed by |
| 361 |
various means. |
| 362 |
</p> |
| 363 |
<p>Callgrind can start with instrumentation mode switched off by |
| 364 |
specifying option |
| 365 |
<code class="option"><a class="link" href="cl-manual.html#opt.instr-atstart">--instr-atstart=no</a></code>. |
| 366 |
Afterwards, instrumentation can be controlled in two ways: first, |
| 367 |
interactively with: </p> |
| 368 |
<pre class="screen">callgrind_control -i on</pre> |
| 369 |
<p> (and |
| 370 |
switching off again by specifying "off" instead of "on"). Second, |
| 371 |
instrumentation state can be programmatically changed with the |
| 372 |
macros <code class="computeroutput"><a class="link" href="cl-manual.html#cr.start-instr">CALLGRIND_START_INSTRUMENTATION</a>;</code> |
| 373 |
and <code class="computeroutput"><a class="link" href="cl-manual.html#cr.stop-instr">CALLGRIND_STOP_INSTRUMENTATION</a>;</code>. |
| 374 |
</p> |
| 375 |
<p>Similarly, the collection state at program start can be |
| 376 |
switched off by |
| 377 |
<code class="option"><a class="link" href="cl-manual.html#opt.instr-atstart">--instr-atstart=no</a></code>. |
| 378 |
During execution, it can be controlled programmatically with the |
| 379 |
macro <code class="computeroutput">CALLGRIND_TOGGLE_COLLECT;</code>. |
| 380 |
Further, you can limit event collection to a specific function by |
| 381 |
using <code class="option"><a class="link" href="cl-manual.html#opt.toggle-collect">--toggle-collect=function</a></code>. |
| 382 |
This will toggle the collection state on entering and leaving the |
| 383 |
specified function. When this option is in effect, the default |
| 384 |
collection state at program start is "off". Only events happening |
| 385 |
while running inside of the given function will be |
| 386 |
collected. Recursive calls of the given function do not trigger |
| 387 |
any action. This option can be given multiple times to specify |
| 388 |
different functions of interest.</p> |
| 389 |
</div> |
| 390 |
<div class="sect2"> |
| 391 |
<div class="titlepage"><div><div><h3 class="title"> |
| 392 |
<a name="cl-manual.busevents"></a>6.2.3. Counting global bus events</h3></div></div></div> |
| 393 |
<p>For access to shared data among threads in a multithreaded |
| 394 |
code, synchronization is required to avoid raced conditions. |
| 395 |
Synchronization primitives are usually implemented via atomic instructions. |
| 396 |
However, excessive use of such instructions can lead to performance |
| 397 |
issues.</p> |
| 398 |
<p>To enable analysis of this problem, Callgrind optionally can count |
| 399 |
the number of atomic instructions executed. More precisely, for x86/x86_64, |
| 400 |
these are instructions using a lock prefix. For architectures supporting |
| 401 |
LL/SC, these are the number of SC instructions executed. For both, the term |
| 402 |
"global bus events" is used.</p> |
| 403 |
<p>The short name of the event type used for global bus events is "Ge". |
| 404 |
To count global bus events, use |
| 405 |
<code class="option"><a class="link" href="cl-manual.html#clopt.collect-bus">--collect-bus=yes</a></code>. |
| 406 |
</p> |
| 407 |
</div> |
| 408 |
<div class="sect2"> |
| 409 |
<div class="titlepage"><div><div><h3 class="title"> |
| 410 |
<a name="cl-manual.cycles"></a>6.2.4. Avoiding cycles</h3></div></div></div> |
| 411 |
<p>Informally speaking, a cycle is a group of functions which |
| 412 |
call each other in a recursive way.</p> |
| 413 |
<p>Formally speaking, a cycle is a nonempty set S of functions, |
| 414 |
such that for every pair of functions F and G in S, it is possible |
| 415 |
to call from F to G (possibly via intermediate functions) and also |
| 416 |
from G to F. Furthermore, S must be maximal -- that is, be the |
| 417 |
largest set of functions satisfying this property. For example, if |
| 418 |
a third function H is called from inside S and calls back into S, |
| 419 |
then H is also part of the cycle and should be included in S.</p> |
| 420 |
<p>Recursion is quite usual in programs, and therefore, cycles |
| 421 |
sometimes appear in the call graph output of Callgrind. However, |
| 422 |
the title of this chapter should raise two questions: What is bad |
| 423 |
about cycles which makes you want to avoid them? And: How can |
| 424 |
cycles be avoided without changing program code?</p> |
| 425 |
<p>Cycles are not bad in itself, but tend to make performance |
| 426 |
analysis of your code harder. This is because inclusive costs |
| 427 |
for calls inside of a cycle are meaningless. The definition of |
| 428 |
inclusive cost, i.e. self cost of a function plus inclusive cost |
| 429 |
of its callees, needs a topological order among functions. For |
| 430 |
cycles, this does not hold true: callees of a function in a cycle include |
| 431 |
the function itself. Therefore, KCachegrind does cycle detection |
| 432 |
and skips visualization of any inclusive cost for calls inside |
| 433 |
of cycles. Further, all functions in a cycle are collapsed into artificial |
| 434 |
functions called like <code class="computeroutput">Cycle 1</code>.</p> |
| 435 |
<p>Now, when a program exposes really big cycles (as is |
| 436 |
true for some GUI code, or in general code using event or callback based |
| 437 |
programming style), you lose the nice property to let you pinpoint |
| 438 |
the bottlenecks by following call chains from |
| 439 |
<code class="function">main</code>, guided via |
| 440 |
inclusive cost. In addition, KCachegrind loses its ability to show |
| 441 |
interesting parts of the call graph, as it uses inclusive costs to |
| 442 |
cut off uninteresting areas.</p> |
| 443 |
<p>Despite the meaningless of inclusive costs in cycles, the big |
| 444 |
drawback for visualization motivates the possibility to temporarily |
| 445 |
switch off cycle detection in KCachegrind, which can lead to |
| 446 |
misguiding visualization. However, often cycles appear because of |
| 447 |
unlucky superposition of independent call chains in a way that |
| 448 |
the profile result will see a cycle. Neglecting uninteresting |
| 449 |
calls with very small measured inclusive cost would break these |
| 450 |
cycles. In such cases, incorrect handling of cycles by not detecting |
| 451 |
them still gives meaningful profiling visualization.</p> |
| 452 |
<p>It has to be noted that currently, <span class="command"><strong>callgrind_annotate</strong></span> |
| 453 |
does not do any cycle detection at all. For program executions with function |
| 454 |
recursion, it e.g. can print nonsense inclusive costs way above 100%.</p> |
| 455 |
<p>After describing why cycles are bad for profiling, it is worth |
| 456 |
talking about cycle avoidance. The key insight here is that symbols in |
| 457 |
the profile data do not have to exactly match the symbols found in the |
| 458 |
program. Instead, the symbol name could encode additional information |
| 459 |
from the current execution context such as recursion level of the |
| 460 |
current function, or even some part of the call chain leading to the |
| 461 |
function. While encoding of additional information into symbols is |
| 462 |
quite capable of avoiding cycles, it has to be used carefully to not cause |
| 463 |
symbol explosion. The latter imposes large memory requirement for Callgrind |
| 464 |
with possible out-of-memory conditions, and big profile data files.</p> |
| 465 |
<p>A further possibility to avoid cycles in Callgrind's profile data |
| 466 |
output is to simply leave out given functions in the call graph. Of course, this |
| 467 |
also skips any call information from and to an ignored function, and thus can |
| 468 |
break a cycle. Candidates for this typically are dispatcher functions in event |
| 469 |
driven code. The option to ignore calls to a function is |
| 470 |
<code class="option"><a class="link" href="cl-manual.html#opt.fn-skip">--fn-skip=function</a></code>. |
| 471 |
Aside from possibly breaking cycles, this is used in Callgrind to skip |
| 472 |
trampoline functions in the PLT sections |
| 473 |
for calls to functions in shared libraries. You can see the difference |
| 474 |
if you profile with |
| 475 |
<code class="option"><a class="link" href="cl-manual.html#opt.skip-plt">--skip-plt=no</a></code>. |
| 476 |
If a call is ignored, its cost events will be propagated to the |
| 477 |
enclosing function.</p> |
| 478 |
<p>If you have a recursive function, you can distinguish the first |
| 479 |
10 recursion levels by specifying |
| 480 |
<code class="option"><a class="link" href="cl-manual.html#opt.separate-recs-num">--separate-recs10=function</a></code>. |
| 481 |
Or for all functions with |
| 482 |
<code class="option"><a class="link" href="cl-manual.html#opt.separate-recs">--separate-recs=10</a></code>, |
| 483 |
but this will |
| 484 |
give you much bigger profile data files. In the profile data, you will see |
| 485 |
the recursion levels of "func" as the different functions with names |
| 486 |
"func", "func'2", "func'3" and so on.</p> |
| 487 |
<p>If you have call chains "A > B > C" and "A > C > B" |
| 488 |
in your program, you usually get a "false" cycle "B <> C". Use |
| 489 |
<code class="option"><a class="link" href="cl-manual.html#opt.separate-callers-num">--separate-callers2=B</a></code> |
| 490 |
<code class="option"><a class="link" href="cl-manual.html#opt.separate-callers-num">--separate-callers2=C</a></code>, |
| 491 |
and functions "B" and "C" will be treated as different functions |
| 492 |
depending on the direct caller. Using the apostrophe for appending |
| 493 |
this "context" to the function name, you get "A > B'A > C'B" |
| 494 |
and "A > C'A > B'C", and there will be no cycle. Use |
| 495 |
<code class="option"><a class="link" href="cl-manual.html#opt.separate-callers">--separate-callers=2</a></code> to get a 2-caller |
| 496 |
dependency for all functions. Note that doing this will increase |
| 497 |
the size of profile data files.</p> |
| 498 |
</div> |
| 499 |
<div class="sect2"> |
| 500 |
<div class="titlepage"><div><div><h3 class="title"> |
| 501 |
<a name="cl-manual.forkingprograms"></a>6.2.5. Forking Programs</h3></div></div></div> |
| 502 |
<p>If your program forks, the child will inherit all the profiling |
| 503 |
data that has been gathered for the parent. To start with empty profile |
| 504 |
counter values in the child, the client request |
| 505 |
<code class="computeroutput"><a class="link" href="cl-manual.html#cr.zero-stats">CALLGRIND_ZERO_STATS</a>;</code> |
| 506 |
can be inserted into code to be executed by the child, directly |
| 507 |
after |
| 508 |
<code class="computeroutput">fork</code>.</p> |
| 509 |
<p>However, you will have to make sure that the output file format string |
| 510 |
(controlled by <code class="option">--callgrind-out-file</code>) does contain |
| 511 |
<code class="option">%p</code> (which is true by default). Otherwise, the |
| 512 |
outputs from the parent and child will overwrite each other or will be |
| 513 |
intermingled, which almost certainly is not what you want.</p> |
| 514 |
<p>You will be able to control the new child independently from |
| 515 |
the parent via callgrind_control.</p> |
| 516 |
</div> |
| 517 |
</div> |
| 518 |
<div class="sect1"> |
| 519 |
<div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
| 520 |
<a name="cl-manual.options"></a>6.3. Callgrind Command-line Options</h2></div></div></div> |
| 521 |
<p> |
| 522 |
In the following, options are grouped into classes. |
| 523 |
</p> |
| 524 |
<p> |
| 525 |
Some options allow the specification of a function/symbol name, such as |
| 526 |
<code class="option"><a class="link" href="cl-manual.html#opt.dump-before">--dump-before=function</a></code>, or |
| 527 |
<code class="option"><a class="link" href="cl-manual.html#opt.fn-skip">--fn-skip=function</a></code>. |
| 528 |
All these options can be specified multiple times for different functions. |
| 529 |
In addition, the function specifications actually are patterns by supporting |
| 530 |
the use of wildcards '*' (zero or more arbitrary characters) and '?' |
| 531 |
(exactly one arbitrary character), similar to file name globbing in the |
| 532 |
shell. This feature is important especially for C++, as without wildcard |
| 533 |
usage, the function would have to be specified in full extent, including |
| 534 |
parameter signature. </p> |
| 535 |
<div class="sect2"> |
| 536 |
<div class="titlepage"><div><div><h3 class="title"> |
| 537 |
<a name="cl-manual.options.creation"></a>6.3.1. Dump creation options</h3></div></div></div> |
| 538 |
<p> |
| 539 |
These options influence the name and format of the profile data files. |
| 540 |
</p> |
| 541 |
<div class="variablelist"> |
| 542 |
<a name="cl.opts.list.creation"></a><dl class="variablelist"> |
| 543 |
<dt> |
| 544 |
<a name="opt.callgrind-out-file"></a><span class="term"> |
| 545 |
<code class="option">--callgrind-out-file=<file> </code> |
| 546 |
</span> |
| 547 |
</dt> |
| 548 |
<dd><p>Write the profile data to |
| 549 |
<code class="computeroutput">file</code> rather than to the default |
| 550 |
output file, |
| 551 |
<code class="computeroutput">callgrind.out.<pid></code>. The |
| 552 |
<code class="option">%p</code> and <code class="option">%q</code> format specifiers |
| 553 |
can be used to embed the process ID and/or the contents of an |
| 554 |
environment variable in the name, as is the case for the core |
| 555 |
option |
| 556 |
<code class="option"><a class="link" href="manual-core.html#opt.log-file">--log-file</a></code>. |
| 557 |
When multiple dumps are made, the file name |
| 558 |
is modified further; see below.</p></dd> |
| 559 |
<dt> |
| 560 |
<a name="opt.dump-line"></a><span class="term"> |
| 561 |
<code class="option">--dump-line=<no|yes> [default: yes] </code> |
| 562 |
</span> |
| 563 |
</dt> |
| 564 |
<dd><p>This specifies that event counting should be performed at |
| 565 |
source line granularity. This allows source annotation for sources |
| 566 |
which are compiled with debug information |
| 567 |
(<code class="option">-g</code>).</p></dd> |
| 568 |
<dt> |
| 569 |
<a name="opt.dump-instr"></a><span class="term"> |
| 570 |
<code class="option">--dump-instr=<no|yes> [default: no] </code> |
| 571 |
</span> |
| 572 |
</dt> |
| 573 |
<dd><p>This specifies that event counting should be performed at |
| 574 |
per-instruction granularity. |
| 575 |
This allows for assembly code |
| 576 |
annotation. Currently the results can only be |
| 577 |
displayed by KCachegrind.</p></dd> |
| 578 |
<dt> |
| 579 |
<a name="opt.compress-strings"></a><span class="term"> |
| 580 |
<code class="option">--compress-strings=<no|yes> [default: yes] </code> |
| 581 |
</span> |
| 582 |
</dt> |
| 583 |
<dd><p>This option influences the output format of the profile data. |
| 584 |
It specifies whether strings (file and function names) should be |
| 585 |
identified by numbers. This shrinks the file, |
| 586 |
but makes it more difficult |
| 587 |
for humans to read (which is not recommended in any case).</p></dd> |
| 588 |
<dt> |
| 589 |
<a name="opt.compress-pos"></a><span class="term"> |
| 590 |
<code class="option">--compress-pos=<no|yes> [default: yes] </code> |
| 591 |
</span> |
| 592 |
</dt> |
| 593 |
<dd><p>This option influences the output format of the profile data. |
| 594 |
It specifies whether numerical positions are always specified as absolute |
| 595 |
values or are allowed to be relative to previous numbers. |
| 596 |
This shrinks the file size.</p></dd> |
| 597 |
<dt> |
| 598 |
<a name="opt.combine-dumps"></a><span class="term"> |
| 599 |
<code class="option">--combine-dumps=<no|yes> [default: no] </code> |
| 600 |
</span> |
| 601 |
</dt> |
| 602 |
<dd><p>When enabled, when multiple profile data parts are to be |
| 603 |
generated these parts are appended to the same output file. |
| 604 |
Not recommended.</p></dd> |
| 605 |
</dl> |
| 606 |
</div> |
| 607 |
</div> |
| 608 |
<div class="sect2"> |
| 609 |
<div class="titlepage"><div><div><h3 class="title"> |
| 610 |
<a name="cl-manual.options.activity"></a>6.3.2. Activity options</h3></div></div></div> |
| 611 |
<p> |
| 612 |
These options specify when actions relating to event counts are to |
| 613 |
be executed. For interactive control use callgrind_control. |
| 614 |
</p> |
| 615 |
<div class="variablelist"> |
| 616 |
<a name="cl.opts.list.activity"></a><dl class="variablelist"> |
| 617 |
<dt> |
| 618 |
<a name="opt.dump-every-bb"></a><span class="term"> |
| 619 |
<code class="option">--dump-every-bb=<count> [default: 0, never] </code> |
| 620 |
</span> |
| 621 |
</dt> |
| 622 |
<dd><p>Dump profile data every <code class="option">count</code> basic blocks. |
| 623 |
Whether a dump is needed is only checked when Valgrind's internal |
| 624 |
scheduler is run. Therefore, the minimum setting useful is about 100000. |
| 625 |
The count is a 64-bit value to make long dump periods possible. |
| 626 |
</p></dd> |
| 627 |
<dt> |
| 628 |
<a name="opt.dump-before"></a><span class="term"> |
| 629 |
<code class="option">--dump-before=<function> </code> |
| 630 |
</span> |
| 631 |
</dt> |
| 632 |
<dd><p>Dump when entering <code class="option">function</code>.</p></dd> |
| 633 |
<dt> |
| 634 |
<a name="opt.zero-before"></a><span class="term"> |
| 635 |
<code class="option">--zero-before=<function> </code> |
| 636 |
</span> |
| 637 |
</dt> |
| 638 |
<dd><p>Zero all costs when entering <code class="option">function</code>.</p></dd> |
| 639 |
<dt> |
| 640 |
<a name="opt.dump-after"></a><span class="term"> |
| 641 |
<code class="option">--dump-after=<function> </code> |
| 642 |
</span> |
| 643 |
</dt> |
| 644 |
<dd><p>Dump when leaving <code class="option">function</code>.</p></dd> |
| 645 |
</dl> |
| 646 |
</div> |
| 647 |
</div> |
| 648 |
<div class="sect2"> |
| 649 |
<div class="titlepage"><div><div><h3 class="title"> |
| 650 |
<a name="cl-manual.options.collection"></a>6.3.3. Data collection options</h3></div></div></div> |
| 651 |
<p> |
| 652 |
These options specify when events are to be aggregated into event counts. |
| 653 |
Also see <a class="xref" href="cl-manual.html#cl-manual.limits" title="6.2.2. Limiting the range of collected events">Limiting range of event collection</a>.</p> |
| 654 |
<div class="variablelist"> |
| 655 |
<a name="cl.opts.list.collection"></a><dl class="variablelist"> |
| 656 |
<dt> |
| 657 |
<a name="opt.instr-atstart"></a><span class="term"> |
| 658 |
<code class="option">--instr-atstart=<yes|no> [default: yes] </code> |
| 659 |
</span> |
| 660 |
</dt> |
| 661 |
<dd> |
| 662 |
<p>Specify if you want Callgrind to start simulation and |
| 663 |
profiling from the beginning of the program. |
| 664 |
When set to <code class="computeroutput">no</code>, |
| 665 |
Callgrind will not be able |
| 666 |
to collect any information, including calls, but it will have at |
| 667 |
most a slowdown of around 4, which is the minimum Valgrind |
| 668 |
overhead. Instrumentation can be interactively enabled via |
| 669 |
<code class="computeroutput">callgrind_control -i on</code>.</p> |
| 670 |
<p>Note that the resulting call graph will most probably not |
| 671 |
contain <code class="function">main</code>, but will contain all the |
| 672 |
functions executed after instrumentation was enabled. |
| 673 |
Instrumentation can also be programmatically enabled/disabled. See the |
| 674 |
Callgrind include file |
| 675 |
<code class="computeroutput">callgrind.h</code> for the macro |
| 676 |
you have to use in your source code.</p> |
| 677 |
<p>For cache |
| 678 |
simulation, results will be less accurate when switching on |
| 679 |
instrumentation later in the program run, as the simulator starts |
| 680 |
with an empty cache at that moment. Switch on event collection |
| 681 |
later to cope with this error.</p> |
| 682 |
</dd> |
| 683 |
<dt> |
| 684 |
<a name="opt.collect-atstart"></a><span class="term"> |
| 685 |
<code class="option">--collect-atstart=<yes|no> [default: yes] </code> |
| 686 |
</span> |
| 687 |
</dt> |
| 688 |
<dd> |
| 689 |
<p>Specify whether event collection is enabled at beginning |
| 690 |
of the profile run.</p> |
| 691 |
<p>To only look at parts of your program, you have two |
| 692 |
possibilities:</p> |
| 693 |
<div class="orderedlist"><ol class="orderedlist" type="1"> |
| 694 |
<li class="listitem"><p>Zero event counters before entering the program part you |
| 695 |
want to profile, and dump the event counters to a file after |
| 696 |
leaving that program part.</p></li> |
| 697 |
<li class="listitem"><p>Switch on/off collection state as needed to only see |
| 698 |
event counters happening while inside of the program part you |
| 699 |
want to profile.</p></li> |
| 700 |
</ol></div> |
| 701 |
<p>The second option can be used if the program part you want to |
| 702 |
profile is called many times. Option 1, i.e. creating a lot of |
| 703 |
dumps is not practical here.</p> |
| 704 |
<p>Collection state can be |
| 705 |
toggled at entry and exit of a given function with the |
| 706 |
option <code class="option"><a class="link" href="cl-manual.html#opt.toggle-collect">--toggle-collect</a></code>. If you |
| 707 |
use this option, collection |
| 708 |
state should be disabled at the beginning. Note that the |
| 709 |
specification of <code class="option">--toggle-collect</code> |
| 710 |
implicitly sets |
| 711 |
<code class="option">--collect-state=no</code>.</p> |
| 712 |
<p>Collection state can be toggled also by inserting the client request |
| 713 |
<code class="computeroutput"> |
| 714 |
|
| 715 |
CALLGRIND_TOGGLE_COLLECT |
| 716 |
;</code> |
| 717 |
at the needed code positions.</p> |
| 718 |
</dd> |
| 719 |
<dt> |
| 720 |
<a name="opt.toggle-collect"></a><span class="term"> |
| 721 |
<code class="option">--toggle-collect=<function> </code> |
| 722 |
</span> |
| 723 |
</dt> |
| 724 |
<dd><p>Toggle collection on entry/exit of <code class="option">function</code>.</p></dd> |
| 725 |
<dt> |
| 726 |
<a name="opt.collect-jumps"></a><span class="term"> |
| 727 |
<code class="option">--collect-jumps=<no|yes> [default: no] </code> |
| 728 |
</span> |
| 729 |
</dt> |
| 730 |
<dd><p>This specifies whether information for (conditional) jumps |
| 731 |
should be collected. As above, callgrind_annotate currently is not |
| 732 |
able to show you the data. You have to use KCachegrind to get jump |
| 733 |
arrows in the annotated code.</p></dd> |
| 734 |
<dt> |
| 735 |
<a name="opt.collect-systime"></a><span class="term"> |
| 736 |
<code class="option">--collect-systime=<no|yes|msec|usec|nsec> [default: no] </code> |
| 737 |
</span> |
| 738 |
</dt> |
| 739 |
<dd> |
| 740 |
<p>This specifies whether information for system call times |
| 741 |
should be collected.</p> |
| 742 |
<p>The value <code class="computeroutput">no</code> indicates to record |
| 743 |
no system call information.</p> |
| 744 |
<p>The other values indicate to record the number of system calls |
| 745 |
done (sysCount event) and the elapsed time (sysTime event) spent |
| 746 |
in system calls. |
| 747 |
The <code class="computeroutput">--collect-systime</code> value gives |
| 748 |
the unit used for sysTime : milli seconds, micro seconds or nano |
| 749 |
seconds. With the value <code class="computeroutput">nsec</code>, |
| 750 |
callgrind also records the cpu time spent during system calls |
| 751 |
(sysCpuTime).</p> |
| 752 |
<p>The value <code class="computeroutput">yes</code> is a synonym |
| 753 |
of <code class="computeroutput">msec</code>. |
| 754 |
The value <code class="computeroutput">nsec</code> is not supported |
| 755 |
on Darwin.</p> |
| 756 |
</dd> |
| 757 |
<dt> |
| 758 |
<a name="clopt.collect-bus"></a><span class="term"> |
| 759 |
<code class="option">--collect-bus=<no|yes> [default: no] </code> |
| 760 |
</span> |
| 761 |
</dt> |
| 762 |
<dd><p>This specifies whether the number of global bus events executed |
| 763 |
should be collected. The event type "Ge" is used for these events.</p></dd> |
| 764 |
</dl> |
| 765 |
</div> |
| 766 |
</div> |
| 767 |
<div class="sect2"> |
| 768 |
<div class="titlepage"><div><div><h3 class="title"> |
| 769 |
<a name="cl-manual.options.separation"></a>6.3.4. Cost entity separation options</h3></div></div></div> |
| 770 |
<p> |
| 771 |
These options specify how event counts should be attributed to execution |
| 772 |
contexts. |
| 773 |
For example, they specify whether the recursion level or the |
| 774 |
call chain leading to a function should be taken into account, |
| 775 |
and whether the thread ID should be considered. |
| 776 |
Also see <a class="xref" href="cl-manual.html#cl-manual.cycles" title="6.2.4. Avoiding cycles">Avoiding cycles</a>.</p> |
| 777 |
<div class="variablelist"> |
| 778 |
<a name="cmd-options.separation"></a><dl class="variablelist"> |
| 779 |
<dt> |
| 780 |
<a name="opt.separate-threads"></a><span class="term"> |
| 781 |
<code class="option">--separate-threads=<no|yes> [default: no] </code> |
| 782 |
</span> |
| 783 |
</dt> |
| 784 |
<dd><p>This option specifies whether profile data should be generated |
| 785 |
separately for every thread. If yes, the file names get "-threadID" |
| 786 |
appended.</p></dd> |
| 787 |
<dt> |
| 788 |
<a name="opt.separate-callers"></a><span class="term"> |
| 789 |
<code class="option">--separate-callers=<callers> [default: 0] </code> |
| 790 |
</span> |
| 791 |
</dt> |
| 792 |
<dd><p>Separate contexts by at most <callers> functions in the |
| 793 |
call chain. See <a class="xref" href="cl-manual.html#cl-manual.cycles" title="6.2.4. Avoiding cycles">Avoiding cycles</a>.</p></dd> |
| 794 |
<dt> |
| 795 |
<a name="opt.separate-callers-num"></a><span class="term"> |
| 796 |
<code class="option">--separate-callers<number>=<function> </code> |
| 797 |
</span> |
| 798 |
</dt> |
| 799 |
<dd><p>Separate <code class="option">number</code> callers for <code class="option">function</code>. |
| 800 |
See <a class="xref" href="cl-manual.html#cl-manual.cycles" title="6.2.4. Avoiding cycles">Avoiding cycles</a>.</p></dd> |
| 801 |
<dt> |
| 802 |
<a name="opt.separate-recs"></a><span class="term"> |
| 803 |
<code class="option">--separate-recs=<level> [default: 2] </code> |
| 804 |
</span> |
| 805 |
</dt> |
| 806 |
<dd><p>Separate function recursions by at most <code class="option">level</code> levels. |
| 807 |
See <a class="xref" href="cl-manual.html#cl-manual.cycles" title="6.2.4. Avoiding cycles">Avoiding cycles</a>.</p></dd> |
| 808 |
<dt> |
| 809 |
<a name="opt.separate-recs-num"></a><span class="term"> |
| 810 |
<code class="option">--separate-recs<number>=<function> </code> |
| 811 |
</span> |
| 812 |
</dt> |
| 813 |
<dd><p>Separate <code class="option">number</code> recursions for <code class="option">function</code>. |
| 814 |
See <a class="xref" href="cl-manual.html#cl-manual.cycles" title="6.2.4. Avoiding cycles">Avoiding cycles</a>.</p></dd> |
| 815 |
<dt> |
| 816 |
<a name="opt.skip-plt"></a><span class="term"> |
| 817 |
<code class="option">--skip-plt=<no|yes> [default: yes] </code> |
| 818 |
</span> |
| 819 |
</dt> |
| 820 |
<dd><p>Ignore calls to/from PLT sections.</p></dd> |
| 821 |
<dt> |
| 822 |
<a name="opt.skip-direct-rec"></a><span class="term"> |
| 823 |
<code class="option">--skip-direct-rec=<no|yes> [default: yes] </code> |
| 824 |
</span> |
| 825 |
</dt> |
| 826 |
<dd><p>Ignore direct recursions.</p></dd> |
| 827 |
<dt> |
| 828 |
<a name="opt.fn-skip"></a><span class="term"> |
| 829 |
<code class="option">--fn-skip=<function> </code> |
| 830 |
</span> |
| 831 |
</dt> |
| 832 |
<dd> |
| 833 |
<p>Ignore calls to/from a given function. E.g. if you have a |
| 834 |
call chain A > B > C, and you specify function B to be |
| 835 |
ignored, you will only see A > C.</p> |
| 836 |
<p>This is very convenient to skip functions handling callback |
| 837 |
behaviour. For example, with the signal/slot mechanism in the |
| 838 |
Qt graphics library, you only want |
| 839 |
to see the function emitting a signal to call the slots connected |
| 840 |
to that signal. First, determine the real call chain to see the |
| 841 |
functions needed to be skipped, then use this option.</p> |
| 842 |
</dd> |
| 843 |
</dl> |
| 844 |
</div> |
| 845 |
</div> |
| 846 |
<div class="sect2"> |
| 847 |
<div class="titlepage"><div><div><h3 class="title"> |
| 848 |
<a name="cl-manual.options.simulation"></a>6.3.5. Simulation options</h3></div></div></div> |
| 849 |
<div class="variablelist"> |
| 850 |
<a name="cl.opts.list.simulation"></a><dl class="variablelist"> |
| 851 |
<dt> |
| 852 |
<a name="clopt.cache-sim"></a><span class="term"> |
| 853 |
<code class="option">--cache-sim=<yes|no> [default: no] </code> |
| 854 |
</span> |
| 855 |
</dt> |
| 856 |
<dd><p>Specify if you want to do full cache simulation. By default, |
| 857 |
only instruction read accesses will be counted ("Ir"). |
| 858 |
With cache simulation, further event counters are enabled: |
| 859 |
Cache misses on instruction reads ("I1mr"/"ILmr"), |
| 860 |
data read accesses ("Dr") and related cache misses ("D1mr"/"DLmr"), |
| 861 |
data write accesses ("Dw") and related cache misses ("D1mw"/"DLmw"). |
| 862 |
For more information, see <a class="xref" href="cg-manual.html" title="5. Cachegrind: a high-precision tracing profiler">Cachegrind: a cache and branch-prediction profiler</a>. |
| 863 |
</p></dd> |
| 864 |
<dt> |
| 865 |
<a name="clopt.branch-sim"></a><span class="term"> |
| 866 |
<code class="option">--branch-sim=<yes|no> [default: no] </code> |
| 867 |
</span> |
| 868 |
</dt> |
| 869 |
<dd><p>Specify if you want to do branch prediction simulation. |
| 870 |
Further event counters are enabled: Number of executed conditional |
| 871 |
branches and related predictor misses ("Bc"/"Bcm"), executed indirect |
| 872 |
jumps and related misses of the jump address predictor ("Bi"/"Bim"). |
| 873 |
</p></dd> |
| 874 |
</dl> |
| 875 |
</div> |
| 876 |
</div> |
| 877 |
<div class="sect2"> |
| 878 |
<div class="titlepage"><div><div><h3 class="title"> |
| 879 |
<a name="cl-manual.options.cachesimulation"></a>6.3.6. Cache simulation options</h3></div></div></div> |
| 880 |
<div class="variablelist"> |
| 881 |
<a name="cl.opts.list.cachesimulation"></a><dl class="variablelist"> |
| 882 |
<dt> |
| 883 |
<a name="opt.simulate-wb"></a><span class="term"> |
| 884 |
<code class="option">--simulate-wb=<yes|no> [default: no] </code> |
| 885 |
</span> |
| 886 |
</dt> |
| 887 |
<dd><p>Specify whether write-back behavior should be simulated, allowing |
| 888 |
to distinguish LL caches misses with and without write backs. |
| 889 |
The cache model of Cachegrind/Callgrind does not specify write-through |
| 890 |
vs. write-back behavior, and this also is not relevant for the number |
| 891 |
of generated miss counts. However, with explicit write-back simulation |
| 892 |
it can be decided whether a miss triggers not only the loading of a new |
| 893 |
cache line, but also if a write back of a dirty cache line had to take |
| 894 |
place before. The new dirty miss events are ILdmr, DLdmr, and DLdmw, |
| 895 |
for misses because of instruction read, data read, and data write, |
| 896 |
respectively. As they produce two memory transactions, they should |
| 897 |
account for a doubled time estimation in relation to a normal miss. |
| 898 |
</p></dd> |
| 899 |
<dt> |
| 900 |
<a name="opt.simulate-hwpref"></a><span class="term"> |
| 901 |
<code class="option">--simulate-hwpref=<yes|no> [default: no] </code> |
| 902 |
</span> |
| 903 |
</dt> |
| 904 |
<dd><p>Specify whether simulation of a hardware prefetcher should be |
| 905 |
added which is able to detect stream access in the second level cache |
| 906 |
by comparing accesses to separate to each page. |
| 907 |
As the simulation can not decide about any timing issues of prefetching, |
| 908 |
it is assumed that any hardware prefetch triggered succeeds before a |
| 909 |
real access is done. Thus, this gives a best-case scenario by covering |
| 910 |
all possible stream accesses.</p></dd> |
| 911 |
<dt> |
| 912 |
<a name="opt.cacheuse"></a><span class="term"> |
| 913 |
<code class="option">--cacheuse=<yes|no> [default: no] </code> |
| 914 |
</span> |
| 915 |
</dt> |
| 916 |
<dd><p>Specify whether cache line use should be collected. For every |
| 917 |
cache line, from loading to it being evicted, the number of accesses |
| 918 |
as well as the number of actually used bytes is determined. This |
| 919 |
behavior is related to the code which triggered loading of the cache |
| 920 |
line. In contrast to miss counters, which shows the position where |
| 921 |
the symptoms of bad cache behavior (i.e. latencies) happens, the |
| 922 |
use counters try to pinpoint at the reason (i.e. the code with the |
| 923 |
bad access behavior). The new counters are defined in a way such |
| 924 |
that worse behavior results in higher cost. |
| 925 |
AcCost1 and AcCost2 are counters showing bad temporal locality |
| 926 |
for L1 and LL caches, respectively. This is done by summing up |
| 927 |
reciprocal values of the numbers of accesses of each cache line, |
| 928 |
multiplied by 1000 (as only integer costs are allowed). E.g. for |
| 929 |
a given source line with 5 read accesses, a value of 5000 AcCost |
| 930 |
means that for every access, a new cache line was loaded and directly |
| 931 |
evicted afterwards without further accesses. Similarly, SpLoss1/2 |
| 932 |
shows bad spatial locality for L1 and LL caches, respectively. It |
| 933 |
gives the <span class="emphasis"><em>spatial loss</em></span> count of bytes which |
| 934 |
were loaded into cache but never accessed. It pinpoints at code |
| 935 |
accessing data in a way such that cache space is wasted. This hints |
| 936 |
at bad layout of data structures in memory. Assuming a cache line |
| 937 |
size of 64 bytes and 100 L1 misses for a given source line, the |
| 938 |
loading of 6400 bytes into L1 was triggered. If SpLoss1 shows a |
| 939 |
value of 3200 for this line, this means that half of the loaded data was |
| 940 |
never used, or using a better data layout, only half of the cache |
| 941 |
space would have been needed. |
| 942 |
Please note that for cache line use counters, it currently is |
| 943 |
not possible to provide meaningful inclusive costs. Therefore, |
| 944 |
inclusive cost of these counters should be ignored. |
| 945 |
</p></dd> |
| 946 |
<dt> |
| 947 |
<a name="cl.opt.I1"></a><span class="term"> |
| 948 |
<code class="option">--I1=<size>,<associativity>,<line size> </code> |
| 949 |
</span> |
| 950 |
</dt> |
| 951 |
<dd><p>Specify the size, associativity and line size of the level 1 |
| 952 |
instruction cache. </p></dd> |
| 953 |
<dt> |
| 954 |
<a name="cl.opt.D1"></a><span class="term"> |
| 955 |
<code class="option">--D1=<size>,<associativity>,<line size> </code> |
| 956 |
</span> |
| 957 |
</dt> |
| 958 |
<dd><p>Specify the size, associativity and line size of the level 1 |
| 959 |
data cache.</p></dd> |
| 960 |
<dt> |
| 961 |
<a name="cl.opt.LL"></a><span class="term"> |
| 962 |
<code class="option">--LL=<size>,<associativity>,<line size> </code> |
| 963 |
</span> |
| 964 |
</dt> |
| 965 |
<dd><p>Specify the size, associativity and line size of the last-level |
| 966 |
cache.</p></dd> |
| 967 |
</dl> |
| 968 |
</div> |
| 969 |
</div> |
| 970 |
</div> |
| 971 |
<div class="sect1"> |
| 972 |
<div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
| 973 |
<a name="cl-manual.monitor-commands"></a>6.4. Callgrind Monitor Commands</h2></div></div></div> |
| 974 |
<p>The Callgrind tool provides monitor commands handled by the Valgrind |
| 975 |
gdbserver (see <a class="xref" href="manual-core-adv.html#manual-core-adv.gdbserver-commandhandling" title="3.2.5. Monitor command handling by the Valgrind gdbserver">Monitor command handling by the Valgrind gdbserver</a>). |
| 976 |
Valgrind python code provides GDB front end commands giving an easier usage of |
| 977 |
the callgrind monitor commands (see |
| 978 |
<a class="xref" href="manual-core-adv.html#manual-core-adv.gdbserver-gdbmonitorfrontend" title="3.2.6. GDB front end commands for Valgrind gdbserver monitor commands">GDB front end commands for Valgrind gdbserver monitor commands</a>). To launch a |
| 979 |
callgrind monitor command via its GDB front end command, instead of prefixing |
| 980 |
the command with "monitor", you must use the GDB <code class="varname">callgrind</code> |
| 981 |
command (or the shorter aliases <code class="varname">cg</code>). Using the callgrind GDB |
| 982 |
front end command provide a more flexible usage, such as auto-completion of the |
| 983 |
command by GDB. In GDB, you can use <code class="varname">help callgrind</code> to get |
| 984 |
help about the callgrind front end monitor commands and you can |
| 985 |
use <code class="varname">apropos callgrind</code> to get all the commands mentionning the |
| 986 |
word "callgrind" in their name or on-line help. |
| 987 |
</p> |
| 988 |
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| 989 |
<li class="listitem"><p><code class="varname">dump [<dump_hint>]</code> requests to dump the |
| 990 |
profile data. </p></li> |
| 991 |
<li class="listitem"><p><code class="varname">zero</code> requests to zero the profile data |
| 992 |
counters. </p></li> |
| 993 |
<li class="listitem"><p><code class="varname">instrumentation [on|off]</code> requests to set |
| 994 |
(if parameter on/off is given) or get the current instrumentation state. |
| 995 |
</p></li> |
| 996 |
<li class="listitem"><p><code class="varname">status</code> requests to print out some status |
| 997 |
information.</p></li> |
| 998 |
</ul></div> |
| 999 |
</div> |
| 1000 |
<div class="sect1"> |
| 1001 |
<div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
| 1002 |
<a name="cl-manual.clientrequests"></a>6.5. Callgrind specific client requests</h2></div></div></div> |
| 1003 |
<p>Callgrind provides the following specific client requests in |
| 1004 |
<code class="filename">callgrind.h</code>. See that file for the exact details of |
| 1005 |
their arguments.</p> |
| 1006 |
<div class="variablelist"> |
| 1007 |
<a name="cl.clientrequests.list"></a><dl class="variablelist"> |
| 1008 |
<dt> |
| 1009 |
<a name="cr.dump-stats"></a><span class="term"> |
| 1010 |
<code class="computeroutput">CALLGRIND_DUMP_STATS</code> |
| 1011 |
</span> |
| 1012 |
</dt> |
| 1013 |
<dd><p>Force generation of a profile dump at specified position |
| 1014 |
in code, for the current thread only. Written counters will be reset |
| 1015 |
to zero.</p></dd> |
| 1016 |
<dt> |
| 1017 |
<a name="cr.dump-stats-at"></a><span class="term"> |
| 1018 |
<code class="computeroutput">CALLGRIND_DUMP_STATS_AT(string)</code> |
| 1019 |
</span> |
| 1020 |
</dt> |
| 1021 |
<dd><p>Same as <code class="computeroutput">CALLGRIND_DUMP_STATS</code>, |
| 1022 |
but allows to specify a string to be able to distinguish profile |
| 1023 |
dumps.</p></dd> |
| 1024 |
<dt> |
| 1025 |
<a name="cr.zero-stats"></a><span class="term"> |
| 1026 |
<code class="computeroutput">CALLGRIND_ZERO_STATS</code> |
| 1027 |
</span> |
| 1028 |
</dt> |
| 1029 |
<dd><p>Reset the profile counters for the current thread to zero.</p></dd> |
| 1030 |
<dt> |
| 1031 |
<a name="cr.toggle-collect"></a><span class="term"> |
| 1032 |
<code class="computeroutput">CALLGRIND_TOGGLE_COLLECT</code> |
| 1033 |
</span> |
| 1034 |
</dt> |
| 1035 |
<dd><p>Toggle the collection state. This allows to ignore events |
| 1036 |
with regard to profile counters. See also options |
| 1037 |
<code class="option"><a class="link" href="cl-manual.html#opt.collect-atstart">--collect-atstart</a></code> |
| 1038 |
and |
| 1039 |
<code class="option"><a class="link" href="cl-manual.html#opt.toggle-collect">--toggle-collect</a></code>.</p></dd> |
| 1040 |
<dt> |
| 1041 |
<a name="cr.start-instr"></a><span class="term"> |
| 1042 |
<code class="computeroutput">CALLGRIND_START_INSTRUMENTATION</code> |
| 1043 |
</span> |
| 1044 |
</dt> |
| 1045 |
<dd><p>Start full Callgrind instrumentation if not already enabled. |
| 1046 |
When cache simulation is done, this will flush the simulated cache |
| 1047 |
and lead to an artificial cache warmup phase afterwards with |
| 1048 |
cache misses which would not have happened in reality. See also |
| 1049 |
option |
| 1050 |
<code class="option"><a class="link" href="cl-manual.html#opt.instr-atstart">--instr-atstart</a></code>. |
| 1051 |
</p></dd> |
| 1052 |
<dt> |
| 1053 |
<a name="cr.stop-instr"></a><span class="term"> |
| 1054 |
<code class="computeroutput">CALLGRIND_STOP_INSTRUMENTATION</code> |
| 1055 |
</span> |
| 1056 |
</dt> |
| 1057 |
<dd><p>Stop full Callgrind instrumentation if not already disabled. |
| 1058 |
This flushes Valgrinds translation cache, and does no additional |
| 1059 |
instrumentation afterwards: it effectivly will run at the same |
| 1060 |
speed as Nulgrind, i.e. at minimal slowdown. Use this to |
| 1061 |
speed up the Callgrind run for uninteresting code parts. Use |
| 1062 |
<code class="computeroutput"><a class="link" href="cl-manual.html#cr.start-instr">CALLGRIND_START_INSTRUMENTATION</a></code> |
| 1063 |
to enable instrumentation again. See also option |
| 1064 |
<code class="option"><a class="link" href="cl-manual.html#opt.instr-atstart">--instr-atstart</a></code>. |
| 1065 |
</p></dd> |
| 1066 |
</dl> |
| 1067 |
</div> |
| 1068 |
</div> |
| 1069 |
<div class="sect1"> |
| 1070 |
<div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
| 1071 |
<a name="cl-manual.callgrind_annotate-options"></a>6.6. callgrind_annotate Command-line Options</h2></div></div></div> |
| 1072 |
<div class="variablelist"> |
| 1073 |
<a name="callgrind_annotate.opts.list"></a><dl class="variablelist"> |
| 1074 |
<dt><span class="term"><code class="option">-h --help</code></span></dt> |
| 1075 |
<dd><p>Show summary of options.</p></dd> |
| 1076 |
<dt><span class="term"><code class="option">--version</code></span></dt> |
| 1077 |
<dd><p>Show version of callgrind_annotate.</p></dd> |
| 1078 |
<dt><span class="term"> |
| 1079 |
<code class="option">--show=A,B,C [default: all]</code> |
| 1080 |
</span></dt> |
| 1081 |
<dd><p>Only show figures for events A,B,C.</p></dd> |
| 1082 |
<dt><span class="term"> |
| 1083 |
<code class="option">--threshold=<0--100> [default: 99%] </code> |
| 1084 |
</span></dt> |
| 1085 |
<dd> |
| 1086 |
<p>Percentage of counts (of primary sort event) we are |
| 1087 |
interested in.</p> |
| 1088 |
<p>callgrind_annotate stops printing functions when the sum |
| 1089 |
of the cost percentage of the printed functions is bigger or equal |
| 1090 |
to the given threshold percentage.</p> |
| 1091 |
</dd> |
| 1092 |
<dt><span class="term"> |
| 1093 |
<code class="option">--sort=A,B,C</code> |
| 1094 |
</span></dt> |
| 1095 |
<dd> |
| 1096 |
<p>Sort columns by events A,B,C [event column order].</p> |
| 1097 |
<p>Optionally, each event is followed by a : and a threshold, |
| 1098 |
to specify different thresholds depending on the event.</p> |
| 1099 |
<p>callgrind_annotate stops printing functions when the sum |
| 1100 |
of the cost percentage of the printed functions for all the events |
| 1101 |
is bigger or equal to the given event threshold percentages.</p> |
| 1102 |
<p>When one or more thresholds are given via this option, |
| 1103 |
the value of <code class="option">--threshold</code> is ignored.</p> |
| 1104 |
</dd> |
| 1105 |
<dt><span class="term"> |
| 1106 |
<code class="option">--show-percs=<no|yes> [default: no] </code> |
| 1107 |
</span></dt> |
| 1108 |
<dd><p>When enabled, a percentage is printed next to all event counts. |
| 1109 |
This helps gauge the relative importance of each function and line. |
| 1110 |
</p></dd> |
| 1111 |
<dt><span class="term"> |
| 1112 |
<code class="option">--auto=<yes|no> [default: yes] </code> |
| 1113 |
</span></dt> |
| 1114 |
<dd><p>Annotate all source files containing functions that helped |
| 1115 |
reach the event count threshold.</p></dd> |
| 1116 |
<dt><span class="term"> |
| 1117 |
<code class="option">--context=N [default: 8] </code> |
| 1118 |
</span></dt> |
| 1119 |
<dd><p>Print N lines of context before and after annotated |
| 1120 |
lines.</p></dd> |
| 1121 |
<dt><span class="term"> |
| 1122 |
<code class="option">--inclusive=<yes|no> [default: no] </code> |
| 1123 |
</span></dt> |
| 1124 |
<dd><p>Add subroutine costs to functions calls.</p></dd> |
| 1125 |
<dt><span class="term"> |
| 1126 |
<code class="option">--tree=<none|caller|calling|both> [default: none] </code> |
| 1127 |
</span></dt> |
| 1128 |
<dd><p>Print for each function their callers, the called functions |
| 1129 |
or both.</p></dd> |
| 1130 |
<dt><span class="term"> |
| 1131 |
<code class="option">-I, --include=<dir> </code> |
| 1132 |
</span></dt> |
| 1133 |
<dd><p>Add <code class="option">dir</code> to the list of directories to search |
| 1134 |
for source files.</p></dd> |
| 1135 |
</dl> |
| 1136 |
</div> |
| 1137 |
</div> |
| 1138 |
<div class="sect1"> |
| 1139 |
<div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
| 1140 |
<a name="cl-manual.callgrind_control-options"></a>6.7. callgrind_control Command-line Options</h2></div></div></div> |
| 1141 |
<p>By default, callgrind_control acts on all programs run by the |
| 1142 |
current user under Callgrind. It is possible to limit the actions to |
| 1143 |
specified Callgrind runs by providing a list of pids or program names as |
| 1144 |
argument. The default action is to give some brief information about the |
| 1145 |
applications being run under Callgrind.</p> |
| 1146 |
<div class="variablelist"> |
| 1147 |
<a name="callgrind_control.opts.list"></a><dl class="variablelist"> |
| 1148 |
<dt><span class="term"><code class="option">-h --help</code></span></dt> |
| 1149 |
<dd><p>Show a short description, usage, and summary of options.</p></dd> |
| 1150 |
<dt><span class="term"><code class="option">--version</code></span></dt> |
| 1151 |
<dd><p>Show version of callgrind_control.</p></dd> |
| 1152 |
<dt><span class="term"><code class="option">-l --long</code></span></dt> |
| 1153 |
<dd><p>Show also the working directory, in addition to the brief |
| 1154 |
information given by default. |
| 1155 |
</p></dd> |
| 1156 |
<dt><span class="term"><code class="option">-s --stat</code></span></dt> |
| 1157 |
<dd><p>Show statistics information about active Callgrind runs.</p></dd> |
| 1158 |
<dt><span class="term"><code class="option">-b --back</code></span></dt> |
| 1159 |
<dd><p>Show stack/back traces of each thread in active Callgrind runs. For |
| 1160 |
each active function in the stack trace, also the number of invocations |
| 1161 |
since program start (or last dump) is shown. This option can be |
| 1162 |
combined with -e to show inclusive cost of active functions.</p></dd> |
| 1163 |
<dt><span class="term"><code class="option">-e [A,B,...] </code> (default: all)</span></dt> |
| 1164 |
<dd><p>Show the current per-thread, exclusive cost values of event |
| 1165 |
counters. If no explicit event names are given, figures for all event |
| 1166 |
types which are collected in the given Callgrind run are |
| 1167 |
shown. Otherwise, only figures for event types A, B, ... are shown. If |
| 1168 |
this option is combined with -b, inclusive cost for the functions of |
| 1169 |
each active stack frame is provided, too. |
| 1170 |
</p></dd> |
| 1171 |
<dt><span class="term"><code class="option">--dump[=<desc>] </code> (default: no description)</span></dt> |
| 1172 |
<dd><p>Request the dumping of profile information. Optionally, a |
| 1173 |
description can be specified which is written into the dump as part of |
| 1174 |
the information giving the reason which triggered the dump action. This |
| 1175 |
can be used to distinguish multiple dumps.</p></dd> |
| 1176 |
<dt><span class="term"><code class="option">-z --zero</code></span></dt> |
| 1177 |
<dd><p>Zero all event counters.</p></dd> |
| 1178 |
<dt><span class="term"><code class="option">-k --kill</code></span></dt> |
| 1179 |
<dd><p>Force a Callgrind run to be terminated.</p></dd> |
| 1180 |
<dt><span class="term"><code class="option">--instr=<on|off></code></span></dt> |
| 1181 |
<dd><p>Switch instrumentation mode on or off. If a Callgrind run has |
| 1182 |
instrumentation disabled, no simulation is done and no events are |
| 1183 |
counted. This is useful to skip uninteresting program parts, as there |
| 1184 |
is much less slowdown (same as with the Valgrind tool "none"). See also |
| 1185 |
the Callgrind option <code class="option">--instr-atstart</code>.</p></dd> |
| 1186 |
<dt><span class="term"><code class="option">--vgdb-prefix=<prefix></code></span></dt> |
| 1187 |
<dd><p>Specify the vgdb prefix to use by callgrind_control. |
| 1188 |
callgrind_control internally uses vgdb to find and control the active |
| 1189 |
Callgrind runs. If the <code class="option">--vgdb-prefix</code> option was used |
| 1190 |
for launching valgrind, then the same option must be given to |
| 1191 |
callgrind_control.</p></dd> |
| 1192 |
</dl> |
| 1193 |
</div> |
| 1194 |
</div> |
| 1195 |
</div> |
| 1196 |
<div> |
| 1197 |
<br><table class="nav" width="100%" cellspacing="3" cellpadding="2" border="0" summary="Navigation footer"> |
| 1198 |
<tr> |
| 1199 |
<td rowspan="2" width="40%" align="left"> |
| 1200 |
<a accesskey="p" href="cg-manual.html"><< 5. Cachegrind: a high-precision tracing profiler</a> </td> |
| 1201 |
<td width="20%" align="center"><a accesskey="u" href="manual.html">Up</a></td> |
| 1202 |
<td rowspan="2" width="40%" align="right"> <a accesskey="n" href="hg-manual.html">7. Helgrind: a thread error detector >></a> |
| 1203 |
</td> |
| 1204 |
</tr> |
| 1205 |
<tr><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td></tr> |
| 1206 |
</table> |
| 1207 |
</div> |
| 1208 |
</body> |
| 1209 |
</html> |