On Wed, 30 Oct 2013 15:47:06 +0100, Mark Wielaard wrote:
I do want as much information as we can give. But IMHO the default
should be as basic as possible. Lets do introduce a -v flag (or some
others for symbol name demangling, module names, source/line, function
arguments, etc.). But not right now. Lets first get the basic
functionality in. I am very eager to finally see this committed!
Modifying the default output in released package is not good.
So introduced the "-v" flag now.
> + printf ("#%-2u 0x%0*" PRIx64 "%4s\t%s\n",
(*framenop)++, width, (uint64_t) pc,
> ! isactivation ? "- 1" : "", symname);
Could we replace the \t with a simple space?
Now that the output lines are all of equal width a space is enough IMHO.
Done.
Thanks,
Jan
diff --git a/src/stack.c b/src/stack.c
index 3b8a908..948325d 100644
--- a/src/stack.c
+++ b/src/stack.c
@@ -27,6 +27,8 @@
#include <fcntl.h>
#include ELFUTILS_HEADER(dwfl)
+static bool verbose = false;
+
static int
frame_callback (Dwfl_Frame *state, void *arg)
{
@@ -64,8 +66,10 @@ frame_callback (Dwfl_Frame *state, void *arg)
if (width == 0)
width = 16;
- printf ("#%-2u 0x%0*" PRIx64 "%4s\t%s\n", (*framenop)++, width,
(uint64_t) pc,
- ! isactivation ? "- 1" : "", symname);
+ printf ("#%-2u 0x%0*" PRIx64, (*framenop)++, width, (uint64_t) pc);
+ if (verbose)
+ printf ("%4s", ! isactivation ? "- 1" : "");
+ printf (" %s\n", symname);
return DWARF_CB_OK;
}
@@ -88,6 +92,26 @@ thread_callback (Dwfl_Thread *thread, void *thread_arg __attribute__
((unused)))
return DWARF_CB_OK;
}
+static error_t
+parse_opt (int key, char *arg __attribute__ ((unused)),
+ struct argp_state *state)
+{
+ switch (key)
+ {
+ case ARGP_KEY_INIT:
+ state->child_inputs[0] = state->input;
+ break;
+
+ case 'v':
+ verbose = true;
+ break;
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
int
main (int argc, char **argv)
{
@@ -99,6 +123,12 @@ main (int argc, char **argv)
/* Set locale. */
(void) setlocale (LC_ALL, "");
+ const struct argp_option options[] =
+ {
+ { "verbose", 'v', NULL, 0, N_("Additionally show frames
activation"), 0 },
+ { NULL, 0, NULL, 0, NULL, 0 }
+ };
+
const struct argp_child children[] =
{
{ .argp = dwfl_standard_argp () },
@@ -107,6 +137,8 @@ main (int argc, char **argv)
const struct argp argp =
{
+ .options = options,
+ .parser = parse_opt,
.doc = N_("\
Print a stack for each thread in a process or core file.\n\
Only real user processes are supported, no kernel or process maps."),