perf probe: Fix segfault when probe with lazy_line to file
authorHe Kuang <hekuang@huawei.com>
Mon, 13 Apr 2015 11:41:30 +0000 (19:41 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 13 Apr 2015 23:12:21 +0000 (20:12 -0300)
The first argument passed to find_probe_point_lazy() should be CU die,
which will be passed to die_walk_lines() when lazy_line matches.
Currently, when we probe with lazy_line pattern to file without function
name, NULL pointer is passed and causes a segment fault.

Can be reproduced as following:

  $ perf probe -k vmlinux --add='fs/super.c;s->s_count=1;'
  [ 1958.984658] perf[1020]: segfault at 10 ip 00007fc6e10d8c71 sp
  00007ffcbfaaf900 error 4 in libdw-0.161.so[7fc6e10ce000+34000]
  Segmentation fault

After this patch:

  $ perf probe -k vmlinux --add='fs/super.c;s->s_count=1;'
  Added new event:
  probe:_stext         (on @fs/super.c)

  You can now use it in all perf tools, such as:
    perf record -e probe:_stext -aR sleep 1

Signed-off-by: He Kuang <hekuang@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1428925290-5623-3-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/probe-finder.c

index ff7865ca3ca3529a12a48ad175d5a18791bc7018..44554c3c2220f44e787f2bf1a7e39e49201ad207 100644 (file)
@@ -1066,7 +1066,7 @@ static int debuginfo__find_probes(struct debuginfo *dbg,
                        if (pp->function)
                                ret = find_probe_point_by_func(pf);
                        else if (pp->lazy_line)
-                               ret = find_probe_point_lazy(NULL, pf);
+                               ret = find_probe_point_lazy(&pf->cu_die, pf);
                        else {
                                pf->lno = pp->line;
                                ret = find_probe_point_by_line(pf);
This page took 0.026145 seconds and 5 git commands to generate.