Can't add perf probe for C++ methods
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