From fb38844dcbec1b86f2d386da488e1d1e8bb57241 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 27 Mar 1997 21:35:00 +0000 Subject: [PATCH] addr2line.c contributed by Ulrich Lauther : * addr2line.c: New file. * Makefile.in: Rebuild dependencies. (ADDR2LINE_PROG): New variable. (MANPAGES): Add addr2line. (PROGS): Add $(ADDR2LINE_PROG). (CFILES): Add addr2line.c. ($(ADDR2LINE_PROG)): New target. * binutils.texi: Document addr2line. * addr2line.1: New file. --- binutils/.Sanitize | 2 + binutils/ChangeLog | 12 ++++ binutils/addr2line.1 | 127 +++++++++++++++++++++++++++++++++++++++++ binutils/binutils.texi | 80 ++++++++++++++++++++++++++ 4 files changed, 221 insertions(+) create mode 100644 binutils/addr2line.1 diff --git a/binutils/.Sanitize b/binutils/.Sanitize index db3ba8a94ff..2ff4c5388c6 100644 --- a/binutils/.Sanitize +++ b/binutils/.Sanitize @@ -30,6 +30,8 @@ README TODO acconfig.h aclocal.m4 +addr2line.1 +addr2line.c ar.1 ar.c arlex.l diff --git a/binutils/ChangeLog b/binutils/ChangeLog index d7678ce2423..393769a5240 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,5 +1,17 @@ Thu Mar 27 16:03:02 1997 Ian Lance Taylor + addr2line.c contributed by Ulrich Lauther + : + * addr2line.c: New file. + * Makefile.in: Rebuild dependencies. + (ADDR2LINE_PROG): New variable. + (MANPAGES): Add addr2line. + (PROGS): Add $(ADDR2LINE_PROG). + (CFILES): Add addr2line.c. + ($(ADDR2LINE_PROG)): New target. + * binutils.texi: Document addr2line. + * addr2line.1: New file. + * version.c (print_version): Update copyright date. Mon Mar 24 10:52:45 1997 Andreas Schwab diff --git a/binutils/addr2line.1 b/binutils/addr2line.1 new file mode 100644 index 00000000000..87ce103f8e3 --- /dev/null +++ b/binutils/addr2line.1 @@ -0,0 +1,127 @@ +.\" Copyright (c) 1997 Free Software Foundation +.\" See COPYING for conditions for redistribution +.TH addr2line 1 "27 March 1997" "Cygnus Solutions" "GNU Development Tools" +.de BP +.sp +.ti \-.2i +\(** +.. + +.SH NAME +addr2line \- convert addresses into file names and line numbers + +.SH SYNOPSIS +.hy 0 +.na +.TP +.B addr2line +.RB "[\|" "\-b\ "\c +.I bfdname\c +.RB " | " "\-\-target="\c +.I bfdname\c +\&\|] +.RB "[\|" \-C | \-\-demangle "\|]" +.RB "[\|" "\-e\ "\c +.I filename\c +.RB " | " "\-\-exe="\c +.I filename\c +\&\|] +.RB "[\|" \-f | \-\-functions "\|]" +.RB "[\|" \-s | \-\-basenames "\|]" +.RB "[\|" \-H | \-\-help "\|]" +.RB "[\|" \-V | \-\-version "\|]" +.RB "[\|" addr addr ... "\|]" +.ad b +.hy 1 +.SH DESCRIPTION +\c +.B addr2line +translates program addresses into file names and line numbers. Given +an address and an executable, it uses the debugging information in the +executable to figure out which file name and line number are +associated with a given address. + +The executable to use is specified with the +.B \-e +option. The default is +.B a.out\c +\&. + +.B addr2line +has two modes of operation. + +In the first, hexadecimal addresses are specified on the command line, +and +.B addr2line +displays the file name and line number for each address. + +In the second, +.B addr2line +reads hexadecimal addresses from standard input, and prints the file +name and line number for each address on standard output. In this +mode, +.B addr2line +may be used in a pipe to convert dynamically chosen addresses. + +The format of the output is FILENAME:LINENO. The file name and line +number for each address is printed on a separate line. If the +.B \-f +option is used, then each FILENAME:LINENO line is preceded by a +FUNCTIONNAME line which is the name of the function containing the +address. + +If the file name or function name can not be determined, +.B addr2line +will print two question marks in their place. If the line number can +not be determined, +.B addr2line +will print 0. + +.SH OPTIONS +.TP +.BI "\-b " "bfdname"\c +.TP +.BI "\-\-target=" "bfdname" +Specify the object-code format for the object files to be +\c +.I bfdname\c +\&. + +.TP +.B \-C +.TP +.B \-\-demangle +Decode (\fIdemangle\fP) low-level symbol names into user-level names. +Besides removing any initial underscore prepended by the system, this +makes C++ function names readable. + +.TP +.BI "\-e " "filename"\c +.TP +.BI "\-\-exe=" "filename" +Specify the name of the executable for which addresses should be +translated. The default file is +.B a.out\c +\&. + +.TP +.B \-f +.TP +.B \-\-functions +Display function names as well as file and line number information. + +.TP +.B \-s +.TP +.B \-\-basenames +Display only the base of each file name. + +.SH "SEE ALSO" +.RB "`\|" binutils "\|'" +entry in +.B +info\c +\&; +.I +The GNU Binary Utilities\c +\&, Roland H. Pesch (October 1991). diff --git a/binutils/binutils.texi b/binutils/binutils.texi index 7b7c8c62fd4..d0ec85d255a 100644 --- a/binutils/binutils.texi +++ b/binutils/binutils.texi @@ -117,6 +117,9 @@ Discard symbols @item c++filt Demangle encoded C++ symbols +@item addr2line +Convert addresses into file names and line numbers + @item nlmconv Convert object code into a Netware Loadable Module @end table @@ -132,6 +135,7 @@ Convert object code into a Netware Loadable Module * strings:: List printable strings from files * strip:: Discard symbols * c++filt:: Filter to demangle encoded C++ symbols +* addr2line:: Convert addresses to file and line * nlmconv:: Converts object code into an NLM * Selecting The Target System:: How these utilities determine the target. * Reporting Bugs:: Reporting Bugs @@ -1675,6 +1679,82 @@ c++filt @var{option} @var{symbol} @end example @end quotation +@node addr2line +@chapter addr2line + +@kindex addr2line +@cindex address to file name and line number + +@smallexample +addr2line [ -b @var{bfdname} | --target=@var{bfdname} ] + [ -C | --demangle ] + [ -e @var{filename} | --exe=@var{filename} ] + [ -f | --functions ] [ -s | --basename ] + [ -H | --help ] [ -V | --version ] + [ addr addr ... ] +@end smallexample + +@code{addr2line} translates program addresses into file names and line +numbers. Given an address and an executable, it uses the debugging +information in the executable to figure out which file name and line +number are associated with a given address. + +The executable to use is specified with the @code{-e} option. The +default is @file{a.out}. + +@code{addr2line} has two modes of operation. + +In the first, hexadecimal addresses are specified on the command line, +and @code{addr2line} displays the file name and line number for each +address. + +In the second, @code{addr2line} reads hexadecimal addresses from +standard input, and prints the file name and line number for each +address on standard output. In this mode, @code{addr2line} may be used +in a pipe to convert dynamically chosen addresses. + +The format of the output is @samp{FILENAME:LINENO}. The file name and +line number for each address is printed on a separate line. If the +@code{-f} option is used, then each @samp{FILENAME:LINENO} line is +preceded by a @samp{FUNCTIONNAME} line which is the name of the function +containing the address. + +If the file name or function name can not be determined, +@code{addr2line} will print two question marks in their place. If the +line number can not be determined, @code{addr2line} will print 0. + +The long and short forms of options, shown here as alternatives, are +equivalent. + +@table @code +@item -b @var{bfdname} +@itemx --target=@var{bfdname} +@cindex object code format +Specify that the object-code format for the object files is +@var{bfdname}. + +@item -C +@itemx --demangle +@cindex demangling in objdump +Decode (@dfn{demangle}) low-level symbol names into user-level names. +Besides removing any initial underscore prepended by the system, this +makes C++ function names readable. @xref{c++filt}, for more information +on demangling. + +@item -e @var{filename} +@itemx --exe=@var{filename} +Specify the name of the executable for which addresses should be +translated. The default file is @file{a.out}. + +@item -f +@itemx --functions +Display function names as well as file and line number information. + +@item -s +@itemx --basenames +Display only the base of each file name. +@end table + @node nlmconv @chapter nlmconv -- 2.30.2