• chevron_right


    Michał "phoe" Herda · Wednesday, 15 April, 2020 - 20:19

#Lisp #CommonLisp

I have managed to create a portability library that successfully overrides the standard Lisp debugger and allows the programmer to supply their own code in its stead.

Purpose: a basic building block that allows one to implement a portable, custom debugger for Common Lisp systems in place of the original system-provided one.

Roughly tested on SBCL, CCL, ECL, Clasp, CLISP, ABCL, LW, and ACL.

TRIVIAL-CUSTOM-DEBUGGER> (with-debugger ((lambda (condition hook)
                                           (declare (ignore hook))
                                           (format t ";; Debugging a ~S!~%" 
                                                   (type-of condition))
                                           (throw :handled t)))
                           (list (catch :handled (error 'error))
                                 (catch :handled (break))
                                 (let ((*break-on-signals* 'error))
                                   (catch :handled (signal 'error)))
                                 (catch :handled 
                                   (invoke-debugger (make-condition 'error)))))
;; Debugging a ERROR!
;; Debugging a SIMPLE-CONDITION!
;; Debugging a SIMPLE-CONDITION!
;; Debugging a ERROR!
(T T T T)

See it on GitHub.