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.
This commit is contained in:
Tristan Gingold
2009-12-09 12:58:23 +00:00
parent 03b952fdda
commit be6f64938f
4 changed files with 38 additions and 3 deletions

View File

@@ -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.

View File

@@ -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>

View File

@@ -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;

View File

@@ -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