diff options
author | Tristan Gingold <gingold@adacore.com> | 2009-12-09 12:58:23 +0000 |
---|---|---|
committer | Tristan Gingold <gingold@adacore.com> | 2009-12-09 12:58:23 +0000 |
commit | be6f64938f985dfb0eaa2107b99f193bb865ce04 (patch) | |
tree | 1f2ff18a44815e86c2d546f1b0e81cf63205590e | |
parent | 03b952fddad1179c316bb9230f696034e6ae3bef (diff) | |
download | gdb-be6f64938f985dfb0eaa2107b99f193bb865ce04.zip gdb-be6f64938f985dfb0eaa2107b99f193bb865ce04.tar.gz gdb-be6f64938f985dfb0eaa2107b99f193bb865ce04.tar.bz2 |
2009-12-09 Tristan Gingold <gingold@adacore.com>
* addr2line.c (translate_addresses): Display addresses
if option -a is used.
(with_addresses): New variable.
(long_options): Add option '-a'.
(usage): Add usage for option '-a'.
(main): Handle option '-a'.
* doc/binutils.texi (addr2line): Document option '-a'.
* NEWS: Mention new feature.
-rw-r--r-- | binutils/ChangeLog | 11 | ||||
-rw-r--r-- | binutils/NEWS | 3 | ||||
-rw-r--r-- | binutils/addr2line.c | 15 | ||||
-rw-r--r-- | binutils/doc/binutils.texi | 12 |
4 files changed, 38 insertions, 3 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index ee7effe..e3aef7d 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,14 @@ +2009-12-09 Tristan Gingold <gingold@adacore.com> + + * addr2line.c (translate_addresses): Display addresses + if option -a is used. + (with_addresses): New variable. + (long_options): Add option '-a'. + (usage): Add usage for option '-a'. + (main): Handle option '-a'. + * doc/binutils.texi (addr2line): Document option '-a'. + * NEWS: Mention new feature. + 2009-12-08 Cary Coutant <ccoutant@google.com> * dwarf.c (dwarf_select_sections_by_names): Handle pubtypes correctly. diff --git a/binutils/NEWS b/binutils/NEWS index 3edee4b..25fee15 100644 --- a/binutils/NEWS +++ b/binutils/NEWS @@ -3,6 +3,9 @@ * Add to dlltool .def file feature of aliasing PE internal symbol name by '== <ID>' option. +* Add a new command line option -a / --addresses to addr2line to display the + address before function name or source filename. + Changes in 2.20: * Add support for delay importing to dlltool. Use the --output-delaylib <file> diff --git a/binutils/addr2line.c b/binutils/addr2line.c index 1872521..2ecdbfa 100644 --- a/binutils/addr2line.c +++ b/binutils/addr2line.c @@ -39,6 +39,7 @@ #include "bucomm.h" static bfd_boolean unwind_inlines; /* -i, unwind inlined functions. */ +static bfd_boolean with_addresses; /* -a, show addresses. */ static bfd_boolean with_functions; /* -f, show function names. */ static bfd_boolean do_demangle; /* -C, demangle names. */ static bfd_boolean base_names; /* -s, strip directory names. */ @@ -50,6 +51,7 @@ static asymbol **syms; /* Symbol table. */ static struct option long_options[] = { + {"addresses", no_argument, NULL, 'a'}, {"basenames", no_argument, NULL, 's'}, {"demangle", optional_argument, NULL, 'C'}, {"exe", required_argument, NULL, 'e'}, @@ -78,6 +80,7 @@ usage (FILE *stream, int status) fprintf (stream, _(" If no addresses are specified on the command line, they will be read from stdin\n")); fprintf (stream, _(" The options are:\n\ @<file> Read options from <file>\n\ + -a --addresses Show addresses\n\ -b --target=<bfdname> Set the binary file format\n\ -e --exe=<executable> Set the input file name (default is a.out)\n\ -i --inlines Unwind inlined functions\n\ @@ -209,6 +212,13 @@ translate_addresses (bfd *abfd, asection *section) pc = bfd_scan_vma (*addr++, NULL, 16); } + if (with_addresses) + { + printf ("0x"); + bfd_printf_vma (abfd, pc); + printf ("\n"); + } + found = FALSE; if (section) find_offset_in_section (abfd, section); @@ -354,13 +364,16 @@ main (int argc, char **argv) file_name = NULL; section_name = NULL; target = NULL; - while ((c = getopt_long (argc, argv, "b:Ce:sfHhij:Vv", long_options, (int *) 0)) + while ((c = getopt_long (argc, argv, "ab:Ce:sfHhij:Vv", long_options, (int *) 0)) != EOF) { switch (c) { case 0: break; /* We've been given a long option. */ + case 'a': + with_addresses = TRUE; + break; case 'b': target = optarg; break; diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index 77a8774..a96ecac 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -2906,7 +2906,8 @@ c++filt @var{option} @var{symbol} @smallexample @c man begin SYNOPSIS addr2line -addr2line [@option{-b} @var{bfdname}|@option{--target=}@var{bfdname}] +addr2line [@option{-a}|@option{--addresses}] + [@option{-b} @var{bfdname}|@option{--target=}@var{bfdname}] [@option{-C}|@option{--demangle}[=@var{style}]] [@option{-e} @var{filename}|@option{--exe=}@var{filename}] [@option{-f}|@option{--functions}] [@option{-s}|@option{--basename}] @@ -2943,7 +2944,8 @@ 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 @command{-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. +containing the address. If the @command{-a} option is used, then the +address read is first printed. If the file name or function name can not be determined, @command{addr2line} will print two question marks in their place. If the @@ -2957,6 +2959,12 @@ The long and short forms of options, shown here as alternatives, are equivalent. @table @env +@item -a +@itemx --addresses +Display address before function names or file and line number +information. The address is printed with a @samp{0x} prefix to easily +identify it. + @item -b @var{bfdname} @itemx --target=@var{bfdname} @cindex object code format |