summaryrefslogtreecommitdiff
path: root/devdocs/elisp/debugging.html
blob: 3e7f28872e3ccc892e5362505578d9be36ef3aa2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 <h2 class="chapter">Debugging Lisp Programs</h2>  <p>There are several ways to find and investigate problems in an Emacs Lisp program. </p> <ul> <li> If a problem occurs when you run the program, you can use the built-in Emacs Lisp debugger to suspend the Lisp evaluator, and examine and/or alter its internal state. </li>
<li> You can use Edebug, a source-level debugger for Emacs Lisp. </li>
<li>  You can trace the execution of functions involved in the problem using the tracing facilities provided by the <samp>trace.el</samp> package. This package provides the functions <code>trace-function-foreground</code> and <code>trace-function-background</code> for tracing function calls, and <code>trace-values</code> for adding values of select variables to the trace. For the details, see the documentation of these facilities in <samp>trace.el</samp>. </li>
<li> If a syntactic problem is preventing Lisp from even reading the program, you can locate it using Lisp editing commands. </li>
<li> You can look at the error and warning messages produced by the byte compiler when it compiles the program. See <a href="compiler-errors">Compiler Errors</a>. </li>
<li> You can use the Testcover package to perform coverage testing on the program. </li>
<li> You can use the ERT package to write regression tests for the program. See <a href="https://www.gnu.org/software/emacs/manual/html_node/ert/index.html#Top">the ERT manual</a> in <cite>ERT: Emacs Lisp Regression Testing</cite>. </li>
<li> You can profile the program to get hints about how to make it more efficient. </li>
</ul> <p>Other useful tools for debugging input and output problems are the dribble file (see <a href="terminal-input">Terminal Input</a>) and the <code>open-termscript</code> function (see <a href="terminal-output">Terminal Output</a>). </p> <table class="menu" border="0" cellspacing="0"> <tr>
<td align="left" valign="top">• <a href="debugger" accesskey="1">Debugger</a>
</td>
<td> </td>
<td align="left" valign="top">A debugger for the Emacs Lisp evaluator. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="edebug" accesskey="2">Edebug</a>
</td>
<td> </td>
<td align="left" valign="top">A source-level Emacs Lisp debugger. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="syntax-errors" accesskey="3">Syntax Errors</a>
</td>
<td> </td>
<td align="left" valign="top">How to find syntax errors. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="test-coverage" accesskey="4">Test Coverage</a>
</td>
<td> </td>
<td align="left" valign="top">Ensuring you have tested all branches in your code. </td>
</tr> <tr>
<td align="left" valign="top">• <a href="profiling" accesskey="5">Profiling</a>
</td>
<td> </td>
<td align="left" valign="top">Measuring the resources that your code uses. </td>
</tr> </table><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/Debugging.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Debugging.html</a>
  </p>
</div>