]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
stack: -b, --build-id shows module build-id, load address and pc offset.
authorMark Wielaard <mjw@redhat.com>
Sun, 22 Dec 2013 23:47:06 +0000 (00:47 +0100)
committerMark Wielaard <mjw@redhat.com>
Tue, 31 Dec 2013 10:58:42 +0000 (11:58 +0100)
A convenient format for offline processing of the backtrace.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
src/ChangeLog
src/stack.c

index d3d680782b74f55e7429d48c6cbed3f1a0e09c5d..4737d697e58bc42f79cfc0f89b01ef7e55b0c3d9 100644 (file)
@@ -1,3 +1,11 @@
+2013-12-23  Mark Wielaard  <mjw@redhat.com>
+
+       * stack.c (show_build_id): New static boolean.
+       (print_frames): Print module build-id, load address and pc offset
+       if show_build_id is true.
+       (parse_opt): Handle '-b'.
+       (main): Add -b to options.
+
 2013-12-22  Mark Wielaard  <mjw@redhat.com>
 
        * stack.c (maxframes): New static unsigned. Initialize to 64.
index 188aa005add5d28ce2e5cd0a5ac8ee31d8d854a5..362cc065b255ad616fb90af3dd6f0feccc514f2d 100644 (file)
@@ -38,6 +38,7 @@ ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
 
 static bool show_activation = false;
 static bool show_module = false;
+static bool show_build_id = false;
 static bool show_source = false;
 static bool show_one_tid = false;
 
@@ -116,15 +117,31 @@ print_frames (struct frames *frames)
       if (symname != NULL)
        printf (" %s", symname);
 
+      const char* fname;
+      Dwarf_Addr start;
+      fname = dwfl_module_info(mod, NULL, &start,
+                              NULL, NULL, NULL, NULL, NULL);
       if (show_module)
        {
-         const char* fname;
-         fname = dwfl_module_info(mod,
-                                  NULL, NULL, NULL, NULL, NULL, NULL, NULL);
          if (fname != NULL)
            printf (" - %s", fname);
        }
 
+      if (show_build_id)
+       {
+         const unsigned char *id;
+         GElf_Addr id_vaddr;
+         int id_len = dwfl_module_build_id (mod, &id, &id_vaddr);
+         if (id_len > 0)
+           {
+             printf ("\n    [");
+             do
+               printf ("%02" PRIx8, *id++);
+             while (--id_len > 0);
+             printf ("]@0x%0" PRIx64 "+%" PRIx64, start, pc_adjusted - start);
+           }
+       }
+
       if (show_source)
        {
          Dwfl_Line *lineobj = dwfl_module_getsrc(mod, pc_adjusted);
@@ -203,6 +220,10 @@ parse_opt (int key, char *arg __attribute__ ((unused)),
       show_activation = show_source = show_module = true;
       break;
 
+    case 'b':
+      show_build_id = true;
+      break;
+
     case '1':
       show_one_tid = true;
       break;
@@ -243,6 +264,8 @@ main (int argc, char **argv)
        N_("Additionally show source file information"), 0 },
       { "verbose", 'v', NULL, 0,
        N_("Show all additional information (activation, module and source)"), 0 },
+      { "build-id",  'b', NULL, 0,
+       N_("Show module build-id, load address and pc offset"), 0 },
       { NULL, '1', NULL, 0,
        N_("Show the backtrace of only one thread"), 0 },
       { NULL, 'n', "MAXFRAMES", 0,
@@ -270,7 +293,7 @@ Only real user processes are supported, no kernel or process maps."),
   argp_parse (&argp, argc, argv, 0, &remaining, &dwfl);
   assert (dwfl != NULL);
   if (remaining != argc)
-    error (2, 0, "eu-stack [-a] [-m] [-s] [-v] [-1] [-n MAXFRAMES]"
+    error (2, 0, "eu-stack [-a] [-m] [-b] [-s] [-v] [-1] [-n MAXFRAMES]"
           " [--debuginfo-path=<path>]"
           " {-p <process id>|--core=<file> [--executable=<file>]|--help}");