🐛 DevLog: Integrated LLDB Debugging - Native-Level Debugging for Pascal #13
jarroddavis68
started this conversation in
DevLog
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Version: JetPascal 0.3.0+
🎉 What's New
JetPascal now includes a full-featured, interactive debugger powered by LLDB-DAP. You can set breakpoints, step through code, inspect variables, and debug your Pascal programs at the source level - even though they're compiled to C++ and optimized by LLVM.
Write Pascal. Debug Pascal. Get native performance.
💡 What This Means
You can now:
✅ Set breakpoints in Pascal source files
✅ Step through code (over, into, out)
✅ Inspect local variables and expressions
✅ View call stacks with Pascal function names
✅ Restart debugging sessions instantly
✅ Evaluate expressions at runtime
✅ See source context with line highlighting
✅ Debug multi-threaded programs
All from a native interactive REPL with zero external tools required.
📝 What the Debugging Experience Looks Like
Here's a complete debugging session:
Every command is interactive. Every response is instant. This is professional-grade debugging.
🔬 Real Features We've Implemented
1. Source-Level Breakpoints
The Magic: Set breakpoints in your Pascal source code, even though the executable is compiled C++.
In the debugger:
How It Works: JetPascal generates
#linedirectives in the C++ output that map back to Pascal source locations. LLDB uses these to set breakpoints at the correct addresses.Why It Matters: You debug Pascal code, not generated C++. The transpilation layer is invisible.
2. Interactive Stepping
Single-Step Debugging: Navigate through your code line by line.
Real Session:
Why It Matters: Full control over execution flow. Step into your functions, skip over library calls, jump out when done.
3. Variable Inspection
Real-Time State: See what's in memory at any point.
Advanced Inspection:
Why It Matters: No more "print debugging". See variable values, evaluate expressions, inspect complex structures - all at runtime.
4. Call Stack Navigation
Trace Execution: See exactly how you got to the current line.
Notice:
Why It Matters: Understand the execution path. Find where bugs originate. See who called what.
5. Source Context Display
Visual Debugging: See where you are in the code.
The
->shows current execution line. 2 lines before and after for context. Auto-updates after every step.After stepping into Add:
Why It Matters: Never lose your place. Always know what's executing. Context helps you think.
6. Instant Restart
Fastest Iteration: Restart debugging without rebuilding.
What Happens:
All in under 2 seconds.
Why It Matters: Test, tweak, restart. No rebuilding. No re-setting breakpoints. Just debug.
7. Multi-Threaded Debugging
Thread-Aware: Debug concurrent programs.
Switch Contexts:
Each thread has its own:
Why It Matters: Debug race conditions, deadlocks, and concurrent logic with full visibility.
8. Expression Evaluation
Interactive Computation: Calculate anything at runtime.
Full C++ Expression Support:
+,-,*,/<,>,==,!=std::sqrt(),.length()Why It Matters: Test hypotheses without modifying code. Validate calculations. Explore state dynamically.
💻 Architecture: How It Works
The Stack
Key Components
1. TDebug Class
2. TDebugREPL Class
3. #line Directives
Generated in C++ output:
These map C++ line numbers back to Pascal source.
4. LLDB-DAP Protocol
State Machine
Transitions:
Start()→ dsInitializingInitialize()→ dsReadyLaunch()→ dsLaunched → dsRunningWhy This Matters: Clean state management prevents race conditions and ensures reliable debugging.
🎯 What Makes This Special
Native LLDB Integration
We don't write our own debugger. We leverage LLDB - the same debugger used by Xcode, VS Code, and Android Studio. Battle-tested. Production-ready.
Source-Level Fidelity
Even though your Pascal compiles to C++ and then to native code, you debug Pascal source. The
#linedirectives ensure perfect mapping.Zero External Dependencies
LLDB-DAP ships with JetPascal. No installation. No configuration. Just run.
Full Protocol Support
We implement the complete DAP specification:
Cross-Platform Ready
LLDB runs on Windows, Linux, and macOS. Your debugging experience is identical across platforms.
🚦 Current Status
✅ Fully Working
These are feature additions, not bugs. The core debugging works perfectly.
🔮 Coming Soon
b file.pas:32 if X > 10)Happy Debugging! 🐛
JetPascal™ - Accelerate Your Code!
Technical Note: This debugger uses LLDB-DAP (Debug Adapter Protocol) which is the universal standard for debugger integration. The same protocol powers VS Code, Vim, Emacs, and most modern IDEs. By supporting DAP, JetPascal ensures compatibility with the entire debugging ecosystem. Our implementation handles the full DAP specification including: launch, attach, breakpoints, stepping, variables, evaluation, threads, and stack traces. The
TDebugclass manages protocol communication, whileTDebugREPLprovides the interactive shell. Future GUI integrations will use this same foundation.Beta Was this translation helpful? Give feedback.
All reactions