Last active
August 29, 2015 14:10
-
-
Save pervognsen/7846083d697419074bb2 to your computer and use it in GitHub Desktop.
watch expressions with dbg.el
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun dbg-watch (expression) | |
(interactive "sExpression: ") | |
(dbg-mi-command (list 'dbg-watch-handler expression) "-var-create - @ %s" (prin1-to-string expression))) | |
(defun dbg-watch-handler (status result expression) | |
(case status | |
((done) | |
(push (cons (cons 'expression expression) result) dbg-watches))) | |
(dbg-render-watches)) | |
(defun dbg-update-watches () | |
(dbg-mi-command 'dbg-update-watches-handler "-var-update --all-values *")) | |
(defun dbg-update-watches-handler (status result) | |
(case status | |
((done) | |
(dolist (change (dbg-item result 'changelist)) | |
(dolist (watch dbg-watches) | |
(when (equal (dbg-item watch 'name) (dbg-item change 'name)) | |
(setf (dbg-item watch 'value) (dbg-item change 'value)) | |
(let ((type (dbg-item change 'type))) | |
(when type | |
(setf (dbg-item watch 'type) type)))))))) | |
(dbg-render-watches)) | |
(defun dbg-render-watches () | |
(with-read-only-buffer dbg-watches-buffer | |
(erase-buffer) | |
(dolist (watch dbg-watches) | |
(insert (format "%s\n" (dbg-expression-string watch)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment