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
commit62d67dc43a07f7ce8f9d4eac6a69d908def6b540 (patch)
treef25e727132308d870c68b1f9dcdf9c66588ef206 /binutils/addr2line.c
parent54f83b69049256b55c07b2e4a7c98f0e5f93df7f (diff)
downloadbinutils-redhat-62d67dc43a07f7ce8f9d4eac6a69d908def6b540.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 b4f48fc7fa..6464e37de0 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;