I'm trying to add a perf probe
for a C++ method in my library, but I keep getting the following:
$ perf probe --exec=/path/to/file --add='my::Own::Method'
Semantic error :There is non-digit char in line number.
I've listed the available functions like so:
$ perf probe --funcs --exec=/path/to/file
And tried some C functions that are also included. A probe can be added for these just fine. So I tried the mangled name (e.g. _ZN2my8Own16Method
) and perf probe
says it doesn't exist.
Is there a way around this issue?
As a workaround you can get the method address with objdump
and perf probe
will accept it.
$ perf probe -x /path/file '0x643f30'
Added new event:
probe_libfile:abs_643f30 (on 0x643f30 in /path/file)
You can now use it in all perf tools, such as:
perf record -e probe_libfile:abs_643f30 -aR sleep 1
Do note that perf probe
expects an offset from the file, and objdump
and readelf
return the address after adjusting for the loading address. For -pie
executable, where the loading address is 0, the addresses will be the same.
For non -pie
executables you can get the loading address by looking at the output of readelf -l /path/file
and searching for the offset 0x000000
and looking at what VirtAddr
it points to, then subtract that number from the symbol address that you get from objdump --syms
or readelf --syms
. It will usually be 0x400000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With