* addr2line.c (pretty_print): New variable.
(long_options): Add an entry for -p/--pretty-print.
(usage): Document -p/--pretty-print.
(translate_addresses): Handle pretty_print. Reindent.
(main): Handle option -p.
* doc/binutils.texi (addr2line): Document -p/--pretty-print.
* NEWS: Mention new feature.
+2009-12-10 Tristan Gingold <gingold@adacore.com>
+
+ * addr2line.c (pretty_print): New variable.
+ (long_options): Add an entry for -p/--pretty-print.
+ (usage): Document -p/--pretty-print.
+ (translate_addresses): Handle pretty_print. Reindent.
+ (main): Handle option -p.
+ * doc/binutils.texi (addr2line): Document -p/--pretty-print.
+ * NEWS: Mention new feature.
+
2009-12-09 Tristan Gingold <gingold@adacore.com>
* addr2line.c (translate_addresses): Display addresses
2009-12-09 Tristan Gingold <gingold@adacore.com>
* addr2line.c (translate_addresses): Display addresses
* Add a new command line option -a / --addresses to addr2line to display the
address before function name or source filename.
* Add a new command line option -a / --addresses to addr2line to display the
address before function name or source filename.
+* Add a new command line option -p / --pretty-print to addr2line to have
+ a more human readable output.
+
Changes in 2.20:
* Add support for delay importing to dlltool. Use the --output-delaylib <file>
Changes in 2.20:
* Add support for delay importing to dlltool. Use the --output-delaylib <file>
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 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 pretty_print; /* -p, print on one line. */
static bfd_boolean base_names; /* -s, strip directory names. */
static int naddr; /* Number of addresses to process. */
static bfd_boolean base_names; /* -s, strip directory names. */
static int naddr; /* Number of addresses to process. */
{"exe", required_argument, NULL, 'e'},
{"functions", no_argument, NULL, 'f'},
{"inlines", no_argument, NULL, 'i'},
{"exe", required_argument, NULL, 'e'},
{"functions", no_argument, NULL, 'f'},
{"inlines", no_argument, NULL, 'i'},
+ {"pretty-print", no_argument, NULL, 'p'},
{"section", required_argument, NULL, 'j'},
{"target", required_argument, NULL, 'b'},
{"help", no_argument, NULL, 'H'},
{"section", required_argument, NULL, 'j'},
{"target", required_argument, NULL, 'b'},
{"help", no_argument, NULL, 'H'},
-e --exe=<executable> Set the input file name (default is a.out)\n\
-i --inlines Unwind inlined functions\n\
-j --section=<name> Read section-relative offsets instead of addresses\n\
-e --exe=<executable> Set the input file name (default is a.out)\n\
-i --inlines Unwind inlined functions\n\
-j --section=<name> Read section-relative offsets instead of addresses\n\
+ -p --pretty-print Make the output easier to read for humans\n\
-s --basenames Strip directory names\n\
-f --functions Show function names\n\
-C --demangle[=style] Demangle function names\n\
-s --basenames Strip directory names\n\
-f --functions Show function names\n\
-C --demangle[=style] Demangle function names\n\
{
printf ("0x");
bfd_printf_vma (abfd, pc);
{
printf ("0x");
bfd_printf_vma (abfd, pc);
+
+ if (pretty_print)
+ printf (": ");
+ else
+ printf ("\n");
- do {
- if (with_functions)
- {
- const char *name;
- char *alloc = NULL;
-
- name = functionname;
- if (name == NULL || *name == '\0')
- name = "??";
- else if (do_demangle)
- {
- alloc = bfd_demangle (abfd, name, DMGL_ANSI | DMGL_PARAMS);
- if (alloc != NULL)
- name = alloc;
- }
-
- printf ("%s\n", name);
-
- if (alloc != NULL)
- free (alloc);
- }
-
- if (base_names && filename != NULL)
- {
- char *h;
-
- h = strrchr (filename, '/');
- if (h != NULL)
- filename = h + 1;
- }
-
- printf ("%s:%u\n", filename ? filename : "??", line);
- if (!unwind_inlines)
- found = FALSE;
- else
- found = bfd_find_inliner_info (abfd, &filename, &functionname, &line);
- } while (found);
-
+ while (1)
+ {
+ if (with_functions)
+ {
+ const char *name;
+ char *alloc = NULL;
+
+ name = functionname;
+ if (name == NULL || *name == '\0')
+ name = "??";
+ else if (do_demangle)
+ {
+ alloc = bfd_demangle (abfd, name, DMGL_ANSI | DMGL_PARAMS);
+ if (alloc != NULL)
+ name = alloc;
+ }
+
+ printf ("%s", name);
+ if (pretty_print)
+ printf (_(" at "));
+ else
+ printf ("\n");
+
+ if (alloc != NULL)
+ free (alloc);
+ }
+
+ if (base_names && filename != NULL)
+ {
+ char *h;
+
+ h = strrchr (filename, '/');
+ if (h != NULL)
+ filename = h + 1;
+ }
+
+ printf ("%s:%u\n", filename ? filename : "??", line);
+ if (!unwind_inlines)
+ found = FALSE;
+ else
+ found = bfd_find_inliner_info (abfd, &filename, &functionname, &line);
+ if (! found)
+ break;
+ if (pretty_print)
+ printf (_(" (inlined by) "));
+ }
}
/* fflush() is essential for using this command as a server
}
/* fflush() is essential for using this command as a server
file_name = NULL;
section_name = NULL;
target = NULL;
file_name = NULL;
section_name = NULL;
target = NULL;
- while ((c = getopt_long (argc, argv, "ab:Ce:sfHhij:Vv", long_options, (int *) 0))
+ while ((c = getopt_long (argc, argv, "ab:Ce:sfHhij:pVv", long_options, (int *) 0))
case 'f':
with_functions = TRUE;
break;
case 'f':
with_functions = TRUE;
break;
+ case 'p':
+ pretty_print = TRUE;
+ break;
case 'v':
case 'V':
print_version ("addr2line");
case 'v':
case 'V':
print_version ("addr2line");
[@option{-e} @var{filename}|@option{--exe=}@var{filename}]
[@option{-f}|@option{--functions}] [@option{-s}|@option{--basename}]
[@option{-i}|@option{--inlines}]
[@option{-e} @var{filename}|@option{--exe=}@var{filename}]
[@option{-f}|@option{--functions}] [@option{-s}|@option{--basename}]
[@option{-i}|@option{--inlines}]
+ [@option{-p}|@option{--pretty-print}]
[@option{-j}|@option{--section=}@var{name}]
[@option{-H}|@option{--help}] [@option{-V}|@option{--version}]
[addr addr @dots{}]
[@option{-j}|@option{--section=}@var{name}]
[@option{-H}|@option{--help}] [@option{-V}|@option{--version}]
[addr addr @dots{}]
@item -j
@itemx --section
Read offsets relative to the specified section instead of absolute addresses.
@item -j
@itemx --section
Read offsets relative to the specified section instead of absolute addresses.
+
+@item -p
+@itemx --pretty-print
+Make the output more human friendly: each location are printed on one line.
+If option @option{-i} is specified, lines for all enclosing scopes are
+prefixed with @samp{(inlined by)}.