Skip to main content

18.2.14 The Outside Context

Edebug tries to be transparent to the program you are debugging, but it does not succeed completely. Edebug also tries to be transparent when you evaluate expressions with e or with the evaluation list buffer, by temporarily restoring the outside context. This section explains precisely what context Edebug restores, and how Edebug fails to be completely transparent.

• Checking Whether to Stop  When Edebug decides what to do.
• Edebug Display Update  When Edebug updates the display.
• Edebug Recursive Edit  When Edebug stops execution.

18.2.14.1 Checking Whether to Stop​

Whenever Edebug is entered, it needs to save and restore certain data before even deciding whether to make trace information or stop the program.

  • max-lisp-eval-depth (see Eval) and max-specpdl-size (see Local Variables) are both increased to reduce Edebug’s impact on the stack. You could, however, still run out of stack space when using Edebug. You can also enlarge the value of edebug-max-depth if Edebug reaches the limit of recursion depth instrumenting code that contains very large quoted lists.
  • The state of keyboard macro execution is saved and restored. While Edebug is active, executing-kbd-macro is bound to nil unless edebug-continue-kbd-macro is non-nil.

18.2.14.2 Edebug Display Update​

When Edebug needs to display something (e.g., in trace mode), it saves the current window configuration from outside Edebug (see Window Configurations). When you exit Edebug, it restores the previous window configuration.

Emacs redisplays only when it pauses. Usually, when you continue execution, the program re-enters Edebug at a breakpoint or after stepping, without pausing or reading input in between. In such cases, Emacs never gets a chance to redisplay the outside configuration. Consequently, what you see is the same window configuration as the last time Edebug was active, with no interruption.

Entry to Edebug for displaying something also saves and restores the following data (though some of them are deliberately not restored if an error or quit signal occurs).

  • Which buffer is current, and the positions of point and the mark in the current buffer, are saved and restored.

  • The outside window configuration is saved and restored if edebug-save-windows is non-nil (see Edebug Options).

    The window configuration is not restored on error or quit, but the outside selected window is reselected even on error or quit in case a save-excursion is active. If the value of edebug-save-windows is a list, only the listed windows are saved and restored.

    The window start and horizontal scrolling of the source code buffer are not restored, however, so that the display remains coherent within Edebug.

  • The value of point in each displayed buffer is saved and restored if edebug-save-displayed-buffer-points is non-nil.

  • The variables overlay-arrow-position and overlay-arrow-string are saved and restored, so you can safely invoke Edebug from the recursive edit elsewhere in the same buffer.

  • cursor-in-echo-area is locally bound to nil so that the cursor shows up in the window.

18.2.14.3 Edebug Recursive Edit​

When Edebug is entered and actually reads commands from the user, it saves (and later restores) these additional data:

  • The current match data. See Match Data.

  • The variables last-command, this-command, last-command-event, last-input-event, last-event-frame, last-nonmenu-event, and track-mouse. Commands in Edebug do not affect these variables outside of Edebug.

    Executing commands within Edebug can change the key sequence that would be returned by this-command-keys, and there is no way to reset the key sequence from Lisp.

    Edebug cannot save and restore the value of unread-command-events. Entering Edebug while this variable has a nontrivial value can interfere with execution of the program you are debugging.

  • Complex commands executed while in Edebug are added to the variable command-history. In rare cases this can alter execution.

  • Within Edebug, the recursion depth appears one deeper than the recursion depth outside Edebug. This is not true of the automatically updated evaluation list window.

  • standard-output and standard-input are bound to nil by the recursive-edit, but Edebug temporarily restores them during evaluations.

  • The state of keyboard macro definition is saved and restored. While Edebug is active, defining-kbd-macro is bound to edebug-continue-kbd-macro.