Does Valgrind provide some kind of API to control data collection? For example, Valgrind has a tool called Lackey that traces memory accesses. I would like to trace memory accesses, but only for one loop, not everywhere. So, I would like to call valgrind.start_tracing() before the loop and valgrind.stop_tracing() after the loop. Is this possible?
As per the comment, the client request is the way to go.
At present none exist for lackey. You would need to add your own. Other tools already have similar client requests that can turn instrumentation off and on.