I am using perf to insert probes on a line of code that’s a macro. For example in the CPython implementation I would like to insert a record to be made every time the GIL is unlocked on line 164:
sudo perf probe -f -x `which python3-dbg` python:take_lock=ceval_gil.h:164
The problem is that line 164 contains a three-line macro MUTEX_LOCK(gil->mutex)
; consequently three probes are inserted into the code
sudo perf probe -f -x `which python3-dbg` python:take_lock=ceval_gil.h:164 gil
Added new events:
python:take_lock (on @ceval_gil.h:164 in /usr/bin/python3.10d with gil)
python:take_lock (on @ceval_gil.h:164 in /usr/bin/python3.10d with gil)
python:take_lock (on @ceval_gil.h:164 in /usr/bin/python3.10d with gil)
You can now use it in all perf tools, such as:
perf record -e python:take_lock -aR sleep 1
Furthermore
sudo perf probe --list
python:take_lock (on drop_gil:20@../Python/ceval_gil.h in /usr/bin/python3.10d with gil)
python:take_lock (on drop_gil:20@../Python/ceval_gil.h in /usr/bin/python3.10d with gil)
python:take_lock (on drop_gil:20@../Python/ceval_gil.h in /usr/bin/python3.10d with gil)
Is there a way to avoid this or delete the first and last probes?