Home | History | Annotate | Download | only in html
      1 <html>
      2 <head>
      3 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
      4 <title>3.Callgrind Format Specification</title>
      5 <link rel="stylesheet" href="vg_basic.css" type="text/css">
      6 <meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
      7 <link rel="home" href="index.html" title="Valgrind Documentation">
      8 <link rel="up" href="tech-docs.html" title="Valgrind Technical Documentation">
      9 <link rel="prev" href="manual-writing-tools.html" title="2.Writing a New Valgrind Tool">
     10 <link rel="next" href="dist.html" title="Valgrind Distribution Documents">
     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="manual-writing-tools.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="tech-docs.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 Technical Documentation</th>
     18 <td width="22px" align="center" valign="middle"><a accesskey="n" href="dist.html"><img src="images/next.png" width="18" height="21" border="0" alt="Next"></a></td>
     19 </tr></table></div>
     20 <div class="chapter" title="3.Callgrind Format Specification">
     21 <div class="titlepage"><div><div><h2 class="title">
     22 <a name="cl-format"></a>3.Callgrind Format Specification</h2></div></div></div>
     23 <div class="toc">
     24 <p><b>Table of Contents</b></p>
     25 <dl>
     26 <dt><span class="sect1"><a href="cl-format.html#cl-format.overview">3.1. Overview</a></span></dt>
     27 <dd><dl>
     28 <dt><span class="sect2"><a href="cl-format.html#cl-format.overview.basics">3.1.1. Basic Structure</a></span></dt>
     29 <dt><span class="sect2"><a href="cl-format.html#cl-format.overview.example1">3.1.2. Simple Example</a></span></dt>
     30 <dt><span class="sect2"><a href="cl-format.html#cl-format.overview.associations">3.1.3. Associations</a></span></dt>
     31 <dt><span class="sect2"><a href="cl-format.html#cl-format.overview.example2">3.1.4. Extended Example</a></span></dt>
     32 <dt><span class="sect2"><a href="cl-format.html#cl-format.overview.compression1">3.1.5. Name Compression</a></span></dt>
     33 <dt><span class="sect2"><a href="cl-format.html#cl-format.overview.compression2">3.1.6. Subposition Compression</a></span></dt>
     34 <dt><span class="sect2"><a href="cl-format.html#cl-format.overview.misc">3.1.7. Miscellaneous</a></span></dt>
     35 </dl></dd>
     36 <dt><span class="sect1"><a href="cl-format.html#cl-format.reference">3.2. Reference</a></span></dt>
     37 <dd><dl>
     38 <dt><span class="sect2"><a href="cl-format.html#cl-format.reference.grammar">3.2.1. Grammar</a></span></dt>
     39 <dt><span class="sect2"><a href="cl-format.html#cl-format.reference.header">3.2.2. Description of Header Lines</a></span></dt>
     40 <dt><span class="sect2"><a href="cl-format.html#cl-format.reference.body">3.2.3. Description of Body Lines</a></span></dt>
     41 </dl></dd>
     42 </dl>
     43 </div>
     44 <p>This chapter describes the Callgrind Profile Format, Version 1.</p>
     45 <p>A synonymous name is "Calltree Profile Format". These names actually mean
     46 the same since Callgrind was previously named Calltree.</p>
     47 <p>The format description is meant for the user to be able to understand the
     48 file contents; but more important, it is given for authors of measurement or
     49 visualization tools to be able to write and read this format.</p>
     50 <div class="sect1" title="3.1.Overview">
     51 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
     52 <a name="cl-format.overview"></a>3.1.Overview</h2></div></div></div>
     53 <p>The profile data format is ASCII based.
     54 It is written by Callgrind, and it is upwards compatible
     55 to the format used by Cachegrind (ie. Cachegrind uses a subset). It can
     56 be read by callgrind_annotate and KCachegrind.</p>
     57 <p>This chapter gives on overview of format features and examples.
     58 For detailed syntax, look at the format reference.</p>
     59 <div class="sect2" title="3.1.1.Basic Structure">
     60 <div class="titlepage"><div><div><h3 class="title">
     61 <a name="cl-format.overview.basics"></a>3.1.1.Basic Structure</h3></div></div></div>
     62 <p>Each file has a header part of an arbitrary number of lines of the
     63 format "key: value". The lines with key "positions" and "events" define
     64 the meaning of cost lines in the second part of the file: the value of
     65 "positions" is a list of subpositions, and the value of "events" is a list
     66 of event type names. Cost lines consist of subpositions followed by 64-bit
     67 counters for the events, in the order specified by the "positions" and "events"
     68 header line.</p>
     69 <p>The "events" header line is always required in contrast to the optional
     70 line for "positions", which defaults to "line", i.e. a line number of some
     71 source file. In addition, the second part of the file contains position
     72 specifications of the form "spec=name". "spec" can be e.g. "fn" for a
     73 function name or "fl" for a file name. Cost lines are always related to
     74 the function/file specifications given directly before.</p>
     75 </div>
     76 <div class="sect2" title="3.1.2.Simple Example">
     77 <div class="titlepage"><div><div><h3 class="title">
     78 <a name="cl-format.overview.example1"></a>3.1.2.Simple Example</h3></div></div></div>
     79 <p>The event names in the following example are quite arbitrary, and are not
     80 related to event names used by Callgrind. Especially, cycle counts matching
     81 real processors probably will never be generated by any Valgrind tools, as these
     82 are bound to simulations of simple machine models for acceptable slowdown.
     83 However, any profiling tool could use the format described in this chapter.</p>
     84 <p>
     85 </p>
     86 <pre class="screen">events: Cycles Instructions Flops
     87 fl=file.f
     88 fn=main
     89 15 90 14 2
     90 16 20 12</pre>
     91 <p>The above example gives profile information for event types "Cycles",
     92 "Instructions", and "Flops". Thus, cost lines give the number of CPU cycles
     93 passed by, number of executed instructions, and number of floating point
     94 operations executed while running code corresponding to some source
     95 position. As there is no line specifying the value of "positions", it defaults
     96 to "line", which means that the first number of a cost line is always a line
     97 number.</p>
     98 <p>Thus, the first cost line specifies that in line 15 of source file
     99 <code class="filename">file.f</code> there is code belonging to function
    100 <code class="function">main</code>. While running, 90 CPU cycles passed by, and 2 of
    101 the 14 instructions executed were floating point operations. Similarly, the
    102 next line specifies that there were 12 instructions executed in the context
    103 of function <code class="function">main</code> which can be related to line 16 in
    104 file <code class="filename">file.f</code>, taking 20 CPU cycles. If a cost line
    105 specifies less event counts than given in the "events" line, the rest is
    106 assumed to be zero.  I.e. there was no floating point instruction executed
    107 relating to line 16.</p>
    108 <p>Note that regular cost lines always give self (also called exclusive)
    109 cost of code at a given position. If you specify multiple cost lines for the
    110 same position, these will be summed up. On the other hand, in the example above
    111 there is no specification of how many times function
    112 <code class="function">main</code> actually was
    113 called: profile data only contains sums.</p>
    114 </div>
    115 <div class="sect2" title="3.1.3.Associations">
    116 <div class="titlepage"><div><div><h3 class="title">
    117 <a name="cl-format.overview.associations"></a>3.1.3.Associations</h3></div></div></div>
    118 <p>The most important extension to the original format of Cachegrind is the
    119 ability to specify call relationship among functions. More generally, you
    120 specify associations among positions. For this, the second part of the
    121 file also can contain association specifications. These look similar to
    122 position specifications, but consist of 2 lines. For calls, the format
    123 looks like 
    124 </p>
    125 <pre class="screen">
    126  calls=(Call Count) (Destination position)
    127  (Source position) (Inclusive cost of call)
    128 </pre>
    129 <p>The destination only specifies subpositions like line number. Therefore,
    130 to be able to specify a call to another function in another source file, you
    131 have to precede the above lines with a "cfn=" specification for the name of the
    132 called function, and a "cfl=" specification if the function is in another
    133 source file. The 2nd line looks like a regular cost line with the difference
    134 that inclusive cost spent inside of the function call has to be specified.</p>
    135 <p>Other associations which or for example (conditional) jumps. See the
    136 reference below for details.</p>
    137 </div>
    138 <div class="sect2" title="3.1.4.Extended Example">
    139 <div class="titlepage"><div><div><h3 class="title">
    140 <a name="cl-format.overview.example2"></a>3.1.4.Extended Example</h3></div></div></div>
    141 <p>The following example shows 3 functions, <code class="function">main</code>,
    142 <code class="function">func1</code>, and <code class="function">func2</code>. Function
    143 <code class="function">main</code> calls <code class="function">func1</code> once and
    144 <code class="function">func2</code> 3 times. <code class="function">func1</code> calls
    145 <code class="function">func2</code> 2 times.
    146 </p>
    147 <pre class="screen">events: Instructions
    148 
    149 fl=file1.c
    150 fn=main
    151 16 20
    152 cfn=func1
    153 calls=1 50
    154 16 400
    155 cfl=file2.c
    156 cfn=func2
    157 calls=3 20
    158 16 400
    159 
    160 fn=func1
    161 51 100
    162 cfl=file2.c
    163 cfn=func2
    164 calls=2 20
    165 51 300
    166 
    167 fl=file2.c
    168 fn=func2
    169 20 700</pre>
    170 <p>One can see that in <code class="function">main</code> only code from line 16
    171 is executed where also the other functions are called. Inclusive cost of
    172 <code class="function">main</code> is 820, which is the sum of self cost 20 and costs
    173 spent in the calls: 400 for the single call to <code class="function">func1</code>
    174 and 400 as sum for the three calls to <code class="function">func2</code>.</p>
    175 <p>Function <code class="function">func1</code> is located in
    176 <code class="filename">file1.c</code>, the same as <code class="function">main</code>.
    177 Therefore, a "cfl=" specification for the call to <code class="function">func1</code>
    178 is not needed. The function <code class="function">func1</code> only consists of code
    179 at line 51 of <code class="filename">file1.c</code>, where <code class="function">func2</code>
    180 is called.</p>
    181 </div>
    182 <div class="sect2" title="3.1.5.Name Compression">
    183 <div class="titlepage"><div><div><h3 class="title">
    184 <a name="cl-format.overview.compression1"></a>3.1.5.Name Compression</h3></div></div></div>
    185 <p>With the introduction of association specifications like calls it is
    186 needed to specify the same function or same file name multiple times. As
    187 absolute filenames or symbol names in C++ can be quite long, it is advantageous
    188 to be able to specify integer IDs for position specifications.
    189 Here, the term "position" corresponds to a file name (source or object file)
    190 or function name.</p>
    191 <p>To support name compression, a position specification can be not only of
    192 the format "spec=name", but also "spec=(ID) name" to specify a mapping of an
    193 integer ID to a name, and "spec=(ID)" to reference a previously defined ID
    194 mapping. There is a separate ID mapping for each position specification,
    195 i.e. you can use ID 1 for both a file name and a symbol name.</p>
    196 <p>With string compression, the example from 1.4 looks like this:
    197 </p>
    198 <pre class="screen">events: Instructions
    199 
    200 fl=(1) file1.c
    201 fn=(1) main
    202 16 20
    203 cfn=(2) func1
    204 calls=1 50
    205 16 400
    206 cfl=(2) file2.c
    207 cfn=(3) func2
    208 calls=3 20
    209 16 400
    210 
    211 fn=(2)
    212 51 100
    213 cfl=(2)
    214 cfn=(3)
    215 calls=2 20
    216 51 300
    217 
    218 fl=(2)
    219 fn=(3)
    220 20 700</pre>
    221 <p>As position specifications carry no information themselves, but only change
    222 the meaning of subsequent cost lines or associations, they can appear
    223 everywhere in the file without any negative consequence. Especially, you can
    224 define name compression mappings directly after the header, and before any cost
    225 lines. Thus, the above example can also be written as
    226 </p>
    227 <pre class="screen">events: Instructions
    228 
    229 # define file ID mapping
    230 fl=(1) file1.c
    231 fl=(2) file2.c
    232 # define function ID mapping
    233 fn=(1) main
    234 fn=(2) func1
    235 fn=(3) func2
    236 
    237 fl=(1)
    238 fn=(1)
    239 16 20
    240 ...</pre>
    241 </div>
    242 <div class="sect2" title="3.1.6.Subposition Compression">
    243 <div class="titlepage"><div><div><h3 class="title">
    244 <a name="cl-format.overview.compression2"></a>3.1.6.Subposition Compression</h3></div></div></div>
    245 <p>If a Callgrind data file should hold costs for each assembler instruction
    246 of a program, you specify subposition "instr" in the "positions:" header line,
    247 and each cost line has to include the address of some instruction. Addresses
    248 are allowed to have a size of 64 bits to support 64-bit architectures. Thus,
    249 repeating similar, long addresses for almost every line in the data file can
    250 enlarge the file size quite significantly, and
    251 motivates for subposition compression: instead of every cost line starting with
    252 a 16 character long address, one is allowed to specify relative addresses.
    253 This relative specification is not only allowed for instruction addresses, but
    254 also for line numbers; both addresses and line numbers are called "subpositions".</p>
    255 <p>A relative subposition always is based on the corresponding subposition
    256 of the last cost line, and starts with a "+" to specify a positive difference,
    257 a "-" to specify a negative difference, or consists of "*" to specify the same
    258 subposition. Because absolute subpositions always are positive (ie. never
    259 prefixed by "-"), any relative specification is non-ambiguous; additionally,
    260 absolute and relative subposition specifications can be mixed freely.
    261 Assume the following example (subpositions can always be specified
    262 as hexadecimal numbers, beginning with "0x"):
    263 </p>
    264 <pre class="screen">positions: instr line
    265 events: ticks
    266 
    267 fn=func
    268 0x80001234 90 1
    269 0x80001237 90 5
    270 0x80001238 91 6</pre>
    271 <p>With subposition compression, this looks like
    272 </p>
    273 <pre class="screen">positions: instr line
    274 events: ticks
    275 
    276 fn=func
    277 0x80001234 90 1
    278 +3 * 5
    279 +1 +1 6</pre>
    280 <p>Remark: For assembler annotation to work, instruction addresses have to
    281 be corrected to correspond to addresses found in the original binary. I.e. for
    282 relocatable shared objects, often a load offset has to be subtracted.</p>
    283 </div>
    284 <div class="sect2" title="3.1.7.Miscellaneous">
    285 <div class="titlepage"><div><div><h3 class="title">
    286 <a name="cl-format.overview.misc"></a>3.1.7.Miscellaneous</h3></div></div></div>
    287 <div class="sect3" title="3.1.7.1.Cost Summary Information">
    288 <div class="titlepage"><div><div><h4 class="title">
    289 <a name="cl-format.overview.misc.summary"></a>3.1.7.1.Cost Summary Information</h4></div></div></div>
    290 <p>For the visualization to be able to show cost percentage, a sum of the
    291 cost of the full run has to be known. Usually, it is assumed that this is the
    292 sum of all cost lines in a file. But sometimes, this is not correct. Thus, you
    293 can specify a "summary:" line in the header giving the full cost for the
    294 profile run. This has another effect: a import filter can show a progress bar
    295 while loading a large data file if he knows to cost sum in advance.</p>
    296 </div>
    297 <div class="sect3" title="3.1.7.2.Long Names for Event Types and inherited Types">
    298 <div class="titlepage"><div><div><h4 class="title">
    299 <a name="cl-format.overview.misc.events"></a>3.1.7.2.Long Names for Event Types and inherited Types</h4></div></div></div>
    300 <p>Event types for cost lines are specified in the "events:" line with an
    301 abbreviated name. For visualization, it makes sense to be able to specify some
    302 longer, more descriptive name. For an event type "Ir" which means "Instruction
    303 Fetches", this can be specified the header line
    304 </p>
    305 <pre class="screen">event: Ir : Instruction Fetches
    306 events: Ir Dr</pre>
    307 <p>In this example, "Dr" itself has no long name associated. The order of
    308 "event:" lines and the "events:" line is of no importance. Additionally,
    309 inherited event types can be introduced for which no raw data is available, but
    310 which are calculated from given types. Suppose the last example, you could add
    311 </p>
    312 <pre class="screen">event: Sum = Ir + Dr</pre>
    313 <p>
    314 to specify an additional event type "Sum", which is calculated by adding costs
    315 for "Ir and "Dr".</p>
    316 </div>
    317 </div>
    318 </div>
    319 <div class="sect1" title="3.2.Reference">
    320 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
    321 <a name="cl-format.reference"></a>3.2.Reference</h2></div></div></div>
    322 <div class="sect2" title="3.2.1.Grammar">
    323 <div class="titlepage"><div><div><h3 class="title">
    324 <a name="cl-format.reference.grammar"></a>3.2.1.Grammar</h3></div></div></div>
    325 <p>
    326 </p>
    327 <pre class="screen">ProfileDataFile := FormatVersion? Creator? PartData*</pre>
    328 <p>
    329 </p>
    330 <pre class="screen">FormatVersion := "version:" Space* Number "\n"</pre>
    331 <p>
    332 </p>
    333 <pre class="screen">Creator := "creator:" NoNewLineChar* "\n"</pre>
    334 <p>
    335 </p>
    336 <pre class="screen">PartData := (HeaderLine "\n")+ (BodyLine "\n")+</pre>
    337 <p>
    338 </p>
    339 <pre class="screen">HeaderLine := (empty line)
    340   | ('#' NoNewLineChar*)
    341   | PartDetail
    342   | Description
    343   | EventSpecification
    344   | CostLineDef</pre>
    345 <p>
    346 </p>
    347 <pre class="screen">PartDetail := TargetCommand | TargetID</pre>
    348 <p>
    349 </p>
    350 <pre class="screen">TargetCommand := "cmd:" Space* NoNewLineChar*</pre>
    351 <p>
    352 </p>
    353 <pre class="screen">TargetID := ("pid"|"thread"|"part") ":" Space* Number</pre>
    354 <p>
    355 </p>
    356 <pre class="screen">Description := "desc:" Space* Name Space* ":" NoNewLineChar*</pre>
    357 <p>
    358 </p>
    359 <pre class="screen">EventSpecification := "event:" Space* Name InheritedDef? LongNameDef?</pre>
    360 <p>
    361 </p>
    362 <pre class="screen">InheritedDef := "=" InheritedExpr</pre>
    363 <p>
    364 </p>
    365 <pre class="screen">InheritedExpr := Name
    366   | Number Space* ("*" Space*)? Name
    367   | InheritedExpr Space* "+" Space* InheritedExpr</pre>
    368 <p>
    369 </p>
    370 <pre class="screen">LongNameDef := ":" NoNewLineChar*</pre>
    371 <p>
    372 </p>
    373 <pre class="screen">CostLineDef := "events:" Space* Name (Space+ Name)*
    374   | "positions:" "instr"? (Space+ "line")?</pre>
    375 <p>
    376 </p>
    377 <pre class="screen">BodyLine := (empty line)
    378   | ('#' NoNewLineChar*)
    379   | CostLine
    380   | PositionSpecification
    381   | AssociationSpecification</pre>
    382 <p>
    383 </p>
    384 <pre class="screen">CostLine := SubPositionList Costs?</pre>
    385 <p>
    386 </p>
    387 <pre class="screen">SubPositionList := (SubPosition+ Space+)+</pre>
    388 <p>
    389 </p>
    390 <pre class="screen">SubPosition := Number | "+" Number | "-" Number | "*"</pre>
    391 <p>
    392 </p>
    393 <pre class="screen">Costs := (Number Space+)+</pre>
    394 <p>
    395 </p>
    396 <pre class="screen">PositionSpecification := Position "=" Space* PositionName</pre>
    397 <p>
    398 </p>
    399 <pre class="screen">Position := CostPosition | CalledPosition</pre>
    400 <p>
    401 </p>
    402 <pre class="screen">CostPosition := "ob" | "fl" | "fi" | "fe" | "fn"</pre>
    403 <p>
    404 </p>
    405 <pre class="screen">CalledPosition := " "cob" | "cfl" | "cfn"</pre>
    406 <p>
    407 </p>
    408 <pre class="screen">PositionName := ( "(" Number ")" )? (Space* NoNewLineChar* )?</pre>
    409 <p>
    410 </p>
    411 <pre class="screen">AssociationSpecification := CallSpecification
    412   | JumpSpecification</pre>
    413 <p>
    414 </p>
    415 <pre class="screen">CallSpecification := CallLine "\n" CostLine</pre>
    416 <p>
    417 </p>
    418 <pre class="screen">CallLine := "calls=" Space* Number Space+ SubPositionList</pre>
    419 <p>
    420 </p>
    421 <pre class="screen">JumpSpecification := ...</pre>
    422 <p>
    423 </p>
    424 <pre class="screen">Space := " " | "\t"</pre>
    425 <p>
    426 </p>
    427 <pre class="screen">Number := HexNumber | (Digit)+</pre>
    428 <p>
    429 </p>
    430 <pre class="screen">Digit := "0" | ... | "9"</pre>
    431 <p>
    432 </p>
    433 <pre class="screen">HexNumber := "0x" (Digit | HexChar)+</pre>
    434 <p>
    435 </p>
    436 <pre class="screen">HexChar := "a" | ... | "f" | "A" | ... | "F"</pre>
    437 <p>
    438 </p>
    439 <pre class="screen">Name = Alpha (Digit | Alpha)*</pre>
    440 <p>
    441 </p>
    442 <pre class="screen">Alpha = "a" | ... | "z" | "A" | ... | "Z"</pre>
    443 <p>
    444 </p>
    445 <pre class="screen">NoNewLineChar := all characters without "\n"</pre>
    446 <p>
    447 </p>
    448 </div>
    449 <div class="sect2" title="3.2.2.Description of Header Lines">
    450 <div class="titlepage"><div><div><h3 class="title">
    451 <a name="cl-format.reference.header"></a>3.2.2.Description of Header Lines</h3></div></div></div>
    452 <p>The header has an arbitrary number of lines of the format 
    453 "key: value". Possible <span class="emphasis"><em>key</em></span> values for the header are:</p>
    454 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
    455 <li class="listitem">
    456 <p><code class="computeroutput">version: number</code> [Callgrind]</p>
    457 <p>This is used to distinguish future profile data formats.  A 
    458     major version of 0 or 1 is supposed to be upwards compatible with 
    459     Cachegrind's format.  It is optional; if not appearing, version 1 
    460     is supposed.  Otherwise, this has to be the first header line.</p>
    461 </li>
    462 <li class="listitem">
    463 <p><code class="computeroutput">pid: process id</code> [Callgrind]</p>
    464 <p>This specifies the process ID of the supervised application 
    465     for which this profile was generated.</p>
    466 </li>
    467 <li class="listitem">
    468 <p><code class="computeroutput">cmd: program name + args</code> [Cachegrind]</p>
    469 <p>This specifies the full command line of the supervised
    470     application for which this profile was generated.</p>
    471 </li>
    472 <li class="listitem">
    473 <p><code class="computeroutput">part: number</code> [Callgrind]</p>
    474 <p>This specifies a sequentially incremented number for each dump 
    475     generated, starting at 1.</p>
    476 </li>
    477 <li class="listitem">
    478 <p><code class="computeroutput">desc: type: value</code> [Cachegrind]</p>
    479 <p>This specifies various information for this dump.  For some 
    480     types, the semantic is defined, but any description type is allowed. 
    481     Unknown types should be ignored.</p>
    482 <p>There are the types "I1 cache", "D1 cache", "LL cache", which 
    483     specify parameters used for the cache simulator.  These are the only
    484     types originally used by Cachegrind.  Additionally, Callgrind uses 
    485     the following types:  "Timerange" gives a rough range of the basic
    486     block counter, for which the cost of this dump was collected. 
    487     Type "Trigger" states the reason of why this trace was generated.
    488     E.g. program termination or forced interactive dump.</p>
    489 </li>
    490 <li class="listitem">
    491 <p><code class="computeroutput">positions: [instr] [line]</code> [Callgrind]</p>
    492 <p>For cost lines, this defines the semantic of the first numbers. 
    493     Any combination of "instr", "bb" and "line" is allowed, but has to be 
    494     in this order which corresponds to position numbers at the start of 
    495     the cost lines later in the file.</p>
    496 <p>If "instr" is specified, the position is the address of an 
    497     instruction whose execution raised the events given later on the 
    498     line.  This address is relative to the offset of the binary/shared 
    499     library file to not have to specify relocation info.  For "line", 
    500     the position is the line number of a source file, which is 
    501     responsible for the events raised. Note that the mapping of "instr"
    502     and "line" positions are given by the debugging line information
    503     produced by the compiler.</p>
    504 <p>This field is optional. If not specified, "line" is supposed 
    505     only.</p>
    506 </li>
    507 <li class="listitem">
    508 <p><code class="computeroutput">events: event type abbreviations</code> [Cachegrind]</p>
    509 <p>A list of short names of the event types logged in this file. 
    510     The order is the same as in cost lines.  The first event type is the
    511     second or third number in a cost line, depending on the value of 
    512     "positions".  Callgrind does not add additional cost types.  Specify
    513     exactly once.</p>
    514 <p>Cost types from original Cachegrind are:
    515       </p>
    516 <div class="itemizedlist"><ul class="itemizedlist" type="circle">
    517 <li class="listitem"><p><span class="command"><strong>Ir</strong></span>: Instruction read access</p></li>
    518 <li class="listitem"><p><span class="command"><strong>I1mr</strong></span>: Instruction Level 1 read cache miss</p></li>
    519 <li class="listitem"><p><span class="command"><strong>ILmr</strong></span>: Instruction last-level read cache miss</p></li>
    520 <li class="listitem"><p>...</p></li>
    521 </ul></div>
    522 <p>
    523     </p>
    524 </li>
    525 <li class="listitem">
    526 <p><code class="computeroutput">summary: costs</code> [Callgrind]</p>
    527 <p><code class="computeroutput">totals: costs</code> [Cachegrind]</p>
    528 <p>The value or the total number of events covered by this trace
    529     file.  Both keys have the same meaning, but the "totals:" line 
    530     happens to be at the end of the file, while "summary:" appears in 
    531     the header.  This was added to allow postprocessing tools to know
    532     in advance to total cost. The two lines always give the same cost 
    533     counts.</p>
    534 </li>
    535 </ul></div>
    536 </div>
    537 <div class="sect2" title="3.2.3.Description of Body Lines">
    538 <div class="titlepage"><div><div><h3 class="title">
    539 <a name="cl-format.reference.body"></a>3.2.3.Description of Body Lines</h3></div></div></div>
    540 <p>There exist lines
    541 <code class="computeroutput">spec=position</code>.  The values for position
    542 specifications are arbitrary strings.  When starting with "(" and a
    543 digit, it's a string in compressed format.  Otherwise it's the real
    544 position string.  This allows for file and symbol names as position
    545 strings, as these never start with "(" + <span class="emphasis"><em>digit</em></span>.
    546 The compressed format is either "(" <span class="emphasis"><em>number</em></span> ")"
    547 <span class="emphasis"><em>space</em></span> <span class="emphasis"><em>position</em></span> or only 
    548 "(" <span class="emphasis"><em>number</em></span> ")".  The first relates
    549 <span class="emphasis"><em>position</em></span> to <span class="emphasis"><em>number</em></span> in the
    550 context of the given format specification from this line to the end of
    551 the file; it makes the (<span class="emphasis"><em>number</em></span>) an alias for
    552 <span class="emphasis"><em>position</em></span>.  Compressed format is always
    553 optional.</p>
    554 <p>Position specifications allowed:</p>
    555 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
    556 <li class="listitem">
    557 <p><code class="computeroutput">ob=</code> [Callgrind]</p>
    558 <p>The ELF object where the cost of next cost lines happens.</p>
    559 </li>
    560 <li class="listitem"><p><code class="computeroutput">fl=</code> [Cachegrind]</p></li>
    561 <li class="listitem"><p><code class="computeroutput">fi=</code> [Cachegrind]</p></li>
    562 <li class="listitem">
    563 <p><code class="computeroutput">fe=</code> [Cachegrind]</p>
    564 <p>The source file including the code which is responsible for
    565     the cost of next cost lines. "fi="/"fe=" is used when the source
    566     file changes inside of a function, i.e. for inlined code.</p>
    567 </li>
    568 <li class="listitem">
    569 <p><code class="computeroutput">fn=</code> [Cachegrind]</p>
    570 <p>The name of the function where the cost of next cost lines 
    571     happens.</p>
    572 </li>
    573 <li class="listitem">
    574 <p><code class="computeroutput">cob=</code> [Callgrind]</p>
    575 <p>The ELF object of the target of the next call cost lines.</p>
    576 </li>
    577 <li class="listitem">
    578 <p><code class="computeroutput">cfl=</code> [Callgrind]</p>
    579 <p>The source file including the code of the target of the
    580     next call cost lines.</p>
    581 </li>
    582 <li class="listitem">
    583 <p><code class="computeroutput">cfn=</code> [Callgrind]</p>
    584 <p>The name of the target function of the next call cost 
    585     lines.</p>
    586 </li>
    587 <li class="listitem">
    588 <p><code class="computeroutput">calls=</code> [Callgrind]</p>
    589 <p>The number of nonrecursive calls which are responsible for the 
    590     cost specified by the next call cost line. This is the cost spent 
    591     inside of the called function.</p>
    592 <p>After "calls=" there MUST be a cost line. This is the cost
    593     spent in the called function. The first number is the source line 
    594     from where the call happened.</p>
    595 </li>
    596 <li class="listitem">
    597 <p><code class="computeroutput">jump=count target position</code> [Callgrind]</p>
    598 <p>Unconditional jump, executed count times, to the given target
    599     position.</p>
    600 </li>
    601 <li class="listitem">
    602 <p><code class="computeroutput">jcnd=exe.count jumpcount target position</code> [Callgrind]</p>
    603 <p>Conditional jump, executed exe.count times with jumpcount 
    604     jumps to the given target position.</p>
    605 </li>
    606 </ul></div>
    607 </div>
    608 </div>
    609 </div>
    610 <div>
    611 <br><table class="nav" width="100%" cellspacing="3" cellpadding="2" border="0" summary="Navigation footer">
    612 <tr>
    613 <td rowspan="2" width="40%" align="left">
    614 <a accesskey="p" href="manual-writing-tools.html">&lt;&lt;2.Writing a New Valgrind Tool</a></td>
    615 <td width="20%" align="center"><a accesskey="u" href="tech-docs.html">Up</a></td>
    616 <td rowspan="2" width="40%" align="right"><a accesskey="n" href="dist.html">Valgrind Distribution Documents&gt;&gt;</a>
    617 </td>
    618 </tr>
    619 <tr><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td></tr>
    620 </table>
    621 </div>
    622 </body>
    623 </html>
    624