296 lines
6.6 KiB
HTML
296 lines
6.6 KiB
HTML
|
<!DOCTYPE HTML>
|
||
|
<HTML LANG="en-us"
|
||
|
><HEAD
|
||
|
><TITLE
|
||
|
>*debugger-hook* | Common Lisp Nova Spec</TITLE
|
||
|
><META CHARSET="US-ASCII"
|
||
|
><LINK REL="canonical" HREF="v_debugger-hook.html"
|
||
|
><LINK REL="next" HREF="v_break-on-signals.html" TYPE="text/html" TITLE="*break-on-signals*"
|
||
|
><LINK REL="prev" HREF="f_break.html" TYPE="text/html" TITLE="break"
|
||
|
><LINK REL="up" HREF="9_2_Conditions_Dictionary.html" TYPE="text/html" TITLE="9.2 Conditions Dictionary"
|
||
|
><LINK REL="start" HREF="index.html" TYPE="text/html" TITLE="Common Lisp Nova Spec"
|
||
|
><META NAME="VIEWPORT" CONTENT="width=device-width, initial-scale=1.0"
|
||
|
><LINK REL="STYLESHEET" HREF="dpans.css%3F3909942064.css"
|
||
|
><SCRIPT SRC="dpans.js%3F3909942064"
|
||
|
></SCRIPT
|
||
|
><SCRIPT SRC="apropos.js%3F3909942064"
|
||
|
></SCRIPT
|
||
|
></HEAD
|
||
|
><BODY
|
||
|
><DIV
|
||
|
><DIV CLASS="topnav"
|
||
|
><DIV CLASS="breadcrumb"
|
||
|
><SPAN CLASS="breadcrumb-item"
|
||
|
><A HREF="index.html"
|
||
|
>Common Lisp Nova Spec</A
|
||
|
></SPAN
|
||
|
> <SPAN CLASS="breadcrumb-item"
|
||
|
>→ <A HREF="9_Conditions.html"
|
||
|
>9. Conditions</A
|
||
|
></SPAN
|
||
|
> <SPAN CLASS="breadcrumb-item"
|
||
|
>→ <A HREF="9_2_Conditions_Dictionary.html"
|
||
|
>9.2 Conditions Dictionary</A
|
||
|
></SPAN
|
||
|
> <SPAN CLASS="breadcrumb-item"
|
||
|
>→ <A HREF="v_debugger-hook.html"
|
||
|
>*debugger-hook*</A
|
||
|
></SPAN
|
||
|
></DIV
|
||
|
><DIV CLASS="apropos"
|
||
|
><DIV CLASS="apropos-io"
|
||
|
><A HREF="f_break.html" CLASS="prev"
|
||
|
>←</A
|
||
|
><SPAN ID="apropos-label"
|
||
|
>Apropos </SPAN
|
||
|
><INPUT ID="apropos" AUTOFOCUS="AUTOFOCUS" PLACEHOLDER="Type here to search" ONINPUT="aproposInput(this);" ONKEYUP="aproposKeyup(event);" ONCHANGE="aproposChange(this);" ONFOCUS="aproposFocus(this);" ONFOCUSOUT="aproposFocusout(this);"
|
||
|
><A HREF="v_break-on-signals.html" CLASS="next"
|
||
|
>→</A
|
||
|
></DIV
|
||
|
><DIV ID="apropos-res"
|
||
|
></DIV
|
||
|
></DIV
|
||
|
></DIV
|
||
|
><DIV CLASS="matter"
|
||
|
><DIV CLASS="com"
|
||
|
><DIV CLASS="begincom"
|
||
|
><HR
|
||
|
><TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0"
|
||
|
><TR
|
||
|
><TD ALIGN="LEFT" VALIGN="BASELINE" WIDTH="100%" CLASS="name"
|
||
|
><SPAN CLASS="idx" DATA-KIND="idxref" DATA-TERM="*debugger-hook*"
|
||
|
></SPAN
|
||
|
><SPAN CLASS="cmsy"
|
||
|
>*</SPAN
|
||
|
><B
|
||
|
>debugger-hook</B
|
||
|
><SPAN CLASS="cmsy"
|
||
|
>*</SPAN
|
||
|
></TD
|
||
|
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
|
||
|
><I
|
||
|
>Variable</I
|
||
|
></TD
|
||
|
></TR
|
||
|
></TABLE
|
||
|
><HR
|
||
|
></DIV
|
||
|
><UL CLASS="subtoc"
|
||
|
></UL
|
||
|
><DL
|
||
|
><DT
|
||
|
><B
|
||
|
>Value Type</B
|
||
|
></DT
|
||
|
><DD
|
||
|
><P CLASS="j"
|
||
|
>a <A HREF="26_1_Glossary.html#designator"
|
||
|
><EM CLASS="term"
|
||
|
>designator</EM
|
||
|
></A
|
||
|
> for a <A HREF="26_1_Glossary.html#function"
|
||
|
><EM CLASS="term"
|
||
|
>function</EM
|
||
|
></A
|
||
|
> of two <A HREF="26_1_Glossary.html#argument"
|
||
|
><EM CLASS="term"
|
||
|
>arguments</EM
|
||
|
></A
|
||
|
> (a <A HREF="26_1_Glossary.html#condition"
|
||
|
><EM CLASS="term"
|
||
|
>condition</EM
|
||
|
></A
|
||
|
> and the <A HREF="26_1_Glossary.html#value"
|
||
|
><EM CLASS="term"
|
||
|
>value</EM
|
||
|
></A
|
||
|
> of <A HREF="v_debugger-hook.html" CLASS="misc"
|
||
|
><B
|
||
|
>*debugger-hook*</B
|
||
|
></A
|
||
|
> at the time the debugger was entered), or <SPAN CLASS="misc"
|
||
|
><B
|
||
|
>nil</B
|
||
|
></SPAN
|
||
|
>.</P
|
||
|
></DD
|
||
|
><DT
|
||
|
><B
|
||
|
>Initial Value</B
|
||
|
></DT
|
||
|
><DD
|
||
|
><P CLASS="j"
|
||
|
><SPAN CLASS="misc"
|
||
|
><B
|
||
|
>nil</B
|
||
|
></SPAN
|
||
|
>.</P
|
||
|
></DD
|
||
|
><DT
|
||
|
><B
|
||
|
>Description</B
|
||
|
></DT
|
||
|
><DD
|
||
|
><P CLASS="j"
|
||
|
>When the <A HREF="26_1_Glossary.html#value"
|
||
|
><EM CLASS="term"
|
||
|
>value</EM
|
||
|
></A
|
||
|
> of <A HREF="v_debugger-hook.html" CLASS="misc"
|
||
|
><B
|
||
|
>*debugger-hook*</B
|
||
|
></A
|
||
|
> is <A HREF="26_1_Glossary.html#non-nil"
|
||
|
><EM CLASS="term"
|
||
|
>non-nil</EM
|
||
|
></A
|
||
|
>, it is called prior to normal entry into the debugger, either due to a call to <A HREF="f_invoke-debugger.html" CLASS="funref"
|
||
|
><B
|
||
|
>invoke-debugger</B
|
||
|
></A
|
||
|
> or due to automatic entry into the debugger from a call to <A HREF="f_error.html" CLASS="funref"
|
||
|
><B
|
||
|
>error</B
|
||
|
></A
|
||
|
> or <A HREF="f_cerror.html" CLASS="funref"
|
||
|
><B
|
||
|
>cerror</B
|
||
|
></A
|
||
|
> with a condition that is not handled. The <A HREF="26_1_Glossary.html#function"
|
||
|
><EM CLASS="term"
|
||
|
>function</EM
|
||
|
></A
|
||
|
> may either handle the <A HREF="26_1_Glossary.html#condition"
|
||
|
><EM CLASS="term"
|
||
|
>condition</EM
|
||
|
></A
|
||
|
> (transfer control) or return normally (allowing the standard debugger to run). To minimize recursive errors while debugging, <A HREF="v_debugger-hook.html" CLASS="varref"
|
||
|
><B
|
||
|
>*debugger-hook*</B
|
||
|
></A
|
||
|
> is bound to <SPAN CLASS="misc"
|
||
|
><B
|
||
|
>nil</B
|
||
|
></SPAN
|
||
|
> by <A HREF="f_invoke-debugger.html" CLASS="funref"
|
||
|
><B
|
||
|
>invoke-debugger</B
|
||
|
></A
|
||
|
> prior to calling the <A HREF="26_1_Glossary.html#function"
|
||
|
><EM CLASS="term"
|
||
|
>function</EM
|
||
|
></A
|
||
|
>.</P
|
||
|
></DD
|
||
|
><DT
|
||
|
><B
|
||
|
>Examples</B
|
||
|
></DT
|
||
|
><DD
|
||
|
><PRE CLASS="screen"
|
||
|
> (defun one-of (choices &optional (prompt "Choice"))
|
||
|
(let ((n (length choices)) (i))
|
||
|
(do ((c choices (cdr c)) (i 1 (+ i 1)))
|
||
|
((null c))
|
||
|
(format t "~&[~D] ~A~%" i (car c)))
|
||
|
(do () ((typep i `(integer 1 ,n)))
|
||
|
(format t "~&~A: " prompt)
|
||
|
(setq i (read))
|
||
|
(fresh-line))
|
||
|
(nth (- i 1) choices)))
|
||
|
|
||
|
(defun my-debugger (condition me-or-my-encapsulation)
|
||
|
(format t "~&Fooey: ~A" condition)
|
||
|
(let ((restart (one-of (compute-restarts))))
|
||
|
(if (not restart) (error "My debugger got an error."))
|
||
|
(let ((*debugger-hook* me-or-my-encapsulation))
|
||
|
(invoke-restart-interactively restart))))
|
||
|
|
||
|
(let ((*debugger-hook* #'my-debugger))
|
||
|
(+ 3 'a))
|
||
|
<SPAN CLASS="cmr"
|
||
|
>⊳</SPAN
|
||
|
> Fooey: The argument to +, A, is not a number.
|
||
|
<SPAN CLASS="cmr"
|
||
|
>⊳</SPAN
|
||
|
> [1] Supply a replacement for A.
|
||
|
<SPAN CLASS="cmr"
|
||
|
>⊳</SPAN
|
||
|
> [2] Return to Cloe Toplevel.
|
||
|
<SPAN CLASS="cmr"
|
||
|
>⊳</SPAN
|
||
|
> Choice: 1
|
||
|
<SPAN CLASS="cmr"
|
||
|
>⊳</SPAN
|
||
|
> Form to evaluate and use: (+ 5 'b)
|
||
|
<SPAN CLASS="cmr"
|
||
|
>⊳</SPAN
|
||
|
> Fooey: The argument to +, B, is not a number.
|
||
|
<SPAN CLASS="cmr"
|
||
|
>⊳</SPAN
|
||
|
> [1] Supply a replacement for B.
|
||
|
<SPAN CLASS="cmr"
|
||
|
>⊳</SPAN
|
||
|
> [2] Supply a replacement for A.
|
||
|
<SPAN CLASS="cmr"
|
||
|
>⊳</SPAN
|
||
|
> [3] Return to Cloe Toplevel.
|
||
|
<SPAN CLASS="cmr"
|
||
|
>⊳</SPAN
|
||
|
> Choice: 1
|
||
|
<SPAN CLASS="cmr"
|
||
|
>⊳</SPAN
|
||
|
> Form to evaluate and use: 1
|
||
|
<SPAN CLASS="cmsy"
|
||
|
><SPAN CLASS="arrow"
|
||
|
>→</SPAN
|
||
|
></SPAN
|
||
|
> 9</PRE
|
||
|
></DD
|
||
|
><DT
|
||
|
><B
|
||
|
>Affected By</B
|
||
|
></DT
|
||
|
><DD
|
||
|
><P CLASS="j"
|
||
|
><A HREF="f_invoke-debugger.html" CLASS="funref"
|
||
|
><B
|
||
|
>invoke-debugger</B
|
||
|
></A
|
||
|
></P
|
||
|
></DD
|
||
|
><DT
|
||
|
><B
|
||
|
>Notes</B
|
||
|
></DT
|
||
|
><DD
|
||
|
><P CLASS="j"
|
||
|
>When evaluating code typed in by the user interactively, it is sometimes useful to have the hook function bind <A HREF="v_debugger-hook.html" CLASS="varref"
|
||
|
><B
|
||
|
>*debugger-hook*</B
|
||
|
></A
|
||
|
> to the <A HREF="26_1_Glossary.html#function"
|
||
|
><EM CLASS="term"
|
||
|
>function</EM
|
||
|
></A
|
||
|
> that was its second argument so that recursive errors can be handled using the same interactive facility.</P
|
||
|
></DD
|
||
|
></DL
|
||
|
></DIV
|
||
|
></DIV
|
||
|
><DIV CLASS="footer"
|
||
|
><DIV CLASS="btmnav"
|
||
|
><A HREF="f_break.html" CLASS="prev"
|
||
|
>←</A
|
||
|
><A HREF="v_break-on-signals.html" CLASS="next"
|
||
|
>→</A
|
||
|
></DIV
|
||
|
><DIV CLASS="trail"
|
||
|
>Conversion to HTML copyright 2023 by Gilbert Baumann</DIV
|
||
|
></DIV
|
||
|
></DIV
|
||
|
><SCRIPT
|
||
|
>domReady();</SCRIPT
|
||
|
></BODY
|
||
|
></HTML
|
||
|
>
|