Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger or instrument with edebug programmatically?

C-u C-M-x evaluates a defun form with edebug instrumented. Can I do that programmatically? I want to do that because I want to write an elisp file of the following form:

;;; define a function with edebug instrumented.
...


;;; do something that invokes the function with particular arguments.
...

then I can run emacs -q --load on that elisp file, step through code, get an idea on further investigation on the bug, edit the elisp file in my original emacs session, run emacs -q --load on it again, and repeat.

like image 988
Jisang Yoo Avatar asked Oct 21 '22 02:10

Jisang Yoo


1 Answers

In ~/test.el:

(defun square (x)
  (* x x))

In ~/testtest.el:

(with-current-buffer (find-file-noselect "~/test.el")
  (re-search-forward "square")  
  (edebug-defun))
(square 5)

In bash:

emacs -q -l ~/testtest.el
like image 116
abo-abo Avatar answered Nov 01 '22 14:11

abo-abo