linux-stable/tools/perf
Masami Hiramatsu e08cfd4bda perf probe: Fix to find line information for probe list
Fix to find the correct (as much as possible) line information for
listing probes. Without this fix, perf probe --list action will show
incorrect line information as below;

  probe:getname_flags  (on getname_flags@ksrc/linux-3/fs/namei.c)
  probe:getname_flags_1 (on getname:-89@x86/include/asm/current.h)
  probe:getname_flags_2 (on user_path_at_empty:-2054@x86/include/asm/current.h)

The minus line number is obviously wrong, and current.h is not related
to the probe point. Deeper investigation discovered that there were 2
issues related to this bug, and minor typos too.

The 1st issue is the rack of considering about nested inlined functions,
which causes the wrong (relative) line number.

The 2nd issue is that the dwarf line info is not correct at those
points. It points 14th line of current.h.

Since it seems that the line info includes somewhat unreliable
information, this fixes perf to try to find correct line information
from both of debuginfo and line info as below.

1) Probe address is the entry of a function instance

  In this case, the line is set as the function declared line.

2) Probe address is the entry of an expanded inline function block

  In this case, the line is set as the function call-site line.
  This means that the line number is relative from the entry line
  of caller function (which can be an inlined function if nested)

3) Probe address is inside a function instance or an expanded
   inline function block

  In this case, perf probe queries the line number from lineinfo
  and verify the function declared file is same as the file name
  queried from lineinfo.

  If the file name is different, it is a failure case. The probe
  address is shown as symbol+offset.

4) Probe address is not in the any function instance

  This is a failure case, the probe address is shown as
  symbol+offset.

With this fix, perf probe -l shows correct probe lines as below;

  probe:getname_flags  (on getname_flags@ksrc/linux-3/fs/namei.c)
  probe:getname_flags_1 (on getname:2@ksrc/linux-3/fs/namei.c)
  probe:getname_flags_2 (on user_path_at_empty:4@ksrc/linux-3/fs/namei.c)

Changes at v2:
 - Fix typos in the function comments. (Thanks to Namhyung Kim)
 - Use die_find_top_inlinefunc instead of die_find_inlinefunc_next.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20130930092144.1693.11058.stgit@udc4-manage.rcp.hitachi.co.jp
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2013-10-04 15:16:05 -03:00
..
arch perf: Fix capabilities bitfield compatibility in 'struct perf_event_mmap_page' 2013-09-20 09:45:11 +02:00
bench perf bench: Fix memcpy benchmark for large sizes 2013-07-22 12:41:56 -03:00
config perf tools: Fix libaudit test 2013-10-04 15:16:05 -03:00
Documentation perf trace: Add option to analyze events in a file versus live 2013-08-29 17:42:34 -03:00
python perf python: Remove duplicate TID bit from mask 2013-08-07 17:35:25 -03:00
scripts perf script: Fix broken include in Context.xs 2013-07-10 13:47:00 -03:00
tests perf tools: Add attr->mmap2 support 2013-09-11 10:09:32 -03:00
ui perf hists: Fix formatting of long symbol names 2013-09-05 16:18:28 -03:00
util perf probe: Fix to find line information for probe list 2013-10-04 15:16:05 -03:00
.gitignore perf tools: Ignore compiled python binaries 2012-09-07 12:10:58 -03:00
bash_completion perf tools: Complete tracepoint event names 2012-10-04 12:44:52 -03:00
builtin-annotate.c perf tools: Add attr->mmap2 support 2013-09-11 10:09:32 -03:00
builtin-bench.c perf tools: Make numa benchmark optional 2013-01-30 10:36:21 -03:00
builtin-buildid-cache.c perf buildid-cache: Add --update option 2013-02-14 14:59:27 -03:00
builtin-buildid-list.c perf symbols: Generalize filter in __fprintf_buildid methods 2012-12-09 08:46:07 -03:00
builtin-diff.c perf tools: Remove filter parameter of perf_event__preprocess_sample() 2013-08-12 10:31:11 -03:00
builtin-evlist.c perf evlist: Pass the event_group info via perf_attr_details 2013-02-06 18:09:28 -03:00
builtin-help.c perf help: Fix --help for builtins 2012-10-22 12:35:49 -02:00
builtin-inject.c perf session: Check for SIGINT in more loops 2013-09-19 11:32:17 -03:00
builtin-kmem.c perf kmem: Make it work again on non NUMA machines 2013-09-24 14:13:46 -03:00
builtin-kvm.c perf kvm: Fix sample_type manipulation 2013-09-09 16:13:11 -03:00
builtin-list.c perf list: List kernel supplied event aliases 2013-07-12 13:53:53 -03:00
builtin-lock.c perf tools: change machine__findnew_thread() to set thread pid 2013-08-29 11:51:31 -03:00
builtin-mem.c perf tools: Add attr->mmap2 support 2013-09-11 10:09:32 -03:00
builtin-probe.c perf tools: Introduce tools/lib/lk library 2013-03-15 13:06:00 -03:00
builtin-record.c perf tools: Remove event types framework completely 2013-07-15 16:28:22 -03:00
builtin-report.c perf session: Check for SIGINT in more loops 2013-09-19 11:32:17 -03:00
builtin-sched.c perf tools: change machine__findnew_thread() to set thread pid 2013-08-29 11:51:31 -03:00
builtin-script.c perf session: Check for SIGINT in more loops 2013-09-19 11:32:17 -03:00
builtin-stat.c perf stat: Set child_pid after perf_evlist__prepare_workload() 2013-10-04 15:16:05 -03:00
builtin-timechart.c perf timechart: Remove event types framework only user 2013-07-15 16:14:47 -03:00
builtin-top.c perf tools: Remove references to struct ip_event 2013-08-29 15:29:28 -03:00
builtin-trace.c perf trace: Add mmap2 handler 2013-09-24 14:15:51 -03:00
builtin.h perf tools: Add new mem command for memory access profiling 2013-04-01 12:21:44 -03:00
command-list.txt perf tools: Add new mem command for memory access profiling 2013-04-01 12:21:44 -03:00
CREDITS
design.txt perf tools: Update ioctl documentation for PERF_IOC_FLAG_GROUP 2012-05-31 11:38:42 -03:00
Makefile perf tools: Add test for parsing with no sample_id_all bit 2013-09-05 16:17:46 -03:00
MANIFEST perf tools: Introduce tools/lib/lk library 2013-03-15 13:06:00 -03:00
perf-archive.sh perf archive: Make 'f' the last parameter for tar 2012-09-17 13:10:42 -03:00
perf.c perf tools: Convert needless static variable to local 2013-04-01 12:22:48 -03:00
perf.h perf kvm: Option to print events that exceed a duration 2013-08-12 10:31:04 -03:00