addr2line.html 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1991-2017 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3
  6. or any later version published by the Free Software Foundation;
  7. with no Invariant Sections, with no Front-Cover Texts, and with no
  8. Back-Cover Texts. A copy of the license is included in the
  9. section entitled "GNU Free Documentation License".
  10. -->
  11. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  12. <head>
  13. <title>GNU Binary Utilities: addr2line</title>
  14. <meta name="description" content="GNU Binary Utilities: addr2line">
  15. <meta name="keywords" content="GNU Binary Utilities: addr2line">
  16. <meta name="resource-type" content="document">
  17. <meta name="distribution" content="global">
  18. <meta name="Generator" content="makeinfo">
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <link href="index.html#Top" rel="start" title="Top">
  21. <link href="Binutils-Index.html#Binutils-Index" rel="index" title="Binutils Index">
  22. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  23. <link href="index.html#Top" rel="up" title="Top">
  24. <link href="nlmconv.html#nlmconv" rel="next" title="nlmconv">
  25. <link href="c_002b_002bfilt.html#c_002b_002bfilt" rel="prev" title="c++filt">
  26. <style type="text/css">
  27. <!--
  28. a.summary-letter {text-decoration: none}
  29. blockquote.smallquotation {font-size: smaller}
  30. div.display {margin-left: 3.2em}
  31. div.example {margin-left: 3.2em}
  32. div.indentedblock {margin-left: 3.2em}
  33. div.lisp {margin-left: 3.2em}
  34. div.smalldisplay {margin-left: 3.2em}
  35. div.smallexample {margin-left: 3.2em}
  36. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  48. span.nolinebreak {white-space:nowrap}
  49. span.roman {font-family:serif; font-weight:normal}
  50. span.sansserif {font-family:sans-serif; font-weight:normal}
  51. ul.no-bullet {list-style: none}
  52. -->
  53. </style>
  54. </head>
  55. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  56. <a name="addr2line"></a>
  57. <div class="header">
  58. <p>
  59. Next: <a href="nlmconv.html#nlmconv" accesskey="n" rel="next">nlmconv</a>, Previous: <a href="c_002b_002bfilt.html#c_002b_002bfilt" accesskey="p" rel="prev">c++filt</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Binutils-Index.html#Binutils-Index" title="Index" rel="index">Index</a>]</p>
  60. </div>
  61. <hr>
  62. <a name="addr2line-1"></a>
  63. <h2 class="chapter">10 addr2line</h2>
  64. <a name="index-addr2line"></a>
  65. <a name="index-address-to-file-name-and-line-number"></a>
  66. <div class="smallexample">
  67. <pre class="smallexample">addr2line [<samp>-a</samp>|<samp>--addresses</samp>]
  68. [<samp>-b</samp> <var>bfdname</var>|<samp>--target=</samp><var>bfdname</var>]
  69. [<samp>-C</samp>|<samp>--demangle</samp>[=<var>style</var>]]
  70. [<samp>-e</samp> <var>filename</var>|<samp>--exe=</samp><var>filename</var>]
  71. [<samp>-f</samp>|<samp>--functions</samp>] [<samp>-s</samp>|<samp>--basename</samp>]
  72. [<samp>-i</samp>|<samp>--inlines</samp>]
  73. [<samp>-p</samp>|<samp>--pretty-print</samp>]
  74. [<samp>-j</samp>|<samp>--section=</samp><var>name</var>]
  75. [<samp>-H</samp>|<samp>--help</samp>] [<samp>-V</samp>|<samp>--version</samp>]
  76. [addr addr &hellip;]
  77. </pre></div>
  78. <p><code>addr2line</code> translates addresses into file names and line numbers.
  79. Given an address in an executable or an offset in a section of a relocatable
  80. object, it uses the debugging information to figure out which file name and
  81. line number are associated with it.
  82. </p>
  83. <p>The executable or relocatable object to use is specified with the <samp>-e</samp>
  84. option. The default is the file <samp>a.out</samp>. The section in the relocatable
  85. object to use is specified with the <samp>-j</samp> option.
  86. </p>
  87. <p><code>addr2line</code> has two modes of operation.
  88. </p>
  89. <p>In the first, hexadecimal addresses are specified on the command line,
  90. and <code>addr2line</code> displays the file name and line number for each
  91. address.
  92. </p>
  93. <p>In the second, <code>addr2line</code> reads hexadecimal addresses from
  94. standard input, and prints the file name and line number for each
  95. address on standard output. In this mode, <code>addr2line</code> may be used
  96. in a pipe to convert dynamically chosen addresses.
  97. </p>
  98. <p>The format of the output is &lsquo;<samp>FILENAME:LINENO</samp>&rsquo;. By default
  99. each input address generates one line of output.
  100. </p>
  101. <p>Two options can generate additional lines before each
  102. &lsquo;<samp>FILENAME:LINENO</samp>&rsquo; line (in that order).
  103. </p>
  104. <p>If the <samp>-a</samp> option is used then a line with the input address
  105. is displayed.
  106. </p>
  107. <p>If the <samp>-f</samp> option is used, then a line with the
  108. &lsquo;<samp>FUNCTIONNAME</samp>&rsquo; is displayed. This is the name of the function
  109. containing the address.
  110. </p>
  111. <p>One option can generate additional lines after the
  112. &lsquo;<samp>FILENAME:LINENO</samp>&rsquo; line.
  113. </p>
  114. <p>If the <samp>-i</samp> option is used and the code at the given address is
  115. present there because of inlining by the compiler then additional
  116. lines are displayed afterwards. One or two extra lines (if the
  117. <samp>-f</samp> option is used) are displayed for each inlined function.
  118. </p>
  119. <p>Alternatively if the <samp>-p</samp> option is used then each input
  120. address generates a single, long, output line containing the address,
  121. the function name, the file name and the line number. If the
  122. <samp>-i</samp> option has also been used then any inlined functions will
  123. be displayed in the same manner, but on separate lines, and prefixed
  124. by the text &lsquo;<samp>(inlined by)</samp>&rsquo;.
  125. </p>
  126. <p>If the file name or function name can not be determined,
  127. <code>addr2line</code> will print two question marks in their place. If the
  128. line number can not be determined, <code>addr2line</code> will print 0.
  129. </p>
  130. <p>The long and short forms of options, shown here as alternatives, are
  131. equivalent.
  132. </p>
  133. <dl compact="compact">
  134. <dt><code>-a</code></dt>
  135. <dt><code>--addresses</code></dt>
  136. <dd><p>Display the address before the function name, file and line number
  137. information. The address is printed with a &lsquo;<samp>0x</samp>&rsquo; prefix to easily
  138. identify it.
  139. </p>
  140. </dd>
  141. <dt><code>-b <var>bfdname</var></code></dt>
  142. <dt><code>--target=<var>bfdname</var></code></dt>
  143. <dd><a name="index-object-code-format-4"></a>
  144. <p>Specify that the object-code format for the object files is
  145. <var>bfdname</var>.
  146. </p>
  147. </dd>
  148. <dt><code>-C</code></dt>
  149. <dt><code>--demangle[=<var>style</var>]</code></dt>
  150. <dd><a name="index-demangling-in-objdump-1"></a>
  151. <p>Decode (<em>demangle</em>) low-level symbol names into user-level names.
  152. Besides removing any initial underscore prepended by the system, this
  153. makes C++ function names readable. Different compilers have different
  154. mangling styles. The optional demangling style argument can be used to
  155. choose an appropriate demangling style for your compiler. See <a href="c_002b_002bfilt.html#c_002b_002bfilt">c++filt</a>,
  156. for more information on demangling.
  157. </p>
  158. </dd>
  159. <dt><code>-e <var>filename</var></code></dt>
  160. <dt><code>--exe=<var>filename</var></code></dt>
  161. <dd><p>Specify the name of the executable for which addresses should be
  162. translated. The default file is <samp>a.out</samp>.
  163. </p>
  164. </dd>
  165. <dt><code>-f</code></dt>
  166. <dt><code>--functions</code></dt>
  167. <dd><p>Display function names as well as file and line number information.
  168. </p>
  169. </dd>
  170. <dt><code>-s</code></dt>
  171. <dt><code>--basenames</code></dt>
  172. <dd><p>Display only the base of each file name.
  173. </p>
  174. </dd>
  175. <dt><code>-i</code></dt>
  176. <dt><code>--inlines</code></dt>
  177. <dd><p>If the address belongs to a function that was inlined, the source
  178. information for all enclosing scopes back to the first non-inlined
  179. function will also be printed. For example, if <code>main</code> inlines
  180. <code>callee1</code> which inlines <code>callee2</code>, and address is from
  181. <code>callee2</code>, the source information for <code>callee1</code> and <code>main</code>
  182. will also be printed.
  183. </p>
  184. </dd>
  185. <dt><code>-j</code></dt>
  186. <dt><code>--section</code></dt>
  187. <dd><p>Read offsets relative to the specified section instead of absolute addresses.
  188. </p>
  189. </dd>
  190. <dt><code>-p</code></dt>
  191. <dt><code>--pretty-print</code></dt>
  192. <dd><p>Make the output more human friendly: each location are printed on one line.
  193. If option <samp>-i</samp> is specified, lines for all enclosing scopes are
  194. prefixed with &lsquo;<samp>(inlined by)</samp>&rsquo;.
  195. </p></dd>
  196. </dl>
  197. <hr>
  198. <div class="header">
  199. <p>
  200. Next: <a href="nlmconv.html#nlmconv" accesskey="n" rel="next">nlmconv</a>, Previous: <a href="c_002b_002bfilt.html#c_002b_002bfilt" accesskey="p" rel="prev">c++filt</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Binutils-Index.html#Binutils-Index" title="Index" rel="index">Index</a>]</p>
  201. </div>
  202. </body>
  203. </html>