• M
    perf probe: Show correct source lines of probes on kmodules · 9b239a12
    Masami Hiramatsu 提交于
    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: NArnaldo Carvalho de Melo <acme@kernel.org>
    Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
    Tested-by: NArnaldo 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.localdomainSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    9b239a12
probe-event.c 65.7 KB