## python.function.return(str filename, str funcname, int lineno, frameptr) 

This probe point is the converse of python.function.return , and indicates that execution of a Python function has ended (either via$_{return}$, or via an exception). It is only triggered for pure-Python (bytecode) functions. 

## 6 Examples 

This SystemTap script uses the tapset above to more cleanly implement the example given above of tracing the Python function-call hierarchy, without needing to directly name the static markers: 

probe python.function.entry { printf("%s => %s in %s:%d
", thread_indent(1), funcname, filename, lineno); } probe python.function.return { printf("%s <= %s in %s:%d
", thread_indent(-1), funcname, filename, lineno); } 

The following script uses the tapset above to provide a top-like view of all running CPython code, showing the top 20 most frequently-entered bytecode frames, each second, across the whole system: 

global fn_calls; probe python.function.entry { fn_calls[pid(), filename, funcname, lineno] += 1; } probe timer.ms(1000) { printf("\033[2J\033[1;1H") /* clear screen \*/ printf("%6s %80s %6s %30s %6s
", "PID", "FILENAME", "LINE", "FUNCTION", "CALLS") foreach ([pid, filename, funcname, lineno] in fn_calls- limit 20) { printf("%6d %80s %6d %30s %6d
", pid, filename, lineno, funcname, fn_calls[pid, filename, funcname, lineno]); } delete fn_calls; } 

