linux-stable/tools/perf
Matija Glavinic Pecotic 9343e45bf6 perf unwind: Fix looking up dwarf unwind stack info
Using perf with call graph method dwarf fails to provide backtrace
support for stripped binary even though .gnu_debuglink points to *.dbg
flavor with properly populated debug symbols.

Problem is reproduced on ARM (v7, v8), kernels 3.14.y, 4.4.y and
4.10.rc3.  Perf is configured with libunwind, and unwind dwarf support
[1]. Test code (stress_bt.c) can be found on [2].

Running (explicitly disable other unwinding methods):

  $ gcc -g -o stress_bt -fomit-frame-pointer -fno-unwind-tables \
	-fno-asynchronous-unwind-tables stress_bt.c
  $ perf record -N --call-graph dwarf ./stress_bt
  $ perf report

results in properly generated call graph. Stripping the binary and running
it results with missing call graph. Expected result is to have call graph:

  $ gcc -g -o stress_bt -fomit-frame-pointer -fno-unwind-tables \
	  -fno-asynchronous-unwind-tables stress_bt.c
  $ objcopy --only-keep-debug stress_bt stress_bt.dbg
  $ objcopy --strip-debug stress_bt
  $ objcopy --add-gnu-debuglink=stress_bt.dbg stress_bt
  $ perf record -N --call-graph dwarf ./stress_bt
  $ perf report

Problem is that perf doesn't try to read symbols pointed by gnu
debuglink.  Patch adds checking, and reading of the symbols from
debuglink and symsrc.  Order of the check is to first check within dso,
then check whether symsrc is defined and try to read from it. Finally,
debuglink is checked. Default locations of debug files are discussed in
[3] and [4]. Comments on RFC are on [5].

[1] https://wiki.linaro.org/LEG/Engineering/TOOLS/perf-callstack-unwinding
[2] [1]#Backtrace_stress_application
[3] https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
[4] https://sourceware.org/binutils/docs/binutils/objcopy.html
[5] https://lkml.org/lkml/2016/8/22/473

Signed-off-by: Matija Glavinic Pecotic <matija.glavinic-pecotic.ext@nokia.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/d309d40a-463f-482b-68e1-1465326efdc1@nokia.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-01-18 12:29:52 -03:00
..
arch perf annotate: AArch64 support 2016-12-01 13:03:19 -03:00
bench perf bench futex: Fix lock-pi help string 2016-12-20 09:37:40 -03:00
Documentation perf sched timehist: Add --state option 2017-01-17 11:36:44 -03:00
jvmti perf kvmti: Remove unused Makefile file 2016-11-14 12:42:56 -03:00
pmu-events perf vendor events: Support couple more POWER8 PVRs in mapfile 2016-10-17 13:39:47 -03:00
python perf python: Add tracepoint example 2016-07-12 16:23:35 -03:00
scripts perf/core improvements and fixes: 2016-08-04 11:02:38 +02:00
tests perf tools: Add unit_number__scnprintf function 2017-01-11 16:48:01 -03:00
trace perf trace: Check if MAP_32BIT is defined (again) 2016-12-20 09:37:40 -03:00
ui perf tools: Move two variables usied in libperf from perf.c 2017-01-17 11:36:45 -03:00
util perf unwind: Fix looking up dwarf unwind stack info 2017-01-18 12:29:52 -03:00
.gitignore
Build perf tools: Move two variables usied in libperf from perf.c 2017-01-17 11:36:45 -03:00
builtin-annotate.c perf annotate: Add branch stack / basic block 2016-09-08 13:44:03 -03:00
builtin-bench.c
builtin-buildid-cache.c tools: Introduce str_error_r() 2016-07-12 15:19:47 -03:00
builtin-buildid-list.c
builtin-c2c.c perf tools: Remove some needless __maybe_unused 2016-12-15 16:25:45 -03:00
builtin-config.c perf config: Mark where are config items from (user or system) 2016-11-14 13:10:37 -03:00
builtin-data.c perf data ctf: Add '--all' option for 'perf data convert' 2016-06-28 10:54:57 -03:00
builtin-diff.c perf hists: Add support for header span 2016-08-23 15:37:33 -03:00
builtin-evlist.c
builtin-help.c perf kallsyms: Introduce tool to look for extended symbol information on the running kernel 2017-01-11 16:48:01 -03:00
builtin-inject.c perf symbols: Remove symbol_filter_t machinery 2016-09-05 11:14:50 -03:00
builtin-kallsyms.c perf kallsyms: Introduce tool to look for extended symbol information on the running kernel 2017-01-11 16:48:01 -03:00
builtin-kmem.c perf kmem: Add option to specify time window of interest 2016-12-01 13:03:02 -03:00
builtin-kvm.c perf kvm: Use NSEC_PER_USEC 2016-08-23 15:37:33 -03:00
builtin-list.c perf list: Support long jevents descriptions 2016-10-03 21:35:47 -03:00
builtin-lock.c
builtin-mem.c perf mem: Fix --all-user/--all-kernel options 2016-12-15 16:25:45 -03:00
builtin-probe.c perf probe: Ignore vmlinux Build-id when offline vmlinux given 2016-09-01 12:42:22 -03:00
builtin-record.c perf record: Add switch-output time option argument 2017-01-11 16:48:02 -03:00
builtin-report.c perf tools: Remove some needless __maybe_unused 2016-12-15 16:25:45 -03:00
builtin-sched.c perf sched timehist: Show total wait times for summary 2017-01-17 11:36:44 -03:00
builtin-script.c perf script: Also allow forcing reading of non-root owned files by root 2017-01-16 14:59:15 -03:00
builtin-stat.c perf tools: Remove some needless __maybe_unused 2016-12-15 16:25:45 -03:00
builtin-timechart.c perf timechart: Use NSEC_PER_U?SEC 2016-08-23 15:37:33 -03:00
builtin-top.c perf annotate: Start supporting cross arch annotation 2016-11-17 17:12:50 -03:00
builtin-trace.c perf trace: Allow specifying list of syscalls and events in -e/--expr/--event 2017-01-11 16:48:01 -03:00
builtin-version.c
builtin.h perf kallsyms: Introduce tool to look for extended symbol information on the running kernel 2017-01-11 16:48:01 -03:00
check-headers.sh perf tools: Move headers check into bash script 2016-12-15 16:25:44 -03:00
command-list.txt perf kallsyms: Introduce tool to look for extended symbol information on the running kernel 2017-01-11 16:48:01 -03:00
CREDITS
design.txt
Makefile
Makefile.config perf tools: Remove unneccessary feature-dwarf warning 2017-01-16 14:59:15 -03:00
Makefile.perf perf jvmti: Create libdir directory before installing libperf-jvmti.so 2017-01-11 16:48:00 -03:00
MANIFEST tools lib: Add for_each_clear_bit macro 2016-10-24 11:07:33 -03:00
perf-archive.sh
perf-completion.sh
perf-read-vdso.c
perf-sys.h perf powerpc: Fix build-test failure 2016-09-08 13:44:07 -03:00
perf-with-kcore.sh
perf.c perf tools: Move two variables usied in libperf from perf.c 2017-01-17 11:36:45 -03:00
perf.h perf evsel: Allow to ignore missing pid 2016-12-15 16:25:46 -03:00