I'm trying to learn how to use perf dynamic tracing on my java application running some JNI-based shared library written in C. The library is installed by path /opt/myapp/lib/libmyapp.so
and then is run with the option -Djava.library.path=/opt/myapp/lib/
. So I run the following command:
root@mypc:~# perf probe -x /opt/myapp/lib/libmyapp.so --add Java_net_my_app_pollEvents0
Error: Failed to add events.
without any hint about the error cause. If there would be no global function with such a name in the library I would get the corresponding error description:
root@mypc:~# perf probe -x /opt/myapp/lib/libmyapp.so --add Java_net_my_app_pollEvents1234567
Probe point 'Java_net_my_app_pollEvents1234567' not found.
Error: Failed to add events.
Can anyone give a hint how to fix this? I tried to add a probe for malloc
function and it works just fine:
root@mypc:~# perf probe -x /lib/x86_64-linux-gnu/libc-2.27.so --add malloc
Added new event:
probe_libc:malloc (on malloc in /lib/x86_64-linux-gnu/libc-2.27.so)
You can now use it in all perf tools, such as:
perf record -e probe_libc:malloc -aR sleep 1
In my case the "argument list too long" error was because I was passing a very long mangled C++ symbol name to perf probe
; explicitly naming the probe point with the EVENT=
syntax allowed the probe point to be successfully added:
$ sudo perf probe -x myelf --no-demangle --add myalias=_SomeVeryLongMangledNameWhee
$ sudo perf record -e 'probe_myelf:myalias' -a -- sleep 30