/* Values for the parameters which have no short form. */
#define OPT_DEMANGLER 0x100
+#define OPT_PRETTY 0x101 /* 'p' is already used to select the process. */
/* Definitions of arguments for argp functions. */
static const struct argp_option options[] =
0 },
{ "demangle", 'C', "ARG", OPTION_ARG_OPTIONAL,
N_("Show demangled symbols (ARG is always ignored)"), 0 },
+ { "pretty-print", OPT_PRETTY, NULL, 0,
+ N_("Print all information on one line, and indent inlines"), 0 },
{ NULL, 0, NULL, 0, N_("Miscellaneous:"), 0 },
/* Unsupported options. */
/* True if all names need to be demangled. */
static bool demangle;
+/* True if all information should be printed on one line. */
+static bool pretty;
+
#ifdef USE_DEMANGLE
static size_t demangle_buffer_len = 0;
static char *demangle_buffer = NULL;
show_inlines = true;
break;
+ case OPT_PRETTY:
+ pretty = true;
+ break;
+
default:
return ARGP_ERR_UNKNOWN;
}
const char *name = get_diename (&scopes[i]);
if (name == NULL)
return false;
- puts (symname (name));
+ printf ("%s%c", symname (name), pretty ? ' ' : '\n');
return true;
}
const char *name = get_diename (&scopes[i]);
if (name == NULL)
return false;
- printf ("%s inlined", symname (name));
+
+ /* When using --pretty-print we only show inlines on their
+ own line. Just print the first subroutine name. */
+ if (pretty)
+ {
+ printf ("%s ", symname (name));
+ return true;
+ }
+ else
+ printf ("%s inlined", symname (name));
Dwarf_Files *files;
if (dwarf_getsrcfiles (cudie, &files, NULL) == 0)
if (i >= 0)
name = dwfl_module_relocation_info (mod, i, NULL);
if (name == NULL)
- puts ("??");
+ printf ("??%c", pretty ? ' ': '\n');
else
- printf ("(%s)+%#" PRIx64 "\n", name, addr);
+ printf ("(%s)+%#" PRIx64 "%c", name, addr, pretty ? ' ' : '\n');
}
else
{
}
}
}
- puts ("");
+ printf ("%c", pretty ? ' ' : '\n');
}
}
if (print_addresses)
{
int width = get_addr_width (mod);
- printf ("0x%.*" PRIx64 "\n", width, addr);
+ printf ("0x%.*" PRIx64 "%s", width, addr, pretty ? ": " : "\n");
}
if (show_functions)
if (! print_dwarf_function (mod, addr) && !show_symbols)
{
const char *name = dwfl_module_addrname (mod, addr);
- if (name != NULL)
- puts (symname (name));
- else
- puts ("??");
+ name = name != NULL ? symname (name) : "??";
+ printf ("%s%c", name, pretty ? ' ' : '\n');
}
}
if (show_symbols)
print_addrsym (mod, addr);
+ if ((show_functions || show_symbols) && pretty)
+ printf ("at ");
+
Dwfl_Line *line = dwfl_module_getsrc (mod, addr);
const char *src;
if (dwarf_tag (die) != DW_TAG_inlined_subroutine)
continue;
+ if (pretty)
+ printf (" (inlined by) ");
+
if (show_functions)
{
/* Search for the parent inline or function. It
|| tag == DW_TAG_entry_point
|| tag == DW_TAG_subprogram)
{
- puts (symname (get_diename (parent)));
+ printf ("%s%s",
+ symname (get_diename (parent)),
+ pretty ? " at " : "\n");
break;
}
}
/tmp/x.cpp:33
EOF
+# All together now (plus function names and addresses and pretty)
+testrun_compare ${abs_top_builddir}/src/addr2line --pretty-print -a -f -i -e testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f0 0x00000000000005f1 0x00000000000005f2 <<\EOF
+0x00000000000005a0: foobar at /tmp/x.cpp:5
+0x00000000000005a1: foobar at /tmp/x.cpp:6
+0x00000000000005b0: fubar at /tmp/x.cpp:10
+0x00000000000005b1: fubar at /tmp/x.cpp:11
+0x00000000000005c0: foobar at /tmp/x.cpp:5
+ (inlined by) bar at /tmp/x.cpp:15
+0x00000000000005d0: fubar at /tmp/x.cpp:10
+ (inlined by) baz at /tmp/x.cpp:20
+0x00000000000005e0: foobar at /tmp/x.cpp:5
+ (inlined by) bar at /tmp/x.cpp:15
+ (inlined by) _Z3foov at /tmp/x.cpp:25
+0x00000000000005e1: fubar at /tmp/x.cpp:10
+ (inlined by) baz at /tmp/x.cpp:20
+ (inlined by) _Z3foov at /tmp/x.cpp:26
+0x00000000000005f0: _Z2fuv at /tmp/x.cpp:31
+0x00000000000005f1: fubar at /tmp/x.cpp:10
+ (inlined by) _Z2fuv at /tmp/x.cpp:32
+0x00000000000005f2: foobar at /tmp/x.cpp:5
+ (inlined by) _Z2fuv at /tmp/x.cpp:33
+EOF
+
exit 0