If some emacs-lisp function, such as a major mode hook, is taking longer than expected to execute, I would sometimes like to interrupt it and look at the current stack. Ideally, I'd also like to be able to look at variable values, and so on, in the debugger. I'm not talking about code that I am deliberately executing in emacs-lisp mode, but rather code that gets executed in the normal operation of emacs.
How can I interrupt execution of emacs-lisp code directly in emacs? I do not know up front which function I need to debug.
For example, typing C-g
, while it interrupts execution, also tells me nothing about which function was interrupted.