Rui Patroc�nio <[EMAIL PROTECTED]> writes:
> I'm trying to call "my top level" when the "return to top level" is
> invoked in the debugger, but I'm having some troubles. I suppose I
> should handle the abort restart... Am I close?
> Any help please?
Not sure what you mean with "handle the abort restart". If you bind an
abort restart like:
(defun my-toplevel ()
(loop
(with-simple-restart (abort "Return to my top level.")
(invoke-debugger)))
then the "real toplevel" restart is still visible in the debugger:
Restarts:
0: [abort] Return to my top level
1: Return to Top-Level.
You could use your own *debugger-hook* and invoke the "real" debugger
in a slightly different way, e.g:
(defun my-debugger-hook (h condition)
(declare (ignore h))
(unix:unix-sigsetmask 0)
(let* ((*debugger-hook* nil)
(debug::*debug-condition* condition)
(debug::*debug-restarts* (butlast (compute-restarts condition)))
;; ^^^^^^^^ this is the interesting part
(*standard-input* *debug-io*)
(*standard-output* *debug-io*)
(*error-output* *debug-io*))
(debug::real-invoke-debugger condition)))
(defun my-toplevel ()
(loop
(with-simple-restart (abort "Return to my top level")
(let ((*debugger-hook* #'my-debugger-hook))
(invoke-debugger))))
This will only list your own restart. You probaly also want to
redefine the Quit debugger command, or catch the
'lisp::top-level-catcher tag.
--helmut.