Call Stack to PlantUML

A Visual Studio Code extension that captures call stacks from debug sessions and converts them into PlantUML Activity Diagrams, helping you visualize and document complex execution flows.
�🎯 Features
Core Capabilities
- 📸 Capture Call Stacks: Extract call stack information from any active debug session
- 🎨 Generate PlantUML Diagrams: Automatically convert call stacks into PlantUML Activity Diagram syntax
- 🌳 Multi-Path Support: Record multiple call stack paths and intelligently merge them into a tree structure
- � Auto-Reset on New Session: Automatically clears recorded call stacks when starting a new debug session
- �📋 Clipboard Integration: Copy generated PlantUML scripts directly to your clipboard
- 🔧 Configurable: Customize diagram line length for optimal readability
- 🧵 Thread Selection: Choose which thread to capture when debugging multi-threaded applications
Benefits
- Visual Documentation: Transform abstract call stacks into clear, visual diagrams
- Debugging Aid: Better understand complex execution flows during debugging
- Code Review: Share execution paths with team members using standardized UML
- Architecture Analysis: Document and analyze actual program behavior
📦 Installation
From VS Code Marketplace
- Open VS Code
- Go to Extensions (
Ctrl+Shift+X / Cmd+Shift+X)
- Search for "Call Stack to PlantUML"
- Click Install
From Command Line
code --install-extension JianpingCai.call-stack-to-plantuml
Manual Installation
- Download the
.vsix file from GitHub Releases
- In VS Code, go to Extensions view
- Click the
... menu → Install from VSIX...
- Select the downloaded file
🚀 Usage
Quick Start
- Start Debugging: Open your project and start a debug session (
F5)
- Hit a Breakpoint: Pause execution at a breakpoint
- Open Command Palette: Press
Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac)
- Run Command: Type and select "Copy Call Stack to PlantUML"
- Select Thread: Choose the thread you want to capture from the dropdown
- Paste & Visualize: Paste the copied PlantUML script into a PlantUML editor
Available Commands
| Command |
Description |
Use Case |
| Copy Call Stack to PlantUML |
Records current call stack and copies PlantUML script to clipboard |
Quick one-shot capture and export |
| Record Call Stack |
Records and merges current call stack into the tree without copying |
Building complex multi-path diagrams |
| Clear Recorded Call Stack |
Resets all recorded call stacks |
Starting fresh or debugging new scenario |
Advanced Workflow: Multi-Path Diagrams
For applications with multiple execution paths (e.g., conditional branches, callbacks):
Record First Path:
- Hit first breakpoint
- Run "Record Call Stack"
Record Additional Paths:
- Continue execution (
F5)
- Hit another breakpoint (different path)
- Run "Record Call Stack" again
- Repeat for all paths you want to capture
Generate Diagram:
- Run "Copy Call Stack to PlantUML"
- The extension merges all paths into a unified diagram
Clear When Done:
- Run "Clear Recorded Call Stack" to reset manually
- Note: The extension automatically resets when you start a new debug session
PlantUML Visualization
Once you've copied the PlantUML script, visualize it using:
Online Editors
VS Code Extensions
Local Rendering
# Install PlantUML locally
brew install plantuml # macOS
# or download from https://plantuml.com/download
# Generate diagram
plantuml diagram.puml
⚙️ Configuration
Settings
Configure the extension in your VS Code settings.json:
{
"call-stack-to-plantuml.maxLength": 60
}
| Setting |
Type |
Default |
Description |
call-stack-to-plantuml.maxLength |
number |
60 |
Maximum line length for function names in diagrams before word wrapping is applied |
Accessing Settings
Via UI:
- Open Settings (
Ctrl+, / Cmd+,)
- Search for "call-stack-to-plantuml"
Via settings.json:
- Open Command Palette
- Type "Preferences: Open User Settings (JSON)"
- Add the configuration
Example Configurations
Compact Diagrams (for wide displays):
{
"call-stack-to-plantuml.maxLength": 100
}
Narrow Diagrams (for documentation):
{
"call-stack-to-plantuml.maxLength": 40
}
📖 Examples
Example Output
Captured Call Stack:
main() → processData() → validateInput() → sanitizeString()
Generated PlantUML:
@startuml
start
:main;
:processData;
:validateInput;
:sanitizeString;
stop
@enduml
Multi-Path Example
Scenario: Application with conditional logic
function main() {
if (condition) {
pathA();
} else {
pathB();
}
}
Recording Process:
- Set breakpoint in
pathA() → Record
- Set breakpoint in
pathB() → Record
- Copy to PlantUML
Generated Diagram shows split execution paths:
@startuml
start
:main;
split
:pathA;
split again
:pathB;
end split
stop
@enduml
🎓 Use Cases
1. Debugging Complex Logic
Visualize the actual execution flow through complex nested function calls.
2. Code Documentation
Generate diagrams for documentation that accurately reflect runtime behavior.
Identify call stack depth and redundant function calls.
4. Code Review
Share execution paths with team members for better code understanding.
5. Learning & Teaching
Help developers understand program flow in unfamiliar codebases.
🔍 Supported Debuggers
This extension works with any VS Code debugger that implements the Debug Adapter Protocol (DAP), including:
- JavaScript/TypeScript: Node.js, Chrome DevTools
- Python: Python Debugger
- C/C++: GDB, LLDB
- Java: Java Debug Server
- Go: Delve
- C#: .NET Debugger
- And many more...
🛠️ Troubleshooting
Common Issues
No threads available
- Ensure your debug session is active and paused at a breakpoint
- Some debuggers may not support thread enumeration
Call stack not captured
- Verify you've selected a thread from the dropdown
- Check that the debugger supports stack trace requests
Generated diagram looks wrong
- Try adjusting the
maxLength configuration
- Ensure the PlantUML syntax is valid in your editor
Extension not activating
- Check VS Code version compatibility (requires
^1.76.0)
- Reload VS Code window (
Developer: Reload Window)
Getting Help
- Check existing GitHub Issues
- Create a new issue with:
- VS Code version
- Extension version
- Debugger being used
- Steps to reproduce the problem
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Quick Contribution Guide
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature
- Make your changes
- Add tests if applicable
- Commit with clear messages:
git commit -m "Add: feature description"
- Push to your fork:
git push origin feature/my-feature
- Open a Pull Request
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
📝 Changelog
See CHANGELOG.md for version history and release notes.
🙏 Acknowledgments
- VS Code Team - For the excellent extensibility API and debug protocol
- PlantUML - For providing a powerful, text-based diagramming language
- Contributors - Thank you to everyone who has contributed to this project
📚 Resources
💡 Tips & Best Practices
- Clear between sessions: Reset the call stack tree when switching to different debugging scenarios
- Use meaningful breakpoints: Place breakpoints at key decision points for better diagrams
- Adjust maxLength: Experiment with different values to find what works best for your code style
- Combine with PlantUML extensions: Install a PlantUML viewer in VS Code for seamless workflow
Enjoy visualizing your code execution flows! ⭐
If you find this extension helpful, please consider: