Search code examples
perf

trying to add perf probe at function%return not working


I'm trying to use perf to add 2 probe points, one each at the beginning and end of a function.

I get the name of the symbol (mangled, to work with perf) using this:

perf probe --funcs -x ./libVfeAecAndComms.so --no-demangle --filter='*'

which gives me 3 lines of output that are relevant for the function I'm after:

_ZN10AecElement15ProcessSubFrameERK15VoiceAudioFrameIfERS1_m
_ZN10AecElement15ProcessSubFrameERK15VoiceAudioFrameIfERS1_m
_ZN10AecElement15ProcessSubFrameERK15VoiceAudioFrameIfERS1_m@plt

The actual function is just AecElement::ProcessSubFrame() which returns void.

I can add a probe for the function entry using this:

perf probe -x ./libVfeAecAndComms.so --add psf_enter='_ZN10AecElement15ProcessSubFrameERK15VoiceAudioFrameIfERS1_m'

This seems to work with this message:

Added new event:
  probe_libVfeAecAndComms:psb_enter (on _ZN10AecElement15ProcessSubFrameERK15VoiceAudioFrameIfERS1_m in /opt/Bose/bin/VfeElementLibs/AecElement/libVfeAecAndComms.so)

I'm trying to add another probe point for the return from that function using the ' %return' trick outlined in the documentation for perf-probe [1] as follows:

perf probe -x ./libVfeAecAndComms.so --add psf_ret='_ZN10AecElement15ProcessSubFrameERK15VoiceAudioFrameIfERS1_m%return'

but it gives me an error:

Failed to find symbol _ZN10AecElement15ProcessSubFrameERK15VoiceAudioFrameIfERS1_m in /opt/Bose/bin/VfeElementLibs/AecElement/libVfeAecAndComms.so
  Error: Failed to add events.

One other note: running objdump --t ./libVfeAecAndComms.so only lists the one symbol name, _ZN10AecElement15ProcessSubFrameERK15VoiceAudioFrameIfERS1_m

I'm not sure why the %return added to the mangled symbol name isn't recognized. I've seen a couple of blogs showing this exact approach and the man page seems to say it should work.

Is there another way to do this?

[1] https://linux.die.net/man/1/perf-probe


Solution

  • It appears I only needed to add a --no-demangle at the end of the request to add the probe point. FWIW I didn't need this when I added the first probe point for the function entry.

    Also, interesting to me is that it adds two probe points for this one call. I don't understand that, yet.

    perf probe -x ./libVfeAecAndComms.so --add psf_return=_ZN10AecElement15ProcessSubFrameERK15VoiceAudioFrameIfERS1_m%return --no-demangle
    Added new events:
      probe_libVfeAecAndComms:psf_return__return (on _ZN10AecElement15ProcessSubFrameERK15VoiceAudioFrameIfERS1_m%return in /opt/Bose/bin/VfeElementLibs/AecElement/libVfeAecAndComms.so)
      probe_libVfeAecAndComms:psf_return_1 (on _ZN10AecElement15ProcessSubFrameERK15VoiceAudioFrameIfERS1_m%return in /opt/Bose/bin/VfeElementLibs/AecElement/libVfeAecAndComms.so)