Set the profiling function. It will be called on each function call and return. See the profiler chapter in the library manual.
sys/setprofile
setprofile