The Trace Utils Extension helps you seamlessly add tracing points to your Python code and visualize execution flow using DOT graphs. With intuitive features and quick setup, this extension is a powerful tool for debugging and understanding your Python scripts.
Features
Insert Trace Points: Add tracing points in your Python code with a single click.
Execution Visualization: Generate DOT graphs to visualize the code's execution flow.
Preview Graphs: Open and view DOT files with any Graphviz extension.
Requirements
Python 3.x installed and available in PATH
VS Code 1.65.0 or higher (preferred 1.96.0)
Python's matplotlib module
pip3 install matplotlib
python3 -m pip show matplotlib (Verify)
Installation
Install the extension from VS Code Marketplace
Open a Python file
Look for the trace buttons in the editor title bar
Usage
Adding Trace Points
Click the "Insert Trace Points" button in the editor title bar.
It will add a new Trace Terminal.
Enter two line numbers where you want to start and stop tracing, adjust accordingly.
The extension will automatically add the required imports and tracing functions.
Note:
If tracing points need to be added in different files:
Manually add start_tracing() and stop_tracing() at the desired locations in their respective files.
In both files, add the following import statement at the top (if not already present):
from trace_utils import start_tracing, stop_tracing
Generating Visualization
Run your Python code with the trace points in Trace Terminal.
A log file will be generated in the current working directory.
Click the "Generate Dot" button in the editor title bar
A output.dot file will be generated in your workspace
Use a Graphviz extension or external viewer to open and view the generated DOT graph.