Usage
Examples
Arguments
JavaScript or TypeScript file to debug
Debugger Interface
When launched, the debugger shows:Interface Components
Header
Shows current execution state:Code View
Displays source code with:- Line numbers
- Current line indicator (
►) - Surrounding context
- Breakpoint markers
Console Panel
Shows program output:console.log()outputconsole.error()output- Program results
Call Stack
Displays current function call chain:Debugger Commands
Resume
Resume
Continue execution until next breakpoint or completionShortcut:
F5 or Continue buttonStep Over
Step Over
Execute current line and pause at next lineShortcut:
F10 or Step Over buttonDoes not step into function callsStep In
Step In
Step into function callsShortcut:
F11 or Step In buttonPauses at first line of called functionStep Out
Step Out
Continue until current function returnsShortcut:
Shift+F11 or Step Out buttonResumes execution until function exitBreakpoints
Set breakpoints during debugging:- Navigate to desired line
- Toggle breakpoint
- Execution pauses when breakpoint is reached
Breakpoint functionality is implemented through the debugger UI. The exact mechanism is still being refined.
Example Session
Step through code
Press
Step Over to execute line by lineWatch variables and output in console panelCode Instrumentation
The debugger works by:- Parsing source: Reading your JavaScript/TypeScript
- Injecting hooks: Adding profiling calls at each line and function
- Executing: Running instrumented code
- Intercepting: Pausing at hooks and showing UI
TypeScript Support
Console Output
Program output appears in the console panel:Call Stack Navigation
The call stack shows function call hierarchy:- Deepest function is rightmost
- Caller chain shows execution path
- Updates as you step through code
Limitations
- Limited variable inspection
- No watch expressions
- No conditional breakpoints
- No call stack navigation (view only)
- Terminal UI may have rendering issues
- Not all JavaScript features supported
- May crash or behave unexpectedly
When to Use Debug Mode
Understanding code flow
Understanding code flow
Step through unfamiliar code to understand execution order
Finding crashes
Finding crashes
Identify exactly where errors occur
Validating logic
Validating logic
Verify conditional branches and loops work correctly
Inspecting simple state
Inspecting simple state
View console output at specific points
Alternative Debugging
For more robust debugging:Troubleshooting
Debugger won’t start
UI rendering issues
- Resize terminal window
- Try different terminal emulator
- Check terminal supports ANSI colors
Breakpoints not working
- Ensure line has executable code
- Try stepping manually with Step Over
- Check if feature is fully implemented
Crashes during debugging
- Report issue on GitHub
- Try simpler code first
- Use alternative debugging methods
Debugger Architecture
Underneath, the debugger:- Injects profiling hooks (
profile1,profile2) - Hooks fire before/after each line and function
- UI library (Byg) renders interface
- User input controls execution flow
- Console output is captured and displayed
Future Improvements
Planned enhancements:- Variable inspection and watch expressions
- Conditional breakpoints
- Call stack navigation
- Memory inspection
- Expression evaluation
- Better UI/UX
Providing Feedback
Since this feature is experimental:- Report bugs on GitHub
- Describe what works/doesn’t work
- Share use cases and needs
- Contribute improvements
Comparison with Other Debuggers
| Feature | porf debug | Node.js debugger | Browser DevTools |
|---|---|---|---|
| Interactive | ✓ | ✓ | ✓ |
| Breakpoints | Limited | ✓ | ✓ |
| Variable inspection | ✗ | ✓ | ✓ |
| Watch expressions | ✗ | ✓ | ✓ |
| Call stack | View only | ✓ | ✓ |
| Terminal UI | ✓ | ✓ | ✗ |
| Maturity | Experimental | Stable | Stable |
Related Tools
Profile
Performance profiling
Run with -d
Debug compilation issues
REPL
Interactive exploration
Overview
All CLI commands