linux/tools/perf
Masami Hiramatsu 9b239a12bc perf probe: Show correct source lines of probes on kmodules
Perf probe always failed to find appropriate line numbers because of
failing to find .text start address offset from debuginfo.

e.g.
  ----
  # ./perf probe -m pcspkr pcspkr_event:5
  Added new events:
    probe:pcspkr_event   (on pcspkr_event:5 in pcspkr)
    probe:pcspkr_event_1 (on pcspkr_event:5 in pcspkr)

  You can now use it in all perf tools, such as:

          perf record -e probe:pcspkr_event_1 -aR sleep 1

  # ./perf probe -l
  Failed to find debug information for address ffffffffa031f006
  Failed to find debug information for address ffffffffa031f016
    probe:pcspkr_event   (on pcspkr_event+6 in pcspkr)
    probe:pcspkr_event_1 (on pcspkr_event+22 in pcspkr)
  ----

This fixes the above issue as below.
1. Get the relative address of the symbol in .text by using
   map->start.
2. Adjust the address by adding the offset of .text section
   in the kernel module binary.

With this fix, perf probe -l shows lines correctly.
  ----
  # ./perf probe -l
    probe:pcspkr_event   (on pcspkr_event:5@drivers/input/misc/pcspkr.c in pcspkr)
    probe:pcspkr_event_1 (on pcspkr_event:5@drivers/input/misc/pcspkr.c in pcspkr)
  ----

Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20150930164132.3733.24643.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-09-30 18:34:35 -03:00
..
arch perf tools: Introduce regs_query_register_offset() for x86 2015-09-15 09:48:33 -03:00
bench perf bench futex: Add lock_pi stresser 2015-07-20 17:49:51 -03:00
config Merge branch 'perf/urgent' into perf/core, to pick up fixes before applying new changes 2015-09-18 09:24:01 +02:00
Documentation perf report: Amend documentation about max_stack and synthesized callchains 2015-09-30 18:34:26 -03:00
python perf python: Make twatch.py use soft dummy event, freq=0 2015-07-29 10:51:45 -03:00
scripts perf tools: Add more documentation to export-to-postgresql.py script 2015-09-28 16:53:07 -03:00
tests perf machine: Add method for common kernel_map(FUNCTION) operation 2015-09-30 18:34:29 -03:00
trace/strace/groups perf trace: Add read/write to the file group 2015-09-04 13:22:06 -03:00
ui perf hists browser: Use the map to determine if a DSO is being used as a kernel 2015-09-28 15:50:54 -03:00
util perf probe: Show correct source lines of probes on kmodules 2015-09-30 18:34:35 -03:00
.gitignore perf tools: Add Intel PT instruction decoder 2015-08-17 11:11:36 -03:00
Build perf trace: Support 'strace' syscall event groups 2015-07-20 15:16:32 -03:00
builtin-annotate.c perf env: Rename some leftovers from rename to perf_env 2015-09-14 12:50:20 -03:00
builtin-bench.c perf bench futex: Add lock_pi stresser 2015-07-20 17:49:51 -03:00
builtin-buildid-cache.c perf buildid: Introduce sysfs/filename__sprintf_build_id 2015-08-28 14:53:50 -03:00
builtin-buildid-list.c perf buildid: Introduce sysfs/filename__sprintf_build_id 2015-08-28 14:53:50 -03:00
builtin-data.c perf data: Support using -f to override perf.data file ownership for 'convert' 2015-04-02 13:18:52 -03:00
builtin-diff.c perf callchain: Allow disabling call graphs per event 2015-08-12 13:20:28 -03:00
builtin-evlist.c perf evlist: Support using -f to override perf.data file ownership 2015-04-02 13:18:45 -03:00
builtin-help.c perf tools: Add the bash completion for listing subsubcommands of perf help 2015-03-19 13:49:39 -03:00
builtin-inject.c perf inject: Add --strip option to strip out non-synthesized events 2015-09-28 17:19:51 -03:00
builtin-kmem.c perf machine: Add method for common kernel_map(FUNCTION) operation 2015-09-30 18:34:29 -03:00
builtin-kvm.c tools lib api fs: Replace debugfs/tracefs objects interface with fs.c 2015-09-14 12:50:15 -03:00
builtin-list.c perf list: Extend raw-dump to certain kind of events 2015-02-27 15:52:24 -03:00
builtin-lock.c perf machine: Protect the machine->threads with a rwlock 2015-05-08 16:19:27 -03:00
builtin-mem.c perf mem: Fill in the missing session freeing after an error occurs 2015-07-01 17:53:49 -03:00
builtin-probe.c perf probe: Fix a segfault when removing uprobe events 2015-09-21 18:01:17 -03:00
builtin-record.c perf record: Synthesize COMM event for a command line workload 2015-09-22 22:43:12 -03:00
builtin-report.c perf machine: Add method for common kernel_map(FUNCTION) operation 2015-09-30 18:34:29 -03:00
builtin-sched.c perf sched: Add option to merge like comms to lat output 2015-05-27 12:21:45 -03:00
builtin-script.c perf script: Make scripting_max_stack value allow for synthesized callchains 2015-09-28 17:09:41 -03:00
builtin-stat.c perf stat: Quieten failed to read counter message 2015-09-02 16:30:47 -03:00
builtin-timechart.c perf tools: Elliminate alignment holes 2015-05-18 10:17:33 -03:00
builtin-top.c perf top: Filter symbols based on __map__is_kernel(map) 2015-09-28 15:50:53 -03:00
builtin-trace.c perf evsel: Propagate error info from tp_format 2015-09-15 09:48:33 -03:00
builtin.h perf tools: Add new 'perf data' command 2015-02-25 12:42:25 -03:00
command-list.txt perf tools: Add new 'perf data' command 2015-02-25 12:42:25 -03:00
CREDITS
design.txt perf tools: Update some code references in design.txt 2014-03-18 18:17:06 -03:00
Makefile perf build: Fix single target build dependency check 2015-06-22 11:27:09 -03:00
Makefile.perf tools build: Build fixdep helper from perf and basic libs 2015-09-28 15:50:55 -03:00
MANIFEST perf tools: Add include/err.h into MANIFEST 2015-09-22 10:47:05 -03:00
perf-archive.sh
perf-completion.sh perf tools: Avoid confusion with preloaded bash function for perf bash completion 2015-03-19 13:53:27 -03:00
perf-read-vdso.c perf tools: Build programs to copy 32-bit compatibility 2014-10-29 10:32:48 -02:00
perf-sys.h perf tools: Move generic barriers out of perf-sys.h 2015-05-08 16:05:08 -03:00
perf-with-kcore.sh perf tools: Fix perf-with-kcore handling of arguments containing spaces 2015-08-06 16:48:27 -03:00
perf.c perf env: Introduce read_cpu_topology_map() method 2015-09-14 12:50:28 -03:00
perf.h perf record: Add ability to name registers to record 2015-08-31 18:01:33 -03:00