1 Enabling the static markers macOS comes with built-in support for DTrace. On Linux, in order to build CPython with the embedded markers for SystemTap, the SystemTap development tools must be installed. On a Linux machine, this can be done via: $ yum install systemtap-sdt-devel or: $ sudo apt-get install systemtap-sdt-dev CPython must then be configured --with-dtrace : checking for --with-dtrace... yes On macOS, you can list available DTrace probes by running a Python process in the background and listing all probes made available by the Python provider: On Linux, you can verify if the SystemTap static markers are present in the built binary by seeing if it contains a “.note.stapsdt” section. If you’ve built Python as a shared library (with –enable-shared), you need to look instead within the shared library. For example: $ readelf -S ./python | grep .note.stapsdt [30] .note.stapsdt NOTE 0000000000000000 00308d78 $ readelf -S libpython3.3dm.so.1.0 | grep .note.stapsdt [29] .note.stapsdt NOTE 0000000000000000 00365b68 Sufficiently modern readelf can print the metadata: 2 (continues on next page) $ readelf -n ./python Displaying notes found at file offset 0x00000254 with length 0x00000020: Owner Data size Description GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag) OS: Linux, ABI: 2.6.32 Displaying notes found at file offset 0x00000274 with length 0x00000024: Owner Data size Description GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID␣ ↪ → bitstring) Build ID: df924a2b08a7e89f6e11251d4602022977af2670 $ python3.6 -q & $ sudo dtrace -l -P python $! # or: dtrace -l -m python3.6 ID PROVIDER MODULE FUNCTION NAME 29564 python18035python3.6 _PyEval_EvalFrameDefault function-entry 29565 python18035python3.6 dtrace_function_entry function-entry 29566 python18035python3.6 _PyEval_EvalFrameDefault function- ↪ → return 29567 python18035python3.6 dtrace_function_return function- ↪ → return 29568 python18035python3.6 collect gc-done 29569 python18035python3.6 collect gc-start 29570 python18035python3.6 _PyEval_EvalFrameDefault line 29571 python18035python3.6 maybe_dtrace_line line