(continued from previous page) 

printf("%s <= %s in %s:%d\
", thread_indent(-1), funcname, filename, lineno); } 

It can be invoked like this: 

$ stap \ show-call-hierarchy.stp \ -c"./python test.py" 

The output looks like this: 

11408 python(8274): => __contains__ in Lib/_abcoll.py:362 11414 python(8274): => __getitem__ in Lib/os.py:425 11418 python(8274):=> encode in Lib/os.py:490 11424 python(8274):<= encode in Lib/os.py:493 11428 python(8274): <= __getitem__ in Lib/os.py:426 11433 python(8274): <= __contains__ in Lib/_abcoll.py:366 

where the columns are: 

• time in microseconds since start of script 

• name of executable 

• PID of process 

and the remainder indicates the call/return hierarchy as the script executes. 

For a –enable-shared build of CPython, the markers are contained within the libpython shared library, and the probe’s dotted path needs to reflect this. For example, this line from the above example: 

probe process("python").mark("function__entry") { 

should instead read: 

probe 

(assuming a debug build of CPython 3.6) 

## 4 Available static markers 

function__entry(str filename, str funcname, int lineno) 

This marker indicates that execution of a Python function has begun. It is only triggered for pure-Python (bytecode) functions. 

The filename, function name, and line number are provided back to the tracing script as positional arguments, which must be accessed using$_{$arg1}$ ,$_{$arg2}$ ,$_{$arg3}$ : 

• $arg1 :$_{(const char *)}$ filename, accessible using$_{user_string($arg1)}$ 

• $arg2 :$_{(const char *)}$ function name, accessible using$_{user_string($arg2)}$ 

• $arg3 :$_{int}$ line number 

function__return(str filename, str funcname, int lineno) 

This marker is the converse of$_{function__entry()}$ , 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. 

The arguments are the same as for$_{function__entry()}$ 

