Skip to content

Instantly share code, notes, and snippets.

@mvaled
Created February 7, 2014 21:01
Show Gist options
  • Save mvaled/8871765 to your computer and use it in GitHub Desktop.
Save mvaled/8871765 to your computer and use it in GitHub Desktop.
How to attach a command buffer to current source buffer [draft]
(when (and (require 'dash) (require 'realgud) (require 'grizzl))
(defun xars-grizzl-select-cmdbuf()
"Lets the user select a realgud command buffer, unless there's a single
command buffer, in which case returns the buffer directly."
(interactive)
(let ((cmdbuffers (-select #'realgud-cmdbuf? (buffer-list))))
(if (> (length cmdbuffers) 1)
(let* ((cmdbuffers-names (-map #'buffer-name cmdbuffers))
(cmdbuffers-index (grizzl-make-index cmdbuffers-names)))
(let ((selection (grizzl-completing-read
"Debugger Buffer: " cmdbuffers-index)))
(when selection
(message "Selected debugger %s" selection)
(get-buffer selection))))
;; else (no buffer or a single one)
(car cmdbuffers))))
(defun xars-attach-to-cmdbuf ()
"Attaches current buffer to a debugging session."
(interactive)
(-when-let (cmdbuf (xars-grizzl-select-cmdbuf))
(message "Attaching current buffer %s to command buffer %s"
(current-buffer) cmdbuf)
(realgud-srcbuf-init-or-update (current-buffer) cmdbuf)))
@mvaled
Copy link
Author

mvaled commented Feb 14, 2015

Hi @rocky,

It's been a long time... I think what PyDev does is to spawn two communicating processes (or threads):

A middleware and the debugger server.

The debugger runs the programs and has a trace function that can simply check a global state shared by both the middleware and the server.

The client actually communicates to the middleware that maintains the list of break points, state, etc...

When the clients sets a break, the middleware stores this setting. Later on the debugger process' trace function gets to this break and comunicates this to the middleware and the clients gets this.

This is just a guess about how to architecture such client/server debugger that can set breaks while the debugger is running.

I think that in order to accommodate such a debugger major changes are required in the core of realgud.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment