Welcome to Ghostly Debugger – a modern, extensible Python debugger for educational and professional use. Ghostly Debugger offers advanced features such as conditional breakpoints, variable watchpoints, variable history, interactive variable modification, call stack inspection, and more, all from a powerful command-line interface.
Set breakpoints at any file and line, with optional conditions, hit counts, and temporary status.
# Example: Set a conditional breakpoint
ghost_debugger.set_breakpoint('myfile.py', 15, condition='result > 20')Monitor the value of any Python expression during execution.
# Example: Add a watch expression
ghost_debugger.add_watch_expression('result')Pause execution automatically when a variable's value changes.
# Example: Set a watchpoint on a variable
ghost_debugger.set_watchpoint('result')Track and inspect the history of variable values during debugging.
# Variable history is tracked automatically for watched variablesModify variables on-the-fly during a paused debugging session.
# Interactive variable modification is prompted during inspectionView the call stack and navigate between frames.
# Inspect the call stack
ghost_debugger.inspect_call_stack()Break on all or uncaught exceptions, and inspect tracebacks.
# Set exception break mode
# In the debugger command loop: except all | except uncaughtList and inspect running threads (switching is informational only).
# In the debugger command loop: threadsA rich CLI for stepping, continuing, setting/clearing breakpoints, watchpoints, evaluating expressions, and more.
# Example commands in the debugger prompt:
continue, step, next, out, bt, frame <idx>, break <file> <line> [cond=EXPR] [hit=N] [temp],
enable <file> <line>, disable <file> <line>, clear <file> <line>,
watch <expr>, watch remove <expr>, watchpoint <var>, watchpoint clear <var>,
threads, thread <ident>, eval <expr>, loglevel <level>, except all|uncaught, help
-
Installation:
- Install Ghostly Debugger using pip (if published) or clone the repository.
pip install ghostly_debugger # or clone and use directly -
Importing Ghostly Debugger:
from ghostly_debugger import GhostlyDebugger ghost_debugger = GhostlyDebugger()
-
Setting Up Your Code:
- Create an instance and configure breakpoints, watchpoints, or expressions as needed.
ghost_debugger.set_breakpoint('<string>', 15, condition='result > 20') ghost_debugger.add_watch_expression('result') ghost_debugger.set_watchpoint('result')
-
Executing Your Code:
- Run your code with the debugger:
code_to_debug = """ def calculate(): x = 5 y = 3 result = x * y return result def main(): z = 2 result = calculate() + z return result result = main() print('Result:', result) """ ghost_debugger.run_with_debugger(code_to_debug)
-
Using the Debugger CLI:
- When execution pauses, use the interactive prompt to step, inspect, modify, and control execution.
- Added variable watchpoints (break on change)
- Improved command-line interface and help
- Enhanced variable inspection and modification
- Thread awareness and exception break modes
- Initial release: breakpoints, watch expressions, variable tracking, interactive modification, call stack inspection, and more.
Contributions are welcome! Fork the repository, make improvements, and submit pull requests.
This project is licensed under the GNU AGPL v3 License.