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-2021 Free Software Foundation, Inc. 4 5Permission is granted to copy, distribute and/or modify this document 6under the terms of the GNU Free Documentation License, Version 1.3 7or any later version published by the Free Software Foundation; 8with no Invariant Sections, with no Front-Cover Texts, and with no 9Back-Cover Texts. A copy of the license is included in the 10section entitled "GNU Free Documentation License". 11 --> 12<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> 13<head> 14<title>GNU Binary Utilities: addr2line</title> 15 16<meta name="description" content="GNU Binary Utilities: addr2line"> 17<meta name="keywords" content="GNU Binary Utilities: addr2line"> 18<meta name="resource-type" content="document"> 19<meta name="distribution" content="global"> 20<meta name="Generator" content="makeinfo"> 21<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 22<link href="index.html#Top" rel="start" title="Top"> 23<link href="Binutils-Index.html#Binutils-Index" rel="index" title="Binutils Index"> 24<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 25<link href="index.html#Top" rel="up" title="Top"> 26<link href="windmc.html#windmc" rel="next" title="windmc"> 27<link href="c_002b_002bfilt.html#c_002b_002bfilt" rel="previous" title="c++filt"> 28<style type="text/css"> 29<!-- 30a.summary-letter {text-decoration: none} 31blockquote.smallquotation {font-size: smaller} 32div.display {margin-left: 3.2em} 33div.example {margin-left: 3.2em} 34div.indentedblock {margin-left: 3.2em} 35div.lisp {margin-left: 3.2em} 36div.smalldisplay {margin-left: 3.2em} 37div.smallexample {margin-left: 3.2em} 38div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 39div.smalllisp {margin-left: 3.2em} 40kbd {font-style:oblique} 41pre.display {font-family: inherit} 42pre.format {font-family: inherit} 43pre.menu-comment {font-family: serif} 44pre.menu-preformatted {font-family: serif} 45pre.smalldisplay {font-family: inherit; font-size: smaller} 46pre.smallexample {font-size: smaller} 47pre.smallformat {font-family: inherit; font-size: smaller} 48pre.smalllisp {font-size: smaller} 49span.nocodebreak {white-space:nowrap} 50span.nolinebreak {white-space:nowrap} 51span.roman {font-family:serif; font-weight:normal} 52span.sansserif {font-family:sans-serif; font-weight:normal} 53ul.no-bullet {list-style: none} 54--> 55</style> 56 57 58</head> 59 60<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 61<a name="addr2line"></a> 62<div class="header"> 63<p> 64Next: <a href="windmc.html#windmc" accesskey="n" rel="next">windmc</a>, Previous: <a href="c_002b_002bfilt.html#c_002b_002bfilt" accesskey="p" rel="previous">c++filt</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<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> 65</div> 66<hr> 67<a name="addr2line-1"></a> 68<h2 class="chapter">10 addr2line</h2> 69 70<a name="index-addr2line"></a> 71<a name="index-address-to-file-name-and-line-number"></a> 72 73 74<div class="smallexample"> 75<pre class="smallexample">addr2line [<samp>-a</samp>|<samp>--addresses</samp>] 76 [<samp>-b</samp> <var>bfdname</var>|<samp>--target=</samp><var>bfdname</var>] 77 [<samp>-C</samp>|<samp>--demangle</samp>[=<var>style</var>]] 78 [<samp>-r</samp>|<samp>--no-recurse-limit</samp>] 79 [<samp>-R</samp>|<samp>--recurse-limit</samp>] 80 [<samp>-e</samp> <var>filename</var>|<samp>--exe=</samp><var>filename</var>] 81 [<samp>-f</samp>|<samp>--functions</samp>] [<samp>-s</samp>|<samp>--basename</samp>] 82 [<samp>-i</samp>|<samp>--inlines</samp>] 83 [<samp>-p</samp>|<samp>--pretty-print</samp>] 84 [<samp>-j</samp>|<samp>--section=</samp><var>name</var>] 85 [<samp>-H</samp>|<samp>--help</samp>] [<samp>-V</samp>|<samp>--version</samp>] 86 [addr addr …] 87</pre></div> 88 89 90<p><code>addr2line</code> translates addresses into file names and line numbers. 91Given an address in an executable or an offset in a section of a relocatable 92object, it uses the debugging information to figure out which file name and 93line number are associated with it. 94</p> 95<p>The executable or relocatable object to use is specified with the <samp>-e</samp> 96option. The default is the file <samp>a.out</samp>. The section in the relocatable 97object to use is specified with the <samp>-j</samp> option. 98</p> 99<p><code>addr2line</code> has two modes of operation. 100</p> 101<p>In the first, hexadecimal addresses are specified on the command line, 102and <code>addr2line</code> displays the file name and line number for each 103address. 104</p> 105<p>In the second, <code>addr2line</code> reads hexadecimal addresses from 106standard input, and prints the file name and line number for each 107address on standard output. In this mode, <code>addr2line</code> may be used 108in a pipe to convert dynamically chosen addresses. 109</p> 110<p>The format of the output is ‘<samp>FILENAME:LINENO</samp>’. By default 111each input address generates one line of output. 112</p> 113<p>Two options can generate additional lines before each 114‘<samp>FILENAME:LINENO</samp>’ line (in that order). 115</p> 116<p>If the <samp>-a</samp> option is used then a line with the input address 117is displayed. 118</p> 119<p>If the <samp>-f</samp> option is used, then a line with the 120‘<samp>FUNCTIONNAME</samp>’ is displayed. This is the name of the function 121containing the address. 122</p> 123<p>One option can generate additional lines after the 124‘<samp>FILENAME:LINENO</samp>’ line. 125</p> 126<p>If the <samp>-i</samp> option is used and the code at the given address is 127present there because of inlining by the compiler then additional 128lines are displayed afterwards. One or two extra lines (if the 129<samp>-f</samp> option is used) are displayed for each inlined function. 130</p> 131<p>Alternatively if the <samp>-p</samp> option is used then each input 132address generates a single, long, output line containing the address, 133the function name, the file name and the line number. If the 134<samp>-i</samp> option has also been used then any inlined functions will 135be displayed in the same manner, but on separate lines, and prefixed 136by the text ‘<samp>(inlined by)</samp>’. 137</p> 138<p>If the file name or function name can not be determined, 139<code>addr2line</code> will print two question marks in their place. If the 140line number can not be determined, <code>addr2line</code> will print 0. 141</p> 142 143 144<p>The long and short forms of options, shown here as alternatives, are 145equivalent. 146</p> 147<dl compact="compact"> 148<dt><code>-a</code></dt> 149<dt><code>--addresses</code></dt> 150<dd><p>Display the address before the function name, file and line number 151information. The address is printed with a ‘<samp>0x</samp>’ prefix to easily 152identify it. 153</p> 154</dd> 155<dt><code>-b <var>bfdname</var></code></dt> 156<dt><code>--target=<var>bfdname</var></code></dt> 157<dd><a name="index-object-code-format-4"></a> 158<p>Specify that the object-code format for the object files is 159<var>bfdname</var>. 160</p> 161</dd> 162<dt><code>-C</code></dt> 163<dt><code>--demangle[=<var>style</var>]</code></dt> 164<dd><a name="index-demangling-in-objdump-1"></a> 165<p>Decode (<em>demangle</em>) low-level symbol names into user-level names. 166Besides removing any initial underscore prepended by the system, this 167makes C++ function names readable. Different compilers have different 168mangling styles. The optional demangling style argument can be used to 169choose an appropriate demangling style for your compiler. See <a href="c_002b_002bfilt.html#c_002b_002bfilt">c++filt</a>, 170for more information on demangling. 171</p> 172</dd> 173<dt><code>-e <var>filename</var></code></dt> 174<dt><code>--exe=<var>filename</var></code></dt> 175<dd><p>Specify the name of the executable for which addresses should be 176translated. The default file is <samp>a.out</samp>. 177</p> 178</dd> 179<dt><code>-f</code></dt> 180<dt><code>--functions</code></dt> 181<dd><p>Display function names as well as file and line number information. 182</p> 183</dd> 184<dt><code>-s</code></dt> 185<dt><code>--basenames</code></dt> 186<dd><p>Display only the base of each file name. 187</p> 188</dd> 189<dt><code>-i</code></dt> 190<dt><code>--inlines</code></dt> 191<dd><p>If the address belongs to a function that was inlined, the source 192information for all enclosing scopes back to the first non-inlined 193function will also be printed. For example, if <code>main</code> inlines 194<code>callee1</code> which inlines <code>callee2</code>, and address is from 195<code>callee2</code>, the source information for <code>callee1</code> and <code>main</code> 196will also be printed. 197</p> 198</dd> 199<dt><code>-j</code></dt> 200<dt><code>--section</code></dt> 201<dd><p>Read offsets relative to the specified section instead of absolute addresses. 202</p> 203</dd> 204<dt><code>-p</code></dt> 205<dt><code>--pretty-print</code></dt> 206<dd><p>Make the output more human friendly: each location are printed on one line. 207If option <samp>-i</samp> is specified, lines for all enclosing scopes are 208prefixed with ‘<samp>(inlined by)</samp>’. 209</p> 210</dd> 211<dt><code>-r</code></dt> 212<dt><code>-R</code></dt> 213<dt><code>--recurse-limit</code></dt> 214<dt><code>--no-recurse-limit</code></dt> 215<dt><code>--recursion-limit</code></dt> 216<dt><code>--no-recursion-limit</code></dt> 217<dd><p>Enables or disables a limit on the amount of recursion performed 218whilst demangling strings. Since the name mangling formats allow for 219an infinite level of recursion it is possible to create strings whose 220decoding will exhaust the amount of stack space available on the host 221machine, triggering a memory fault. The limit tries to prevent this 222from happening by restricting recursion to 2048 levels of nesting. 223</p> 224<p>The default is for this limit to be enabled, but disabling it may be 225necessary in order to demangle truly complicated names. Note however 226that if the recursion limit is disabled then stack exhaustion is 227possible and any bug reports about such an event will be rejected. 228</p> 229<p>The <samp>-r</samp> option is a synonym for the 230<samp>--no-recurse-limit</samp> option. The <samp>-R</samp> option is a 231synonym for the <samp>--recurse-limit</samp> option. 232</p> 233<p>Note this option is only effective if the <samp>-C</samp> or 234<samp>--demangle</samp> option has been enabled. 235</p> 236</dd> 237</dl> 238 239 240 241<hr> 242<div class="header"> 243<p> 244Next: <a href="windmc.html#windmc" accesskey="n" rel="next">windmc</a>, Previous: <a href="c_002b_002bfilt.html#c_002b_002bfilt" accesskey="p" rel="previous">c++filt</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<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> 245</div> 246 247 248 249</body> 250</html> 251