Re: [PATCH 2/3] perf probe: Make --source avaiable when probe with lazy_line

Arnaldo Carvalho de Melo
2015-04-13T20:57:07Z

Em Mon, Apr 13, 2015 at 07:41:29PM +0800, He Kuang escreveu:
> Use get_real_path() to enable --source option when probe with lazy_line
> pattern.
>
> Before this patch:
>
> $ perf probe -s ./kernel_src/ -k ./vmlinux --add='fs/super.c;s->s_count=1;'
> Failed to open fs/super.c: No such file or directory
> Error: Failed to add events.
>
> After this patch:
>
> $ perf probe -s ./kernel_src/ -k ./vmlinux --add='fs/super.c;s->s_count=1;'
> Added new events:
> probe:_stext (on @fs/super.c)
> probe:_stext_1 (on @fs/super.c)
> ...

Tried just doing:

[root@ssdandy ~]# ulimit -c 100000000
[root@ssdandy ~]# perf probe --add='fs/super.c;s->s_count=1;'
Segmentation fault (core dumped)

I.e. not specifying vmlinux, as it finds the right one looking at the vmlinux path,
and as well not specifying -s, as it should find that as well from the vmlinux file,
but here I get a segfault:

[root@ssdandy ~]# gdb -c core.26128 ~/bin/perf
<SNIP>
Core was generated by `perf probe --add=fs/super.c;s->s_count=1;'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f2a021301c1 in dwarf_tag () from /lib64/libdw.so.1
Missing separate debuginfos, use: debuginfo-install audit-libs-2.4.1-5.el7.x86_64 bzip2-libs-1.0.6-12.el7.x86_64 elfutils-libelf-0.160-1.el7.x86_64 elfutils-libs-0.160-1.el7.x86_64 glibc-2.17-78.el7.x86_64 libgcc-4.8.3-9.el7.x86_64 libunwind-1.1-3.el7.x86_64 nss-softokn-freebl-3.16.2.3-9.el7.x86_64 numactl-libs-2.0.9-4.el7.x86_64 perl-libs-5.16.3-285.el7.x86_64 python-libs-2.7.5-16.el7.x86_64 slang-2.2.4-11.el7.x86_64 xz-libs-5.1.2-9alpha.el7.x86_64 zlib-1.2.7-13.el7.x86_64
(gdb) bt
#0 0x00007f2a021301c1 in dwarf_tag () from /lib64/libdw.so.1

#1 0x00000000004e3b78 in die_walk_lines (rt_die=rt_die@entry=0x0, callback=callback@entry=0x4e0b10 <probe_point_lazy_walker>, data=data@entry=0x7ffff2da1750) at util/dwarf-aux.c:690
#2 0x00000000004dff19 in find_probe_point_lazy (sp_die=sp_die@entry=0x0, pf=pf@entry=0x7ffff2da1750) at util/probe-finder.c:867
#3 0x00000000004e06e2 in debuginfo__find_probes (pf=pf@entry=0x7ffff2da1750, dbg=0x1767c50) at util/probe-finder.c:1058
#4 0x00000000004e13b2 in debuginfo__find_trace_events (dbg=dbg@entry=0x1767c50, pev=pev@entry=0x8fcd90 <params+16>, tevs=tevs@entry=0x1763978, max_tevs=max_tevs@entry=128) at util/probe-finder.c:1218
#5 0x00000000004dcbea in try_to_find_probe_trace_events (target=0x0, max_tevs=128, tevs=0x1763978, pev=0x8fcd90 <params+16>) at util/probe-event.c:611
#6 convert_to_probe_trace_events (target=0x0, max_tevs=128, tevs=0x1763978, pev=0x8fcd90 <params+16>) at util/probe-event.c:2645
#7 add_perf_probe_events (pevs=pevs@entry=0x8fcd90 <params+16>, npevs=<optimized out>, max_tevs=128, force_add=false) at util/probe-event.c:2680
#8 0x000000000044fa7b in __cmd_probe (argc=<optimized out>, argv=argv@entry=0x7ffff2da2600, prefix=<optimized out>) at builtin-probe.c:504
#9 0x000000000044fc34 in cmd_probe (argc=<optimized out>, argv=0x7ffff2da2600, prefix=<optimized out>) at builtin-probe.c:521
#10 0x0000000000470b35 in run_builtin (p=p@entry=0x838420 <commands+384>, argc=argc@entry=2, argv=argv@entry=0x7ffff2da2600) at perf.c:370
#11 0x000000000041d220 in handle_internal_command (argv=0x7ffff2da2600, argc=2) at perf.c:429
#12 run_argv (argv=0x7ffff2da2380, argcp=0x7ffff2da238c) at perf.c:473
#13 main (argc=2, argv=0x7ffff2da2600) at perf.c:588
(gdb)

Now with your patch, another coredump:

[root@ssdandy ~]# rm -f core.26128
[root@ssdandy ~]# perf probe --add='fs/super.c;s->s_count=1;'
Segmentation fault (core dumped)
[root@ssdandy ~]#
[root@ssdandy ~]# gdb -c core.26712 ~/bin/perf
<SNIP>
Core was generated by `perf probe --add=fs/super.c;s->s_count=1;'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f25cf4e61c1 in dwarf_tag () from /lib64/libdw.so.1
Missing separate debuginfos, use: debuginfo-install audit-libs-2.4.1-5.el7.x86_64 bzip2-libs-1.0.6-12.el7.x86_64 elfutils-libelf-0.160-1.el7.x86_64 elfutils-libs-0.160-1.el7.x86_64 glibc-2.17-78.el7.x86_64 libgcc-4.8.3-9.el7.x86_64 libunwind-1.1-3.el7.x86_64 nss-softokn-freebl-3.16.2.3-9.el7.x86_64 numactl-libs-2.0.9-4.el7.x86_64 perl-libs-5.16.3-285.el7.x86_64 python-libs-2.7.5-16.el7.x86_64 slang-2.2.4-11.el7.x86_64 xz-libs-5.1.2-9alpha.el7.x86_64 zlib-1.2.7-13.el7.x86_64
(gdb) bt
#0 0x00007f25cf4e61c1 in dwarf_tag () from /lib64/libdw.so.1
#1 0x00000000004e3c18 in die_walk_lines (rt_die=rt_die@entry=0x0, callback=callback@entry=0x4e0bb0 <probe_point_lazy_walker>, data=data@entry=0x7ffdf9244df0) at util/dwarf-aux.c:690
#2 0x00000000004dff9b in find_probe_point_lazy (sp_die=sp_die@entry=0x0, pf=pf@entry=0x7ffdf9244df0) at util/probe-finder.c:879
#3 0x00000000004e0782 in debuginfo__find_probes (pf=pf@entry=0x7ffdf9244df0, dbg=0xe3ec50) at util/probe-finder.c:1070
#4 0x00000000004e1452 in debuginfo__find_trace_events (dbg=dbg@entry=0xe3ec50, pev=pev@entry=0x8fcd90 <params+16>, tevs=tevs@entry=0xe3a978, max_tevs=max_tevs@entry=128) at util/probe-finder.c:1230
#5 0x00000000004dcc2a in try_to_find_probe_trace_events (target=0x0, max_tevs=128, tevs=0xe3a978, pev=0x8fcd90 <params+16>) at util/probe-event.c:611
#6 convert_to_probe_trace_events (target=0x0, max_tevs=128, tevs=0xe3a978, pev=0x8fcd90 <params+16>) at util/probe-event.c:2645
#7 add_perf_probe_events (pevs=pevs@entry=0x8fcd90 <params+16>, npevs=<optimized out>, max_tevs=128, force_add=false) at util/probe-event.c:2680
#8 0x000000000044faab in __cmd_probe (argc=<optimized out>, argv=argv@entry=0x7ffdf9245ca0, prefix=<optimized out>) at builtin-probe.c:504
#9 0x000000000044fc64 in cmd_probe (argc=<optimized out>, argv=0x7ffdf9245ca0, prefix=<optimized out>) at builtin-probe.c:521
#10 0x0000000000470b65 in run_builtin (p=p@entry=0x838420 <commands+384>, argc=argc@entry=2, argv=argv@entry=0x7ffdf9245ca0) at perf.c:370
#11 0x000000000041d250 in handle_internal_command (argv=0x7ffdf9245ca0, argc=2) at perf.c:429
#12 run_argv (argv=0x7ffdf9245a20, argcp=0x7ffdf9245a2c) at perf.c:473
#13 main (argc=2, argv=0x7ffdf9245ca0) at perf.c:588
(gdb)

