Skip to content

Instantly share code, notes, and snippets.

@pervognsen
Last active August 29, 2015 14:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pervognsen/7846083d697419074bb2 to your computer and use it in GitHub Desktop.
Save pervognsen/7846083d697419074bb2 to your computer and use it in GitHub Desktop.
watch expressions with dbg.el
(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