Demystifying Edebug
Charles Y. Choi
Created: 2024-06-13 Thu 18:07
Disclaimer
- My knowledge of Elisp (or any other Lisp) is not deep.
- Objective is to share knowledge and gain understanding.
Edebug
- Source-level debugger for Elisp
- On paper can do all the things you expect a debugger to do
Edebug though is a mess…
- Terrible ergonomics
- More a kit of parts than an actual tool
- Mismatches with contemporary naming
Edebug Fundamentals
- Edebug operates modally
- To debug, a function must be instrumented
(C-u C-M-x
)
- Any call to an instrumented function activates Edebug
(Typically started by
C-M-x
)
Edebug Fundamentals (cont.)
- When Edebug is activated:
- Different execution (run) modes available, among them:
Stepping (Jumping)
- Edebug stepping works with sexps
- Forward one expression (
f
)
- Step in to next expression after point (
i
)
- Step out of containing expression (
o
)
- ❗️Different from debugging other languages
Watching (Evaluation List)
- Sets up a separate buffer of expressions to watch (E)
- ❗️Manual setup only, compared to IDEs - more bindings
- Persisted for Emacs session
Breakpoints
- Must instrument function before setting a breakpoint
- ❗️Breakpoints are only visible when Edebug is activated
- ❗️Re-evaluating a function removes all previous breakpoints
Misc Commands
- Show stack trace (backtrace) (
d
)
- Repeat last result (
r
)
- Prompt for expression (
e
)
Edebug User Experience
- Steep learning curve
- Many keybindings and commands to know ahead of time
- Difficult to discover and recall
It’s 2024, we can do better
- Add Transient menus for Edebug
- Prototype