crash-stack: disable unw_get_proc_name prediction 80/107880/6
authorRafal Pietruch <r.pietruch@samsung.com>
Fri, 30 Dec 2016 07:38:29 +0000 (08:38 +0100)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Thu, 2 Feb 2017 12:36:24 +0000 (13:36 +0100)
libunwind unw_get_proc_name function may return the name of
a label or a preceeding, nearby procedure; although the value
of the returned name plus the returned offset will
be equal to the instruction-pointer of the stack frame,
developers can find a exact symbol with related code position
in debug packages

Change-Id: I2471c2a9483b577844110f25128a6d539d39e5ad

src/crash-stack/crash-stack-libunw.c

index f013e63..b9b9c35 100644 (file)
@@ -23,8 +23,6 @@
 #include "crash-stack.h"
 #include <libunwind-ptrace.h>
 
-#include <string.h>
-
 #define MAXPROCNAMELEN 512
 
 void _create_crash_stack(Dwfl *dwfl, Elf *core, pid_t pid, Mappings *mappings, Callstack *callstack)
@@ -59,10 +57,8 @@ void _create_crash_stack(Dwfl *dwfl, Elf *core, pid_t pid, Mappings *mappings, C
 
                        proc_name[0] = '\0';
                        unw_word_t off;
-                       unw_get_proc_name(&cursor, proc_name, sizeof(proc_name), &off);
-                       if (strlen(proc_name) > 0)
-                               callstack->proc[callstack->elems].name = strdup(proc_name);
-                       callstack->proc[callstack->elems].offset = off;
+                       if (unw_get_proc_name(&cursor, proc_name, sizeof(proc_name), &off) == 0)
+                               callstack->proc[callstack->elems].offset = off;
 
                        if (unw_step(&cursor) <= 0)
                                break;