+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.
+
2005-05-23 Nick Clifton <nickc@redhat.com>
* readelf.c (fetch_indirect_string): Display a warning message
#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. */
{"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'},
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\
}
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
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)
case 'H':
usage (stdout, 0);
break;
+ case 'i':
+ unwind_inlines = TRUE;
+ break;
default:
usage (stderr, 1);
break;
[@option{-C}|@option{--demangle}[=@var{style}]]
[@option{-e} @var{filename}|@option{--exe=}@var{filename}]
[@option{-f}|@option{--functions}] [@option{-s}|@option{--basename}]
+ [@option{-i}|@option{--inlines}]
[@option{-H}|@option{--help}] [@option{-V}|@option{--version}]
[addr addr @dots{}]
@c man end
@item -s
@itemx --basenames
Display only the base of each file name.
+
+@item -i
+@itemx --inlines
+If the address belongs to a function that was inlined, the source
+information for all enclosing scopes back to the first non-inlined
+function will also be printed. For example, if @code{main} inlines
+@code{callee1} which inlines @code{callee2}, and address is from
+@code{callee2}, the source information for @code{callee1} and @code{main}
+will also be printed.
@end table
@c man end