all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Pogonyshev <pogonyshev@gmail.com>
To: emacs-devel@gnu.org
Subject: [PATCH] bug#23469: automatically instrument forms for Edebug when setting breakpoints
Date: Thu, 12 May 2016 22:37:21 +0200	[thread overview]
Message-ID: <CAG7BparueryjGdeBjs08pTYGoG8edks2Kn9fASPWya6ANYRQCA@mail.gmail.com> (raw)

[-- 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))

                 reply	other threads:[~2016-05-12 20:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAG7BparueryjGdeBjs08pTYGoG8edks2Kn9fASPWya6ANYRQCA@mail.gmail.com \
    --to=pogonyshev@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.