all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] bug#23469: automatically instrument forms for Edebug when setting breakpoints
@ 2016-05-12 20:37 Paul Pogonyshev
  0 siblings, 0 replies; only message in thread
From: Paul Pogonyshev @ 2016-05-12 20:37 UTC (permalink / raw
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 337 bytes --]

Automatically instrument forms for Edebug when setting
breakpoints inside not-yet-instrumented forms.

* lisp/emacs-lisp/edebug.el (edebug-form-data-symbol): Add
optional `instrument-if-needed' argument.
(edebug-find-stop-point): Likewise.
(edebug-modify-breakpoint, edebug-set-conditional-breakpoint):
Pass t as `instrument-if-needed'.

[-- Attachment #2: autoinstrument.diff --]
[-- Type: text/plain, Size: 2917 bytes --]

diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index 07a846f..caea2d9 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -627,10 +627,15 @@ list of a symbol.")
 ;; Also need to find all contained entries,
 ;; and find an entry given a symbol, which should be just assq.
 
-(defun edebug-form-data-symbol ()
+(defun edebug-form-data-symbol (&optional instrument-if-needed)
   "Return the edebug data symbol of the form where point is in.
-If point is not inside a edebuggable form, cause error."
+If point is inside a non-edebuggable form and optional argument
+INSTRUMENT-IF-NEEDED is non-nil, instrument the form first,
+otherwise cause error."
   (or (edebug--form-data-name (edebug-get-form-data-entry (point)))
+      (when instrument-if-needed
+        (edebug-eval-defun t)
+        (edebug--form-data-name (edebug-get-form-data-entry (point))))
       (error "Not inside instrumented form")))
 
 (defun edebug-make-top-form-data-entry (new-entry)
@@ -2871,13 +2876,17 @@ before returning.  The default is one second."
 
 ;;; Breakpoint related functions
 
-(defun edebug-find-stop-point ()
+(defun edebug-find-stop-point (&optional instrument-if-needed)
   ;; Return (function . index) of the nearest edebug stop point.
-  (let* ((edebug-def-name (edebug-form-data-symbol))
+  (let* ((edebug-def-name (edebug-form-data-symbol instrument-if-needed))
 	 (edebug-data
 	   (let ((data (get edebug-def-name 'edebug)))
-	     (if (or (null data) (markerp data))
-		 (error "%s is not instrumented for Edebug" edebug-def-name))
+	     (when (or (null data) (markerp data))
+               (when instrument-if-needed
+                 (edebug-eval-defun t)
+                 (setq data (get edebug-def-name 'edebug)))
+               (when (or (null data) (markerp data))
+                 (error "%s is not instrumented for Edebug" edebug-def-name)))
 	     data))  ; we could do it automatically, if data is a marker.
 	 ;; pull out parts of edebug-data.
 	 (edebug-def-mark (car edebug-data))
@@ -2949,7 +2958,7 @@ before returning.  The default is one second."
 Set it if FLAG is non-nil, clear it otherwise.  Then move to that point.
 If CONDITION or TEMPORARY are non-nil, add those attributes to
 the breakpoint."
-  (let ((edebug-stop-point (edebug-find-stop-point)))
+  (let ((edebug-stop-point (edebug-find-stop-point t)))
     (if edebug-stop-point
 	(let* ((edebug-def-name (car edebug-stop-point))
 	       (index (cdr edebug-stop-point))
@@ -4018,7 +4027,7 @@ With prefix argument, make it a temporary breakpoint."
    (list
     current-prefix-arg
     ;; Read condition as follows; getting previous condition is cumbersome:
-    (let ((edebug-stop-point (edebug-find-stop-point)))
+    (let ((edebug-stop-point (edebug-find-stop-point t)))
       (if edebug-stop-point
 	  (let* ((edebug-def-name (car edebug-stop-point))
 		 (index (cdr edebug-stop-point))

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-05-12 20:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-12 20:37 [PATCH] bug#23469: automatically instrument forms for Edebug when setting breakpoints Paul Pogonyshev

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.