Trying exactly as you did, first without the patch:

[root@ssdandy linux]# perf probe -s /home/acme/git/linux/ -k ../build/v4.0.0-rc6+/vmlinux --add='fs/super.c;s->s_count=1;'
Segmentation fault (core dumped)
[root@ssdandy linux]#

Now with it:

[root@ssdandy linux]# perf probe -s /home/acme/git/linux/ -k ../build/v4.0.0-rc6+/vmlinux --add='fs/super.c;s->s_count=1;'
Segmentation fault (core dumped)
[root@ssdandy linux]#

Core was generated by `perf probe -s /home/acme/git/linux/ -k ../build/v4.0.0-rc6+/vmlinux --add=fs/su'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f76795c01c1 in dwarf_tag () from /lib64/libdw.so.1
Missing separate debuginfos, use: debuginfo-install audit-libs-2.4.1-5.el7.x86_64 bzip2-libs-1.0.6-12.el7.x86_64 elfutils-libelf-0.160-1.el7.x86_64 elfutils-libs-0.160-1.el7.x86_64 glibc-2.17-78.el7.x86_64 libgcc-4.8.3-9.el7.x86_64 libunwind-1.1-3.el7.x86_64 nss-softokn-freebl-3.16.2.3-9.el7.x86_64 numactl-libs-2.0.9-4.el7.x86_64 perl-libs-5.16.3-285.el7.x86_64 python-libs-2.7.5-16.el7.x86_64 slang-2.2.4-11.el7.x86_64 xz-libs-5.1.2-9alpha.el7.x86_64 zlib-1.2.7-13.el7.x86_64
(gdb) bt
#0 0x00007f76795c01c1 in dwarf_tag () from /lib64/libdw.so.1
#1 0x00000000004e3c18 in die_walk_lines (rt_die=rt_die@entry=0x0, callback=callback@entry=0x4e0bb0 <probe_point_lazy_walker>, data=data@entry=0x7ffcf282f280) at util/dwarf-aux.c:690
#2 0x00000000004dff9b in find_probe_point_lazy (sp_die=sp_die@entry=0x0, pf=pf@entry=0x7ffcf282f280) at util/probe-finder.c:879
#3 0x00000000004e0782 in debuginfo__find_probes (pf=pf@entry=0x7ffcf282f280, dbg=0x19c1b30) at util/probe-finder.c:1070
#4 0x00000000004e1452 in debuginfo__find_trace_events (dbg=dbg@entry=0x19c1b30, pev=pev@entry=0x8fcd90 <params+16>, tevs=tevs@entry=0x19be778, max_tevs=max_tevs@entry=128) at util/probe-finder.c:1230
#5 0x00000000004dcc2a in try_to_find_probe_trace_events (target=0x0, max_tevs=128, tevs=0x19be778, pev=0x8fcd90 <params+16>) at util/probe-event.c:611
#6 convert_to_probe_trace_events (target=0x0, max_tevs=128, tevs=0x19be778, pev=0x8fcd90 <params+16>) at util/probe-event.c:2645
#7 add_perf_probe_events (pevs=pevs@entry=0x8fcd90 <params+16>, npevs=<optimized out>, max_tevs=128, force_add=false) at util/probe-event.c:2680
#8 0x000000000044faab in __cmd_probe (argc=<optimized out>, argv=argv@entry=0x7ffcf2830130, prefix=<optimized out>) at builtin-probe.c:504
#9 0x000000000044fc64 in cmd_probe (argc=<optimized out>, argv=0x7ffcf2830130, prefix=<optimized out>) at builtin-probe.c:521
#10 0x0000000000470b65 in run_builtin (p=p@entry=0x838420 <commands+384>, argc=argc@entry=6, argv=argv@entry=0x7ffcf2830130) at perf.c:370
#11 0x000000000041d250 in handle_internal_command (argv=0x7ffcf2830130, argc=6) at perf.c:429
#12 run_argv (argv=0x7ffcf282feb0, argcp=0x7ffcf282febc) at perf.c:473
#13 main (argc=6, argv=0x7ffcf2830130) at perf.c:588
(gdb)

And:

[acme@ssdandy linux]$ ls -la /home/acme/git/linux/fs/super.c
-rw-rw-r--. 1 acme acme 36192 Abr 7 17:59 /home/acme/git/linux/fs/super.c

Processed [1/3], looking if [3/3] can be applied independently of this one.

- Arnaldo