17.5 Debugging Exercises
- Install the
count-words-example
function and then cause it to
enter the built-in debugger when you call it. Run the command on a
region containing two words. You will need to press d a
remarkable number of times. On your system, is a hook called after
the command finishes? (For information on hooks, see Command Loop Overview in The GNU Emacs Lisp Reference
Manual.)
- Copy
count-words-example
into the *scratch* buffer,
instrument the function for Edebug, and walk through its execution.
The function does not need to have a bug, although you can introduce
one if you wish. If the function lacks a bug, the walk-through
completes without problems.
- While running Edebug, type ? to see a list of all the Edebug commands.
(The
global-edebug-prefix
is usually C-x X, i.e.,
CTRL-x followed by an upper case X; use this prefix
for commands made outside of the Edebug debugging buffer.)
- In the Edebug debugging buffer, use the p
(
edebug-bounce-point
) command to see where in the region the
count-words-example
is working.
- Move point to some spot further down the function and then type the
h (
edebug-goto-here
) command to jump to that location.
- Use the t (
edebug-trace-mode
) command to cause Edebug to
walk through the function on its own; use an upper case T for
edebug-Trace-fast-mode
.
- Set a breakpoint, then run Edebug in Trace mode until it reaches the
stopping point.