aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/emacs-lisp/edebug.el53
1 files changed, 38 insertions, 15 deletions
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index a376067443a..78461185d3a 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -741,6 +741,21 @@ Maybe clear the markers and delete the symbol's edebug property?"
741 741
742;;; Offsets for reader 742;;; Offsets for reader
743 743
744(defun edebug-get-edebug-or-ghost (name)
745 "Get NAME's value of property `edebug' or property `ghost-edebug'.
746
747The idea is that should function NAME be recompiled whilst
748debugging is in progress, property `edebug' will get set to a
749marker. The needed data will then come from property
750`ghost-edebug'."
751 (let ((e (get name 'edebug)))
752 (if (consp e)
753 e
754 (let ((g (get name 'ghost-edebug)))
755 (if (consp g)
756 g
757 e)))))
758
744;; Define a structure to represent offset positions of expressions. 759;; Define a structure to represent offset positions of expressions.
745;; Each offset structure looks like: (before . after) for constituents, 760;; Each offset structure looks like: (before . after) for constituents,
746;; or for structures that have elements: (before <subexpressions> . after) 761;; or for structures that have elements: (before <subexpressions> . after)
@@ -1168,6 +1183,12 @@ purpose by adding an entry to this alist, and setting
1168 ;; Not edebugging this form, so reset the symbol's edebug 1183 ;; Not edebugging this form, so reset the symbol's edebug
1169 ;; property to be just a marker at the definition's source code. 1184 ;; property to be just a marker at the definition's source code.
1170 ;; This only works for defs with simple names. 1185 ;; This only works for defs with simple names.
1186
1187 ;; Preserve the `edebug' property in case there's
1188 ;; debugging still under way.
1189 (let ((ghost (get def-name 'edebug)))
1190 (if (consp ghost)
1191 (put def-name 'ghost-edebug ghost)))
1171 (put def-name 'edebug (point-marker)) 1192 (put def-name 'edebug (point-marker))
1172 ;; Also nil out dependent defs. 1193 ;; Also nil out dependent defs.
1173 '(mapcar (function 1194 '(mapcar (function
@@ -1411,6 +1432,8 @@ contains a circular object."
1411 (cons window (window-start window))))) 1432 (cons window (window-start window)))))
1412 1433
1413 ;; Store the edebug data in symbol's property list. 1434 ;; Store the edebug data in symbol's property list.
1435 ;; We actually want to remove this property entirely, but can't.
1436 (put edebug-def-name 'ghost-edebug nil)
1414 (put edebug-def-name 'edebug 1437 (put edebug-def-name 'edebug
1415 ;; A struct or vector would be better here!! 1438 ;; A struct or vector would be better here!!
1416 (list edebug-form-begin-marker 1439 (list edebug-form-begin-marker
@@ -1423,8 +1446,8 @@ contains a circular object."
1423 ))) 1446 )))
1424 1447
1425(defun edebug--restore-breakpoints (name) 1448(defun edebug--restore-breakpoints (name)
1426 (let ((data (get name 'edebug))) 1449 (let ((data (edebug-get-edebug-or-ghost name)))
1427 (when (listp data) 1450 (when (consp data)
1428 (let ((offsets (nth 2 data)) 1451 (let ((offsets (nth 2 data))
1429 (breakpoints (nth 1 data)) 1452 (breakpoints (nth 1 data))
1430 (start (nth 0 data)) 1453 (start (nth 0 data))
@@ -3128,7 +3151,7 @@ before returning. The default is one second."
3128 ;; Return (function . index) of the nearest edebug stop point. 3151 ;; Return (function . index) of the nearest edebug stop point.
3129 (let* ((edebug-def-name (edebug-form-data-symbol)) 3152 (let* ((edebug-def-name (edebug-form-data-symbol))
3130 (edebug-data 3153 (edebug-data
3131 (let ((data (get edebug-def-name 'edebug))) 3154 (let ((data (edebug-get-edebug-or-ghost edebug-def-name)))
3132 (if (or (null data) (markerp data)) 3155 (if (or (null data) (markerp data))
3133 (error "%s is not instrumented for Edebug" edebug-def-name)) 3156 (error "%s is not instrumented for Edebug" edebug-def-name))
3134 data)) ; we could do it automatically, if data is a marker. 3157 data)) ; we could do it automatically, if data is a marker.
@@ -3165,7 +3188,7 @@ before returning. The default is one second."
3165 (if edebug-stop-point 3188 (if edebug-stop-point
3166 (let* ((edebug-def-name (car edebug-stop-point)) 3189 (let* ((edebug-def-name (car edebug-stop-point))
3167 (index (cdr edebug-stop-point)) 3190 (index (cdr edebug-stop-point))
3168 (edebug-data (get edebug-def-name 'edebug)) 3191 (edebug-data (edebug-get-edebug-or-ghost edebug-def-name))
3169 3192
3170 ;; pull out parts of edebug-data 3193 ;; pull out parts of edebug-data
3171 (edebug-def-mark (car edebug-data)) 3194 (edebug-def-mark (car edebug-data))
@@ -3206,7 +3229,7 @@ the breakpoint."
3206 (if edebug-stop-point 3229 (if edebug-stop-point
3207 (let* ((edebug-def-name (car edebug-stop-point)) 3230 (let* ((edebug-def-name (car edebug-stop-point))
3208 (index (cdr edebug-stop-point)) 3231 (index (cdr edebug-stop-point))
3209 (edebug-data (get edebug-def-name 'edebug)) 3232 (edebug-data (edebug-get-edebug-or-ghost edebug-def-name))
3210 3233
3211 ;; pull out parts of edebug-data 3234 ;; pull out parts of edebug-data
3212 (edebug-def-mark (car edebug-data)) 3235 (edebug-def-mark (car edebug-data))
@@ -3244,7 +3267,7 @@ the breakpoint."
3244 "\x3c\x7e\xff\xff\xff\xff\x7e\x3c") 3267 "\x3c\x7e\xff\xff\xff\xff\x7e\x3c")
3245 3268
3246(defun edebug--overlay-breakpoints (function) 3269(defun edebug--overlay-breakpoints (function)
3247 (let* ((data (get function 'edebug)) 3270 (let* ((data (edebug-get-edebug-or-ghost function))
3248 (start (nth 0 data)) 3271 (start (nth 0 data))
3249 (breakpoints (nth 1 data)) 3272 (breakpoints (nth 1 data))
3250 (offsets (nth 2 data))) 3273 (offsets (nth 2 data)))
@@ -3284,9 +3307,9 @@ With prefix argument, make it a temporary breakpoint."
3284 (interactive "P") 3307 (interactive "P")
3285 ;; If the form hasn't been instrumented yet, do it now. 3308 ;; If the form hasn't been instrumented yet, do it now.
3286 (when (and (not edebug-active) 3309 (when (and (not edebug-active)
3287 (let ((data (get (edebug--form-data-name 3310 (let ((data (edebug-get-edebug-or-ghost
3288 (edebug-get-form-data-entry (point))) 3311 (edebug--form-data-name
3289 'edebug))) 3312 (edebug-get-form-data-entry (point))))))
3290 (or (null data) (markerp data)))) 3313 (or (null data) (markerp data))))
3291 (edebug-defun)) 3314 (edebug-defun))
3292 (edebug-modify-breakpoint t nil arg)) 3315 (edebug-modify-breakpoint t nil arg))
@@ -3300,7 +3323,7 @@ With prefix argument, make it a temporary breakpoint."
3300 "Unset all the breakpoints in the current form." 3323 "Unset all the breakpoints in the current form."
3301 (interactive) 3324 (interactive)
3302 (let* ((name (edebug-form-data-symbol)) 3325 (let* ((name (edebug-form-data-symbol))
3303 (breakpoints (nth 1 (get name 'edebug)))) 3326 (breakpoints (nth 1 (edebug-get-edebug-or-ghost name))))
3304 (unless breakpoints 3327 (unless breakpoints
3305 (user-error "There are no breakpoints in %s" name)) 3328 (user-error "There are no breakpoints in %s" name))
3306 (save-excursion 3329 (save-excursion
@@ -3316,7 +3339,7 @@ With prefix argument, make it a temporary breakpoint."
3316 (user-error "No stop point near point")) 3339 (user-error "No stop point near point"))
3317 (let* ((name (car stop-point)) 3340 (let* ((name (car stop-point))
3318 (index (cdr stop-point)) 3341 (index (cdr stop-point))
3319 (data (get name 'edebug)) 3342 (data (edebug-get-edebug-or-ghost name))
3320 (breakpoint (assq index (nth 1 data)))) 3343 (breakpoint (assq index (nth 1 data))))
3321 (unless breakpoint 3344 (unless breakpoint
3322 (user-error "No breakpoint near point")) 3345 (user-error "No breakpoint near point"))
@@ -3497,7 +3520,7 @@ instrument cannot be found, signal an error."
3497 (goto-char func-marker) 3520 (goto-char func-marker)
3498 (edebug-eval-top-level-form) 3521 (edebug-eval-top-level-form)
3499 (list func))) 3522 (list func)))
3500 ((consp func-marker) 3523 ((and (consp func-marker) (consp (symbol-function func)))
3501 (message "%s is already instrumented." func) 3524 (message "%s is already instrumented." func)
3502 (list func)) 3525 (list func))
3503 (t 3526 (t
@@ -4270,7 +4293,7 @@ Save DEF-NAME, BEFORE-INDEX and AFTER-INDEX in FRAME."
4270 (let* ((index (backtrace-get-index)) 4293 (let* ((index (backtrace-get-index))
4271 (frame (nth index backtrace-frames))) 4294 (frame (nth index backtrace-frames)))
4272 (when (edebug--frame-def-name frame) 4295 (when (edebug--frame-def-name frame)
4273 (let* ((data (get (edebug--frame-def-name frame) 'edebug)) 4296 (let* ((data (edebug-get-edebug-or-ghost (edebug--frame-def-name frame)))
4274 (marker (nth 0 data)) 4297 (marker (nth 0 data))
4275 (offsets (nth 2 data))) 4298 (offsets (nth 2 data)))
4276 (pop-to-buffer (marker-buffer marker)) 4299 (pop-to-buffer (marker-buffer marker))
@@ -4354,7 +4377,7 @@ reinstrument it."
4354 (let* ((function (edebug-form-data-symbol)) 4377 (let* ((function (edebug-form-data-symbol))
4355 (counts (get function 'edebug-freq-count)) 4378 (counts (get function 'edebug-freq-count))
4356 (coverages (get function 'edebug-coverage)) 4379 (coverages (get function 'edebug-coverage))
4357 (data (get function 'edebug)) 4380 (data (edebug-get-edebug-or-ghost function))
4358 (def-mark (car data)) ; mark at def start 4381 (def-mark (car data)) ; mark at def start
4359 (edebug-points (nth 2 data)) 4382 (edebug-points (nth 2 data))
4360 (i (1- (length edebug-points))) 4383 (i (1- (length edebug-points)))
@@ -4512,7 +4535,7 @@ With prefix argument, make it a temporary breakpoint."
4512 (if edebug-stop-point 4535 (if edebug-stop-point
4513 (let* ((edebug-def-name (car edebug-stop-point)) 4536 (let* ((edebug-def-name (car edebug-stop-point))
4514 (index (cdr edebug-stop-point)) 4537 (index (cdr edebug-stop-point))
4515 (edebug-data (get edebug-def-name 'edebug)) 4538 (edebug-data (edebug-get-edebug-or-ghost edebug-def-name))
4516 (edebug-breakpoints (car (cdr edebug-data))) 4539 (edebug-breakpoints (car (cdr edebug-data)))
4517 (edebug-break-data (assq index edebug-breakpoints)) 4540 (edebug-break-data (assq index edebug-breakpoints))
4518 (edebug-break-condition (car (cdr edebug-break-data))) 4541 (edebug-break-condition (car (cdr edebug-break-data)))