xref: /freebsd/contrib/elftoolchain/addr2line/addr2line.1 (revision 37a48d408f2b41e2c45952de3498a018b4d41b31)
1.\" Copyright (c) 2009,2010 Joseph Koshy <jkoshy@users.sourceforge.net>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer
9.\"    in this position and unchanged.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
15.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24.\"
25.\" $Id: addr2line.1 3195 2015-05-12 17:22:19Z emaste $
26.\"
27.Dd July 25, 2010
28.Os
29.Dt ADDR2LINE 1
30.Sh NAME
31.Nm addr2line
32.Nd translate program addresses to source file names and line numbers
33.Sh SYNOPSIS
34.Nm
35.Op Fl b Ar target | Fl -target Ns = Ns Ar target
36.Op Fl e Ar pathname | Fl -exe Ns = Ns Ar pathname
37.Op Fl f | Fl -functions
38.Op Fl j Ar sectionname | Fl -section Ns = Ns Ar sectionname
39.Op Fl s | Fl -basename
40.Op Fl C | Fl -demangle
41.Op Fl H | Fl -help
42.Op Fl V | Fl -version
43.Op Ar hexaddress Ns ...
44.Sh DESCRIPTION
45The
46.Nm
47utility translates program addresses specified by the command line
48arguments
49.Ar hexaddress
50to their corresponding source file names and line numbers.
51If no arguments are given to
52.Nm ,
53it will read these addresses from standard input.
54.Pp
55Program addresses specified by arguments
56.Ar hexaddress
57are encoded using the conventions accepted by
58.Xr strtoull 3 .
59.Pp
60By default,
61.Nm
62will use the executable
63.Dq Pa a.out .
64The
65.Fl e
66option may be used to specified a different ELF object.
67.Pp
68The
69.Nm
70utility recognizes the following options:
71.Bl -tag -width indent
72.It Fl b Ar target | Fl -target Ns = Ns Ar target
73This option is recognized by
74.Nm
75but is ignored.
76It is supported for compatibility with GNU binutils.
77.It Fl e Ar pathname | Fl -exe Ns = Ns Ar pathname
78Use the ELF object specified by argument
79.Ar pathname
80to translate addresses.
81If this option is not specified,
82.Nm
83will use the file
84.Dq Pa a.out .
85.It Fl f | Fl -functions
86Display function names in addition to file and line number information.
87.It Fl j Ar sectionname | Fl -section Ns = Ns Ar sectionname
88The values specified by arguments
89.Ar hexaddress
90are to be treated as offsets into the section named
91.Ar sectionname .
92.It Fl s | -basename
93Display only the base name for each file name.
94.It Fl C | Fl -demangle
95Demangle C++ names.
96.It Fl H | Fl -help
97Print a help message.
98.It Fl V | Fl -version
99Print a version identifier and exit.
100.El
101.Sh OUTPUT FORMAT
102If the
103.Fl f
104option was not specified,
105.Nm
106will print the file name and line number for each address specified
107on a separate line.
108.Pp
109If the
110.Fl f
111option was specified,
112.Nm
113will print a line containing the name of the function corresponding
114to program address
115.Ar hexaddress ,
116followed by a line with the file name and line number.
117.Pp
118The
119.Nm
120utility prints the file name and line number using the format
121.Dq FILENAME:LINENUMBER .
122.Pp
123If a file or function name could not be determined,
124.Nm
125will print a question mark in their place.
126If the line number could not be determined,
127.Nm
128will print a zero in its place.
129.Sh EXAMPLES
130To map address 080483c4 in the default executable
131.Pa a.out
132to a source file name and line number use:
133.D1 "% addr2line 080483c4"
134.Pp
135To map address 080483c4 in executable
136.Pa helloworld ,
137use:
138.D1 "% addr2line -e helloworld 080483c4"
139.Pp
140To have
141.Nm
142act as a filter reading addresses from its standard input use:
143.D1 "% addr2line"
144.Pp
145To print the function name corresponding to an address in addition to
146its source file and line number use:
147.D1 "% addr2line -f 080483c4"
148.Sh EXIT STATUS
149.Ex -std
150.Sh SEE ALSO
151.Xr nm 1 ,
152.Xr elfdump 1 ,
153.Xr elfcopy 1 ,
154.Xr strtoull 3
155.Sh AUTHORS
156The
157.Nm
158utility was written by
159.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
160