You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
160 lines
7.7 KiB
HTML
160 lines
7.7 KiB
HTML
4 years ago
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
|
<html>
|
||
|
<!-- This file documents the gprof profiler of the GNU system.
|
||
|
|
||
|
Copyright (C) 1988-2019 Free Software Foundation, Inc.
|
||
|
|
||
|
Permission is granted to copy, distribute and/or modify this document
|
||
|
under the terms of the GNU Free Documentation License, Version 1.3
|
||
|
or any later version published by the Free Software Foundation;
|
||
|
with no Invariant Sections, with no Front-Cover Texts, and with no
|
||
|
Back-Cover Texts. A copy of the license is included in the
|
||
|
section entitled "GNU Free Documentation License".
|
||
|
-->
|
||
|
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
|
||
|
<head>
|
||
|
<title>File Format (GNU gprof)</title>
|
||
|
|
||
|
<meta name="description" content="File Format (GNU gprof)">
|
||
|
<meta name="keywords" content="File Format (GNU gprof)">
|
||
|
<meta name="resource-type" content="document">
|
||
|
<meta name="distribution" content="global">
|
||
|
<meta name="Generator" content="makeinfo">
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<link href="index.html#Top" rel="start" title="Top">
|
||
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||
|
<link href="Details.html#Details" rel="up" title="Details">
|
||
|
<link href="Internals.html#Internals" rel="next" title="Internals">
|
||
|
<link href="Implementation.html#Implementation" rel="prev" title="Implementation">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
a.summary-letter {text-decoration: none}
|
||
|
blockquote.indentedblock {margin-right: 0em}
|
||
|
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
|
||
|
blockquote.smallquotation {font-size: smaller}
|
||
|
div.display {margin-left: 3.2em}
|
||
|
div.example {margin-left: 3.2em}
|
||
|
div.lisp {margin-left: 3.2em}
|
||
|
div.smalldisplay {margin-left: 3.2em}
|
||
|
div.smallexample {margin-left: 3.2em}
|
||
|
div.smalllisp {margin-left: 3.2em}
|
||
|
kbd {font-style: oblique}
|
||
|
pre.display {font-family: inherit}
|
||
|
pre.format {font-family: inherit}
|
||
|
pre.menu-comment {font-family: serif}
|
||
|
pre.menu-preformatted {font-family: serif}
|
||
|
pre.smalldisplay {font-family: inherit; font-size: smaller}
|
||
|
pre.smallexample {font-size: smaller}
|
||
|
pre.smallformat {font-family: inherit; font-size: smaller}
|
||
|
pre.smalllisp {font-size: smaller}
|
||
|
span.nolinebreak {white-space: nowrap}
|
||
|
span.roman {font-family: initial; font-weight: normal}
|
||
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||
|
ul.no-bullet {list-style: none}
|
||
|
-->
|
||
|
</style>
|
||
|
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body lang="en">
|
||
|
<a name="File-Format"></a>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
Next: <a href="Internals.html#Internals" accesskey="n" rel="next">Internals</a>, Previous: <a href="Implementation.html#Implementation" accesskey="p" rel="prev">Implementation</a>, Up: <a href="Details.html#Details" accesskey="u" rel="up">Details</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<a name="Profiling-Data-File-Format"></a>
|
||
|
<h3 class="section">9.2 Profiling Data File Format</h3>
|
||
|
|
||
|
<p>The old BSD-derived file format used for profile data does not contain a
|
||
|
magic cookie that allows to check whether a data file really is a
|
||
|
<code>gprof</code> file. Furthermore, it does not provide a version number, thus
|
||
|
rendering changes to the file format almost impossible. <small>GNU</small> <code>gprof</code>
|
||
|
uses a new file format that provides these features. For backward
|
||
|
compatibility, <small>GNU</small> <code>gprof</code> continues to support the old BSD-derived
|
||
|
format, but not all features are supported with it. For example,
|
||
|
basic-block execution counts cannot be accommodated by the old file
|
||
|
format.
|
||
|
</p>
|
||
|
<p>The new file format is defined in header file <samp>gmon_out.h</samp>. It
|
||
|
consists of a header containing the magic cookie and a version number,
|
||
|
as well as some spare bytes available for future extensions. All data
|
||
|
in a profile data file is in the native format of the target for which
|
||
|
the profile was collected. <small>GNU</small> <code>gprof</code> adapts automatically
|
||
|
to the byte-order in use.
|
||
|
</p>
|
||
|
<p>In the new file format, the header is followed by a sequence of
|
||
|
records. Currently, there are three different record types: histogram
|
||
|
records, call-graph arc records, and basic-block execution count
|
||
|
records. Each file can contain any number of each record type. When
|
||
|
reading a file, <small>GNU</small> <code>gprof</code> will ensure records of the same type are
|
||
|
compatible with each other and compute the union of all records. For
|
||
|
example, for basic-block execution counts, the union is simply the sum
|
||
|
of all execution counts for each basic-block.
|
||
|
</p>
|
||
|
<a name="Histogram-Records"></a>
|
||
|
<h4 class="subsection">9.2.1 Histogram Records</h4>
|
||
|
|
||
|
<p>Histogram records consist of a header that is followed by an array of
|
||
|
bins. The header contains the text-segment range that the histogram
|
||
|
spans, the size of the histogram in bytes (unlike in the old BSD
|
||
|
format, this does not include the size of the header), the rate of the
|
||
|
profiling clock, and the physical dimension that the bin counts
|
||
|
represent after being scaled by the profiling clock rate. The
|
||
|
physical dimension is specified in two parts: a long name of up to 15
|
||
|
characters and a single character abbreviation. For example, a
|
||
|
histogram representing real-time would specify the long name as
|
||
|
“seconds” and the abbreviation as “s”. This feature is useful for
|
||
|
architectures that support performance monitor hardware (which,
|
||
|
fortunately, is becoming increasingly common). For example, under DEC
|
||
|
OSF/1, the “uprofile” command can be used to produce a histogram of,
|
||
|
say, instruction cache misses. In this case, the dimension in the
|
||
|
histogram header could be set to “i-cache misses” and the abbreviation
|
||
|
could be set to “1” (because it is simply a count, not a physical
|
||
|
dimension). Also, the profiling rate would have to be set to 1 in
|
||
|
this case.
|
||
|
</p>
|
||
|
<p>Histogram bins are 16-bit numbers and each bin represent an equal
|
||
|
amount of text-space. For example, if the text-segment is one
|
||
|
thousand bytes long and if there are ten bins in the histogram, each
|
||
|
bin represents one hundred bytes.
|
||
|
</p>
|
||
|
|
||
|
<a name="Call_002dGraph-Records"></a>
|
||
|
<h4 class="subsection">9.2.2 Call-Graph Records</h4>
|
||
|
|
||
|
<p>Call-graph records have a format that is identical to the one used in
|
||
|
the BSD-derived file format. It consists of an arc in the call graph
|
||
|
and a count indicating the number of times the arc was traversed
|
||
|
during program execution. Arcs are specified by a pair of addresses:
|
||
|
the first must be within caller’s function and the second must be
|
||
|
within the callee’s function. When performing profiling at the
|
||
|
function level, these addresses can point anywhere within the
|
||
|
respective function. However, when profiling at the line-level, it is
|
||
|
better if the addresses are as close to the call-site/entry-point as
|
||
|
possible. This will ensure that the line-level call-graph is able to
|
||
|
identify exactly which line of source code performed calls to a
|
||
|
function.
|
||
|
</p>
|
||
|
<a name="Basic_002dBlock-Execution-Count-Records"></a>
|
||
|
<h4 class="subsection">9.2.3 Basic-Block Execution Count Records</h4>
|
||
|
|
||
|
<p>Basic-block execution count records consist of a header followed by a
|
||
|
sequence of address/count pairs. The header simply specifies the
|
||
|
length of the sequence. In an address/count pair, the address
|
||
|
identifies a basic-block and the count specifies the number of times
|
||
|
that basic-block was executed. Any address within the basic-address can
|
||
|
be used.
|
||
|
</p>
|
||
|
<hr>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
Next: <a href="Internals.html#Internals" accesskey="n" rel="next">Internals</a>, Previous: <a href="Implementation.html#Implementation" accesskey="p" rel="prev">Implementation</a>, Up: <a href="Details.html#Details" accesskey="u" rel="up">Details</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|