Search code examples
debuggingemacselisptrace

elisp `trace-function` not producing trace


I am trying to trace a function in emacs lisp. I am trying to use trace-function and friends, but no trace is produced. The *trace-output* buffer gets created, but nothing is written in it.

Here is a minimal example of the problem:

(progn
  (require 'trace)
  (untrace-all)
  (defun f () 'hello)
  ;(trace-function 'f)
  ;(trace-function-background 'f)
  (trace-function-foreground 'f)
  (f))

Executing this from within *scratch* returns 'hello, but not trace information is written to either *trace-output* or *scratch*. I have tried it with each of the three trace functions above without success.

Am I doing something wrong? How can I get trace information to be produced?


Solution

  • Package trace.el defines the global variable inhibit-trace, which is initially nil. However, entering the debugger set inhibit-trace to 't, which remains in effect until the debugger is explicitly quit. Simply closing the *Backtrace* buffer does not exit the debugger.

    My problem was that I had entered the debugger earlier in my sesion and not quit it explicitly.

    This behaviour deserves to be better known :)