### 8.19 SLIME Trace Dialog ¶

The SLIME Trace Dialog, in package `slime-trace-dialog`, is a tracing facility, similar to Common Lisp’s `trace`, but interactive rather than purely textual. It is an Emacs 24-only contrib.

You use it just like you would regular `trace`: after tracing a function, calling it causes interesting information about that particular call to be reported.

However, instead of printing the trace results to the the `*trace-output*` stream (usually the REPL), the SLIME Trace Dialog collects and stores them in your lisp environment until, on user’s request, they are fetched into Emacs and displayed in a dialog-like interactive view.

After starting up SLIME, SLIME’s Trace Dialog installs a Trace menu in the menu-bar of any `slime-mode` buffer and adds two new commands, with respective key-bindings:

`C-c M-t` ¶
`M-x slime-trace-dialog-toggle-trace`

  If point is on a symbol name, toggle tracing of its function definition. If point is not on a symbol, prompt user for a function.

  With a `C-u` prefix argument, and if your lisp implementation allows it, attempt to decipher lambdas, methods and other complicated function signatures.

  The function is traced for the SLIME Trace Dialog only, i.e. it is not found in the list returned by Common Lisp’s `trace`.

`C-c T` ¶
`M-x slime-trace-dialog`

  Pop to the interactive SLIME Trace Dialog buffer associated with the current connection (see Multiple connections).

Consider the (useless) program:

    (defun foo (n) (if (plusp n) (* n (bar (1- n))) 1))
    (defun bar (n) (if (plusp n) (* n (foo (1- n))) 1))

After tracing both `foo` and `bar` with `C-c M-t`, calling call `(foo 2)` and moving to the trace dialog with `C-c T`, we are presented with this buffer.

    Traced specs (2)                                  [refresh]
                                                      [untrace all]
      [untrace] common-lisp-user::bar
      [untrace] common-lisp-user::foo

    Trace collection status (3/3)                     [refresh]
                                                      [clear]

       0 - common-lisp-user::foo
         | > 2
         | < 2
       1 `--- common-lisp-user::bar
            | > 1
            | < 1
       2    `-- common-lisp-user::foo
                 > 0
                 < 1

The dialog is divided into sections displaying the functions already traced, the trace collection progress and the actual trace tree that follow your program’s logic. The most important key-bindings in this buffer are:

`g` ¶
`M-x slime-trace-dialog-fetch-status`

  Update information on the trace collection and traced specs.

`G` ¶
`M-x slime-trace-dialog-fetch-traces`

  Fetch the next batch of outstanding (not fetched yet) traces. With a `C-u` prefix argument, repeat until no more outstanding traces.

`C-k` ¶
`M-x slime-trace-dialog-clear-fetched-traces`

  Prompt for confirmation, then clear all traces, both fetched and outstanding.

The arguments and return values below each entry are interactive buttons. Clicking them opens the inspector (see Inspector commands). Invoking `M-RET` (`slime-trace-dialog-copy-down-to-repl`) returns them to the REPL for manipulation (see REPL: the “top level”). The number left of each entry indicates its absolute position in the calling order, which might differ from display order in case multiple threads call the same traced function.

`slime-trace-dialog-hide-details-mode` hides arguments and return values so you can concentrate on the calling logic. Additionally, `slime-trace-dialog-autofollow-mode` will automatically display additional detail about an entry when the cursor moves over it.