From be6f64938f985dfb0eaa2107b99f193bb865ce04 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 9 Dec 2009 12:58:23 +0000 Subject: 2009-12-09 Tristan Gingold * 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. --- binutils/addr2line.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'binutils/addr2line.c') 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\ @ Read options from \n\ + -a --addresses Show addresses\n\ -b --target= Set the binary file format\n\ -e --exe= 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; -- cgit v1.1