summaryrefslogtreecommitdiff
path: root/binutils/addr2line.c
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>2005-05-23 17:45:42 +0000
committerFred Fish <fnf@specifix.com>2005-05-23 17:45:42 +0000
commit0c552dc1882e1b7cfe81f27117631f04a92381bb (patch)
tree84fc300030057647d6be61bf1586861946ef67fb /binutils/addr2line.c
parent4ab527b0538fcb65673a93dc775c39a2e7ccb6d7 (diff)
downloadbinutils-gdb-0c552dc1882e1b7cfe81f27117631f04a92381bb.tar.gz
Approved by nickc@redhat.com:
2005-05-23 Fred Fish <fnf@specifixinc.com> * addr2line.c (unwind_inlines): New flag for 'i' option. (usage): Document '-i' option. (long_options): Recognize '--inlines'. (translate_addresses): Loop, calling bfd_find_inliner_info as necessary and printing multiple output lines. (main): Handle 'i' option. * doc/binutils.texi (addr2line): Document '-i' option. * NEWS: Mention new addr2line '-i' option.
Diffstat (limited to 'binutils/addr2line.c')
-rw-r--r--binutils/addr2line.c73
1 files changed, 43 insertions, 30 deletions
diff --git a/binutils/addr2line.c b/binutils/addr2line.c
index b4f48fc7fa7..6464e37de0d 100644
--- a/binutils/addr2line.c
+++ b/binutils/addr2line.c
@@ -39,6 +39,7 @@
#include "bucomm.h"
#include "budemang.h"
+static bfd_boolean unwind_inlines; /* -i, unwind inlined functions. */
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. */
@@ -54,6 +55,7 @@ static struct option long_options[] =
{"demangle", optional_argument, NULL, 'C'},
{"exe", required_argument, NULL, 'e'},
{"functions", no_argument, NULL, 'f'},
+ {"inlines", no_argument, NULL, 'i'},
{"target", required_argument, NULL, 'b'},
{"help", no_argument, NULL, 'H'},
{"version", no_argument, NULL, 'V'},
@@ -77,6 +79,7 @@ usage (FILE *stream, int status)
fprintf (stream, _(" The options are:\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\
-s --basenames Strip directory names\n\
-f --functions Show function names\n\
-C --demangle[=style] Demangle function names\n\
@@ -183,36 +186,43 @@ translate_addresses (bfd *abfd)
}
else
{
- if (with_functions)
- {
- const char *name;
- char *alloc = NULL;
-
- name = functionname;
- if (name == NULL || *name == '\0')
- name = "??";
- else if (do_demangle)
- {
- alloc = demangle (abfd, name);
- 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;
- }
+ do {
+ if (with_functions)
+ {
+ const char *name;
+ char *alloc = NULL;
+
+ name = functionname;
+ if (name == NULL || *name == '\0')
+ name = "??";
+ else if (do_demangle)
+ {
+ alloc = demangle (abfd, name);
+ 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);
- printf ("%s:%u\n", filename ? filename : "??", line);
}
/* fflush() is essential for using this command as a server
@@ -291,7 +301,7 @@ main (int argc, char **argv)
file_name = NULL;
target = NULL;
- while ((c = getopt_long (argc, argv, "b:Ce:sfHhVv", long_options, (int *) 0))
+ while ((c = getopt_long (argc, argv, "b:Ce:sfHhiVv", long_options, (int *) 0))
!= EOF)
{
switch (c)
@@ -332,6 +342,9 @@ main (int argc, char **argv)
case 'H':
usage (stdout, 0);
break;
+ case 'i':
+ unwind_inlines = TRUE;
+ break;
default:
usage (stderr, 1);
break;