mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 03:51:15 +08:00
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.
This commit is contained in:
parent
e7e2196da3
commit
68cdf72f1e
@ -1,3 +1,13 @@
|
|||||||
|
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>
|
2009-12-09 Tristan Gingold <gingold@adacore.com>
|
||||||
|
|
||||||
* addr2line.c (translate_addresses): Display addresses
|
* addr2line.c (translate_addresses): Display addresses
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
* Add a new command line option -a / --addresses to addr2line to display the
|
* Add a new command line option -a / --addresses to addr2line to display the
|
||||||
address before function name or source filename.
|
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:
|
Changes in 2.20:
|
||||||
|
|
||||||
* Add support for delay importing to dlltool. Use the --output-delaylib <file>
|
* Add support for delay importing to dlltool. Use the --output-delaylib <file>
|
||||||
|
@ -42,6 +42,7 @@ static bfd_boolean unwind_inlines; /* -i, unwind inlined functions. */
|
|||||||
static bfd_boolean with_addresses; /* -a, show addresses. */
|
static bfd_boolean with_addresses; /* -a, show addresses. */
|
||||||
static bfd_boolean with_functions; /* -f, show function names. */
|
static bfd_boolean with_functions; /* -f, show function names. */
|
||||||
static bfd_boolean do_demangle; /* -C, demangle 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 bfd_boolean base_names; /* -s, strip directory names. */
|
||||||
|
|
||||||
static int naddr; /* Number of addresses to process. */
|
static int naddr; /* Number of addresses to process. */
|
||||||
@ -57,6 +58,7 @@ static struct option long_options[] =
|
|||||||
{"exe", required_argument, NULL, 'e'},
|
{"exe", required_argument, NULL, 'e'},
|
||||||
{"functions", no_argument, NULL, 'f'},
|
{"functions", no_argument, NULL, 'f'},
|
||||||
{"inlines", no_argument, NULL, 'i'},
|
{"inlines", no_argument, NULL, 'i'},
|
||||||
|
{"pretty-print", no_argument, NULL, 'p'},
|
||||||
{"section", required_argument, NULL, 'j'},
|
{"section", required_argument, NULL, 'j'},
|
||||||
{"target", required_argument, NULL, 'b'},
|
{"target", required_argument, NULL, 'b'},
|
||||||
{"help", no_argument, NULL, 'H'},
|
{"help", no_argument, NULL, 'H'},
|
||||||
@ -85,6 +87,7 @@ usage (FILE *stream, int status)
|
|||||||
-e --exe=<executable> Set the input file name (default is a.out)\n\
|
-e --exe=<executable> Set the input file name (default is a.out)\n\
|
||||||
-i --inlines Unwind inlined functions\n\
|
-i --inlines Unwind inlined functions\n\
|
||||||
-j --section=<name> Read section-relative offsets instead of addresses\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\
|
-s --basenames Strip directory names\n\
|
||||||
-f --functions Show function names\n\
|
-f --functions Show function names\n\
|
||||||
-C --demangle[=style] Demangle function names\n\
|
-C --demangle[=style] Demangle function names\n\
|
||||||
@ -216,7 +219,11 @@ translate_addresses (bfd *abfd, asection *section)
|
|||||||
{
|
{
|
||||||
printf ("0x");
|
printf ("0x");
|
||||||
bfd_printf_vma (abfd, pc);
|
bfd_printf_vma (abfd, pc);
|
||||||
printf ("\n");
|
|
||||||
|
if (pretty_print)
|
||||||
|
printf (": ");
|
||||||
|
else
|
||||||
|
printf ("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
found = FALSE;
|
found = FALSE;
|
||||||
@ -233,44 +240,52 @@ translate_addresses (bfd *abfd, asection *section)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
do {
|
while (1)
|
||||||
if (with_functions)
|
{
|
||||||
{
|
if (with_functions)
|
||||||
const char *name;
|
{
|
||||||
char *alloc = NULL;
|
const char *name;
|
||||||
|
char *alloc = NULL;
|
||||||
|
|
||||||
name = functionname;
|
name = functionname;
|
||||||
if (name == NULL || *name == '\0')
|
if (name == NULL || *name == '\0')
|
||||||
name = "??";
|
name = "??";
|
||||||
else if (do_demangle)
|
else if (do_demangle)
|
||||||
{
|
{
|
||||||
alloc = bfd_demangle (abfd, name, DMGL_ANSI | DMGL_PARAMS);
|
alloc = bfd_demangle (abfd, name, DMGL_ANSI | DMGL_PARAMS);
|
||||||
if (alloc != NULL)
|
if (alloc != NULL)
|
||||||
name = alloc;
|
name = alloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("%s\n", name);
|
printf ("%s", name);
|
||||||
|
if (pretty_print)
|
||||||
|
printf (_(" at "));
|
||||||
|
else
|
||||||
|
printf ("\n");
|
||||||
|
|
||||||
if (alloc != NULL)
|
if (alloc != NULL)
|
||||||
free (alloc);
|
free (alloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base_names && filename != NULL)
|
if (base_names && filename != NULL)
|
||||||
{
|
{
|
||||||
char *h;
|
char *h;
|
||||||
|
|
||||||
h = strrchr (filename, '/');
|
h = strrchr (filename, '/');
|
||||||
if (h != NULL)
|
if (h != NULL)
|
||||||
filename = h + 1;
|
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);
|
|
||||||
|
|
||||||
|
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
|
||||||
@ -364,7 +379,7 @@ main (int argc, char **argv)
|
|||||||
file_name = NULL;
|
file_name = NULL;
|
||||||
section_name = NULL;
|
section_name = NULL;
|
||||||
target = 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))
|
||||||
!= EOF)
|
!= EOF)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
@ -400,6 +415,9 @@ main (int argc, char **argv)
|
|||||||
case 'f':
|
case 'f':
|
||||||
with_functions = TRUE;
|
with_functions = TRUE;
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
pretty_print = TRUE;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
case 'V':
|
case 'V':
|
||||||
print_version ("addr2line");
|
print_version ("addr2line");
|
||||||
|
@ -2912,6 +2912,7 @@ addr2line [@option{-a}|@option{--addresses}]
|
|||||||
[@option{-e} @var{filename}|@option{--exe=}@var{filename}]
|
[@option{-e} @var{filename}|@option{--exe=}@var{filename}]
|
||||||
[@option{-f}|@option{--functions}] [@option{-s}|@option{--basename}]
|
[@option{-f}|@option{--functions}] [@option{-s}|@option{--basename}]
|
||||||
[@option{-i}|@option{--inlines}]
|
[@option{-i}|@option{--inlines}]
|
||||||
|
[@option{-p}|@option{--pretty-print}]
|
||||||
[@option{-j}|@option{--section=}@var{name}]
|
[@option{-j}|@option{--section=}@var{name}]
|
||||||
[@option{-H}|@option{--help}] [@option{-V}|@option{--version}]
|
[@option{-H}|@option{--help}] [@option{-V}|@option{--version}]
|
||||||
[addr addr @dots{}]
|
[addr addr @dots{}]
|
||||||
@ -3006,6 +3007,12 @@ will also be printed.
|
|||||||
@item -j
|
@item -j
|
||||||
@itemx --section
|
@itemx --section
|
||||||
Read offsets relative to the specified section instead of absolute addresses.
|
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)}.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@c man end
|
@c man end
|
||||||
|
Loading…
Reference in New Issue
Block a user