summaryrefslogtreecommitdiff
path: root/devdocs/elisp/function-debugging.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/function-debugging.html
new repository
Diffstat (limited to 'devdocs/elisp/function-debugging.html')
-rw-r--r--devdocs/elisp/function-debugging.html32
1 files changed, 32 insertions, 0 deletions
diff --git a/devdocs/elisp/function-debugging.html b/devdocs/elisp/function-debugging.html
new file mode 100644
index 00000000..822d3b7a
--- /dev/null
+++ b/devdocs/elisp/function-debugging.html
@@ -0,0 +1,32 @@
+ <h4 class="subsection">Entering the Debugger on a Function Call</h4> <p>To investigate a problem that happens in the middle of a program, one useful technique is to enter the debugger whenever a certain function is called. You can do this to the function in which the problem occurs, and then step through the function, or you can do this to a function called shortly before the problem, step quickly over the call to that function, and then step through its caller. </p> <dl> <dt id="debug-on-entry">Command: <strong>debug-on-entry</strong> <em>function-name</em>
+</dt> <dd>
+<p>This function requests <var>function-name</var> to invoke the debugger each time it is called. </p> <p>Any function or macro defined as Lisp code may be set to break on entry, regardless of whether it is interpreted code or compiled code. If the function is a command, it will enter the debugger when called from Lisp and when called interactively (after the reading of the arguments). You can also set debug-on-entry for primitive functions (i.e., those written in C) this way, but it only takes effect when the primitive is called from Lisp code. Debug-on-entry is not allowed for special forms. </p> <p>When <code>debug-on-entry</code> is called interactively, it prompts for <var>function-name</var> in the minibuffer. If the function is already set up to invoke the debugger on entry, <code>debug-on-entry</code> does nothing. <code>debug-on-entry</code> always returns <var>function-name</var>. </p> <p>Here’s an example to illustrate use of this function: </p> <div class="example"> <pre class="example">(defun fact (n)
+ (if (zerop n) 1
+ (* n (fact (1- n)))))
+ ⇒ fact
+</pre>
+<pre class="example">(debug-on-entry 'fact)
+ ⇒ fact
+</pre>
+<pre class="example">(fact 3)
+</pre>
+
+<pre class="example">------ Buffer: *Backtrace* ------
+Debugger entered--entering a function:
+* fact(3)
+ eval((fact 3))
+ eval-last-sexp-1(nil)
+ eval-last-sexp(nil)
+ call-interactively(eval-last-sexp)
+------ Buffer: *Backtrace* ------
+</pre>
+
+</div> </dd>
+</dl> <dl> <dt id="cancel-debug-on-entry">Command: <strong>cancel-debug-on-entry</strong> <em>&amp;optional function-name</em>
+</dt> <dd><p>This function undoes the effect of <code>debug-on-entry</code> on <var>function-name</var>. When called interactively, it prompts for <var>function-name</var> in the minibuffer. If <var>function-name</var> is omitted or <code>nil</code>, it cancels break-on-entry for all functions. Calling <code>cancel-debug-on-entry</code> does nothing to a function which is not currently set up to break on entry. </p></dd>
+</dl><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
+ <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Function-Debugging.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Function-Debugging.html</a>
+ </p>
+</div>