230 likes | 396 Views
Source Level Debugging in Allegro CL. By Duane Rettig with Willem Broekema. March, 2009. Outline. Introduction Requirements and History Demos (both Lisp and Python) Design Issues and Future Work. Why has it taken so long?. Lisp is symbolic Lisp is dynamic Lisp has hooks
E N D
Source Level Debugging in Allegro CL By Duane Rettig with Willem Broekema March, 2009
Outline • Introduction • Requirements and History • Demos (both Lisp and Python) • Design • Issues and Future Work
Why has it taken so long? • Lisp is symbolic • Lisp is dynamic • Lisp has hooks • Debuggers don't tend to step through macros
Why Source Debugging Now? • Increasing needs • Compiled functions are getting more complex • More macro usage • Better compilation • More attention to optimization • New capabilities • Macros can now be stepped through
Design Requirements • Works by annotation, not by re-coding and/or recompilation • Annotations must be lazy-loaded • Similar operation between compiled, byte-compiled, interpreted code • Language agnostic • Command Line and GUI compatible
History of Allegro CL Source Debugging Effort • 1998: Promise made • 1999: First debugger paper (show demo)ftp://ftp.franz.com/pub/duane/break.ps • 2007: Resurgence of effort including CLPython • 2009: Command line version • ????: GUI versions
Lisp Demos • ltest.cl • Zoom on error demo • Coverage demo • Debugging the compiler
CLPython Demos • Willem will demo: • setting breakpoints • stepping • printing stack trace • debugging the CLPython compiler
Breakpointing Design Outline • Instruction level (break.ps) • Source mappings • Language Personalities • Backends
Instruction level design • Review break.ps, Figures 1-4
Source Mappings • Breakpoints (records) pre-built • Accessed by index • Level 0 records will point to source text • New slots in breakpoint structures • Language-dependent • Usually includes source form or string • Show dump-lisp-source for ltest
Language Personalities • Language structure, mostly with functions • Contents: • Name: currently :asm, :lisp, or :python • predicate: Function to test for appropriate debug info • find-pc: Function to • print-pc: Function to print line/form • prompt-loop: Function to prompt the user • set-next: Function to set next breakpoints • list-exits: Function to list possible slide directions • slide: Function to slide around in breakpoint set
Back-ends • Currently very primitive • Structure has two slots • a format function • a prompt-loop function • Show back-end for coverage code
lisp-breakpoint pseudo-code (defun sys::lisp-breakpoint (func pc) (uninstall-breakpoints) (let* ((bpt (get-breakpoint func pc)) (ratchet (breakpoint-is-ratchet bpt))) (cond ((and bpt (not ratchet)) (setq *slide-point* bpt) (let* ((lang (breakpoint-language bpt)) (command (call-prompt-loop language bpt))) (delete-temp-breakpoints) (call-set-next language bpt command))) (ratchet (delete-temp-breakpoints))) (install-breakpoints)))
CLPython Personality • Willem will discuss: • Mapping from Python source code to asm location: • Python Parser: mapping Python source to Lisp forms • Allegro CL: mapping Lisp forms to asm offsets • Python ldb language and backend based on that mapping • Source forms at finer granularity than line-level
Lisp Issues • Variables not yet propagated through macros • Local variable locations may not be saved to stack • Multiprocessing critical section issues
Variable Propagation through macros (defmacro foo (x y) (let ((x1 (gensym)) (y1 (gensym))) `(let ((,x1 ,x) (,y1 ,y)) ...))) • Variables will be displayed as gensyms in compiled code • No references to original x and y variables
Local Variable Locations (let ((x (foo)) (y (bar))) (bas x y)) • X will likely be on the stack soon after call to (foo) • Y might never be forced to the stack • Debugger must allow for non-stack variables
Multiprocessing Issues • Per-thread, or global? • Have lisp-breakpoint decide • Setup separate code-vectors per-thread • Lock out critical sections, or allow lisp death?
CLPython Issues • Willem will discuss: • proof of concept • mappings: Python code -> Lisp code -> asm code incomplete/incorrect • stepping “into” Python forms is buggy (crashing) • stack trace handling of non-compiled functions
Other Future Work (Lisp) • GUIs • CG • Emacs/Lisp Interface (ELI) • Slime • True back-stepping • Handle state at various levels • provide user interface for extending undo-ability • Other Language personalities • Lisp DSLs • Loop • CL<any-language>? CLJava? CL/XML? ...
Other Future Work (CLPython) • More debugger commands • run Python code within a stack frame • special stack trace showing Python and Lisp frames combined, to debug CLPython itself • robustly handling source module modifications • Year ????: a complete Lisp-based Python compiler and IDE, based on CLPython and Slime