You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

File-Format.html 7.7KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- This file documents the gprof profiler of the GNU system.
  4. Copyright (C) 1988-2020 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3
  7. or any later version published by the Free Software Foundation;
  8. with no Invariant Sections, with no Front-Cover Texts, and with no
  9. Back-Cover Texts. A copy of the license is included in the
  10. section entitled "GNU Free Documentation License".
  11. -->
  12. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  15. <title>File Format (GNU gprof)</title>
  16. <meta name="description" content="File Format (GNU gprof)">
  17. <meta name="keywords" content="File Format (GNU gprof)">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <link href="index.html#Top" rel="start" title="Top">
  22. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  23. <link href="Details.html#Details" rel="up" title="Details">
  24. <link href="Internals.html#Internals" rel="next" title="Internals">
  25. <link href="Implementation.html#Implementation" rel="prev" title="Implementation">
  26. <style type="text/css">
  27. <!--
  28. a.summary-letter {text-decoration: none}
  29. blockquote.indentedblock {margin-right: 0em}
  30. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.lisp {margin-left: 3.2em}
  35. div.smalldisplay {margin-left: 3.2em}
  36. div.smallexample {margin-left: 3.2em}
  37. div.smalllisp {margin-left: 3.2em}
  38. kbd {font-style: oblique}
  39. pre.display {font-family: inherit}
  40. pre.format {font-family: inherit}
  41. pre.menu-comment {font-family: serif}
  42. pre.menu-preformatted {font-family: serif}
  43. pre.smalldisplay {font-family: inherit; font-size: smaller}
  44. pre.smallexample {font-size: smaller}
  45. pre.smallformat {font-family: inherit; font-size: smaller}
  46. pre.smalllisp {font-size: smaller}
  47. span.nolinebreak {white-space: nowrap}
  48. span.roman {font-family: initial; font-weight: normal}
  49. span.sansserif {font-family: sans-serif; font-weight: normal}
  50. ul.no-bullet {list-style: none}
  51. -->
  52. </style>
  53. </head>
  54. <body lang="en">
  55. <a name="File-Format"></a>
  56. <div class="header">
  57. <p>
  58. 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> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
  59. </div>
  60. <hr>
  61. <a name="Profiling-Data-File-Format"></a>
  62. <h3 class="section">9.2 Profiling Data File Format</h3>
  63. <p>The old BSD-derived file format used for profile data does not contain a
  64. magic cookie that allows to check whether a data file really is a
  65. <code>gprof</code> file. Furthermore, it does not provide a version number, thus
  66. rendering changes to the file format almost impossible. <small>GNU</small> <code>gprof</code>
  67. uses a new file format that provides these features. For backward
  68. compatibility, <small>GNU</small> <code>gprof</code> continues to support the old BSD-derived
  69. format, but not all features are supported with it. For example,
  70. basic-block execution counts cannot be accommodated by the old file
  71. format.
  72. </p>
  73. <p>The new file format is defined in header file <samp>gmon_out.h</samp>. It
  74. consists of a header containing the magic cookie and a version number,
  75. as well as some spare bytes available for future extensions. All data
  76. in a profile data file is in the native format of the target for which
  77. the profile was collected. <small>GNU</small> <code>gprof</code> adapts automatically
  78. to the byte-order in use.
  79. </p>
  80. <p>In the new file format, the header is followed by a sequence of
  81. records. Currently, there are three different record types: histogram
  82. records, call-graph arc records, and basic-block execution count
  83. records. Each file can contain any number of each record type. When
  84. reading a file, <small>GNU</small> <code>gprof</code> will ensure records of the same type are
  85. compatible with each other and compute the union of all records. For
  86. example, for basic-block execution counts, the union is simply the sum
  87. of all execution counts for each basic-block.
  88. </p>
  89. <a name="Histogram-Records"></a>
  90. <h4 class="subsection">9.2.1 Histogram Records</h4>
  91. <p>Histogram records consist of a header that is followed by an array of
  92. bins. The header contains the text-segment range that the histogram
  93. spans, the size of the histogram in bytes (unlike in the old BSD
  94. format, this does not include the size of the header), the rate of the
  95. profiling clock, and the physical dimension that the bin counts
  96. represent after being scaled by the profiling clock rate. The
  97. physical dimension is specified in two parts: a long name of up to 15
  98. characters and a single character abbreviation. For example, a
  99. histogram representing real-time would specify the long name as
  100. &ldquo;seconds&rdquo; and the abbreviation as &ldquo;s&rdquo;. This feature is useful for
  101. architectures that support performance monitor hardware (which,
  102. fortunately, is becoming increasingly common). For example, under DEC
  103. OSF/1, the &ldquo;uprofile&rdquo; command can be used to produce a histogram of,
  104. say, instruction cache misses. In this case, the dimension in the
  105. histogram header could be set to &ldquo;i-cache misses&rdquo; and the abbreviation
  106. could be set to &ldquo;1&rdquo; (because it is simply a count, not a physical
  107. dimension). Also, the profiling rate would have to be set to 1 in
  108. this case.
  109. </p>
  110. <p>Histogram bins are 16-bit numbers and each bin represent an equal
  111. amount of text-space. For example, if the text-segment is one
  112. thousand bytes long and if there are ten bins in the histogram, each
  113. bin represents one hundred bytes.
  114. </p>
  115. <a name="Call_002dGraph-Records"></a>
  116. <h4 class="subsection">9.2.2 Call-Graph Records</h4>
  117. <p>Call-graph records have a format that is identical to the one used in
  118. the BSD-derived file format. It consists of an arc in the call graph
  119. and a count indicating the number of times the arc was traversed
  120. during program execution. Arcs are specified by a pair of addresses:
  121. the first must be within caller&rsquo;s function and the second must be
  122. within the callee&rsquo;s function. When performing profiling at the
  123. function level, these addresses can point anywhere within the
  124. respective function. However, when profiling at the line-level, it is
  125. better if the addresses are as close to the call-site/entry-point as
  126. possible. This will ensure that the line-level call-graph is able to
  127. identify exactly which line of source code performed calls to a
  128. function.
  129. </p>
  130. <a name="Basic_002dBlock-Execution-Count-Records"></a>
  131. <h4 class="subsection">9.2.3 Basic-Block Execution Count Records</h4>
  132. <p>Basic-block execution count records consist of a header followed by a
  133. sequence of address/count pairs. The header simply specifies the
  134. length of the sequence. In an address/count pair, the address
  135. identifies a basic-block and the count specifies the number of times
  136. that basic-block was executed. Any address within the basic-address can
  137. be used.
  138. </p>
  139. <hr>
  140. <div class="header">
  141. <p>
  142. 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> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
  143. </div>
  144. </body>
  145. </html>