Tools/Debugging/Python Trace

= Tracing Python Code =

Tracing code is a handy way to check what the code is doing, where stepping over line by line is impractical.

If a certain operation isn't behaving properly you can trace the execution of the working & failing state, then view their differences to see at which point the code-path diverges.

The 'trace' module
This example shows how to use the trace Python module to trace script execution.

https://developer.blender.org/diffusion/B/browse/master/release/scripts/modules/bpy/__init__.py;711e3564b808ab802c503409e7740b0ca9b6ef65$68

The function call shows:

This example shows how a the function call can be traced.

This traces all script execution on startup (addon registration, module imports... etc).

Heres an example of what the output may look like.

-- snip (around 40k lines) --