perf report: Ensure the perf DSO mapping matches what libdw sees
authorMilian Wolff <milian.wolff@kdab.com>
Fri, 2 Jun 2017 14:37:52 +0000 (16:37 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 5 Jun 2017 17:18:05 +0000 (14:18 -0300)
commit2538b9e2450ae255337c04356e9e0f8cb9ec48d9
tree2005b1d6862137c5809fe3ee11230ae67736d78e
parent5ea0416f51cc93436bbe497c62ab49fd9cb245b6
perf report: Ensure the perf DSO mapping matches what libdw sees

In some situations the libdw unwinder stopped working properly.  I.e.
with libunwind we see:

~~~~~
heaptrack_gui  2228 135073.400112:     641314 cycles:
            e8ed _dl_fixup (/usr/lib/ld-2.25.so)
           15f06 _dl_runtime_resolve_sse_vex (/usr/lib/ld-2.25.so)
           ed94c KDynamicJobTracker::KDynamicJobTracker (/home/milian/projects/compiled/kf5/lib64/libKF5KIOWidgets.so.5.35.0)
           608f3 _GLOBAL__sub_I_kdynamicjobtracker.cpp (/home/milian/projects/compiled/kf5/lib64/libKF5KIOWidgets.so.5.35.0)
            f199 call_init.part.0 (/usr/lib/ld-2.25.so)
            f2a5 _dl_init (/usr/lib/ld-2.25.so)
             db9 _dl_start_user (/usr/lib/ld-2.25.so)
~~~~~

But with libdw and without this patch this sample is not properly
unwound:

~~~~~
heaptrack_gui  2228 135073.400112:     641314 cycles:
            e8ed _dl_fixup (/usr/lib/ld-2.25.so)
           15f06 _dl_runtime_resolve_sse_vex (/usr/lib/ld-2.25.so)
           ed94c KDynamicJobTracker::KDynamicJobTracker (/home/milian/projects/compiled/kf5/lib64/libKF5KIOWidgets.so.5.35.0)
~~~~~

Debug output showed me that libdw found a module for the last frame
address, but it thinks it belongs to /usr/lib/ld-2.25.so. This patch
double-checks what libdw sees and what perf knows. If the mappings
mismatch, we now report the elf known to perf. This fixes the situation
above, and the libdw unwinder produces the same stack as libunwind.

Signed-off-by: Milian Wolff <milian.wolff@kdab.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20170602143753.16907-1-milian.wolff@kdab.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/unwind-libdw.c