summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/edebug.el
diff options
context:
space:
mode:
authorMichael Heerdegen <michael_heerdegen@web.de>2019-11-14 17:47:51 +0100
committerMichael Heerdegen <michael_heerdegen@web.de>2019-11-23 14:20:50 +0100
commit311ca036f4f6d366747072b518e1026347368f8c (patch)
treed3aa6e8400509f1b334ce3d3f2e00e6bfb5b325b /lisp/emacs-lisp/edebug.el
parentbe779cf7b4e513709cef94d7e04d40887b6bdfb2 (diff)
downloademacs-311ca036f4f6d366747072b518e1026347368f8c.tar.gz
emacs-311ca036f4f6d366747072b518e1026347368f8c.tar.bz2
emacs-311ca036f4f6d366747072b518e1026347368f8c.zip
Fix edebug instrumentation removing from advised functions
* lisp/emacs-lisp/edebug.el (edebug-remove-instrumentation): Handle advised functions correctly.
Diffstat (limited to 'lisp/emacs-lisp/edebug.el')
-rw-r--r--lisp/emacs-lisp/edebug.el28
1 files changed, 22 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index 5d527044108..d68ed966f82 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -4571,6 +4571,21 @@ With prefix argument, make it a temporary breakpoint."
;; Continue standard unloading.
nil)
+(defun edebug--unwrap*-symbol-function (symbol)
+ ;; Try to unwrap SYMBOL's `symbol-function'. The result is suitable
+ ;; to be fbound back to SYMBOL with `defalias'. When no unwrapping
+ ;; could be done return nil.
+ (pcase (symbol-function symbol)
+ ((or (and `(macro . ,f) (let was-macro t))
+ (and f (let was-macro nil)))
+ ;; `defalias' takes care of advises so we must strip them
+ (let* ((orig-f (advice--cd*r f))
+ (unwrapped (edebug-unwrap* orig-f)))
+ (cond
+ ((equal unwrapped orig-f) nil)
+ (was-macro `(macro . ,unwrapped))
+ (t unwrapped))))))
+
(defun edebug-remove-instrumentation (functions)
"Remove Edebug instrumentation from FUNCTIONS.
Interactively, the user is prompted for the function to remove
@@ -4582,10 +4597,10 @@ instrumentation for, defaulting to all functions."
(lambda (symbol)
(when (and (get symbol 'edebug)
(or (functionp symbol)
- (macrop symbol)))
- (let ((unwrapped (edebug-unwrap* (symbol-function symbol))))
- (unless (equal unwrapped (symbol-function symbol))
- (push symbol functions)))))
+ (macrop symbol))
+ (edebug--unwrap*-symbol-function
+ symbol))
+ (push symbol functions)))
obarray)
(unless functions
(error "Found no functions to remove instrumentation from"))
@@ -4599,8 +4614,9 @@ instrumentation for, defaulting to all functions."
functions)))))
;; Remove instrumentation.
(dolist (symbol functions)
- (setf (symbol-function symbol)
- (edebug-unwrap* (symbol-function symbol))))
+ (when-let ((unwrapped
+ (edebug--unwrap*-symbol-function symbol)))
+ (defalias symbol unwrapped)))
(message "Removed edebug instrumentation from %s"
(mapconcat #'symbol-name functions ", ")))