Function: dape-disassemble
dape-disassemble is an interactive and natively compiled function
defined in dape.el.
Signature
(dape-disassemble ADDRESS &optional DISPLAY-P)
Documentation
View disassemble of instructions at ADDRESS.
If DISPLAY-P is non-nil, display buffer.
Key Bindings
ctl-x-map C-a M dape-global-map M global-map C-x C-a M help-quick-use-map C-x C-a M
Source Code
;; Defined in /nix/store/1fiaif8pifqj2jh65rbg3fkhg3i56q42-emacs-packages-deps/share/emacs/site-lisp/elpa/dape-0.27.1/dape.el
(defun dape-disassemble (address &optional display-p)
"View disassemble of instructions at ADDRESS.
If DISPLAY-P is non-nil, display buffer."
(interactive
(list
(let ((default
`(,@(when-let* ((number (thing-at-point 'number)))
(list (format "0x%08x" number)))
,@(when-let* ((conn (dape--live-connection 'stopped t))
(address (plist-get (dape--current-stack-frame conn)
:instructionPointerReference)))
(list address)))))
(string-trim
(read-string (format-prompt "Disassemble at address" default) nil nil
default)))
t))
(if-let* ((conn (dape--live-connection 'stopped))
((not (dape--capable-p conn :supportsDisassembleRequest))))
(user-error "Adapter does not support disassemble")
(dape--with-request-bind
((&key ((:instructions instructions)) &allow-other-keys) _)
(dape-request conn :disassemble
`( :memoryReference ,address
:instructionCount 100
:offset 0
:instructionOffset -50
:resolveSymbols t))
(cl-flet ((address-to-int (address)
(string-to-number (substring address 2) 16)))
(with-current-buffer (get-buffer-create "*dape-disassemble*")
(dape-disassemble-mode)
(erase-buffer)
(cl-loop
with last-symbol with last-location
with ps =
(address-to-int (plist-get (dape--current-stack-frame conn)
:instructionPointerReference))
with source = (plist-get (dape--current-stack-frame conn) :source)
with line = (plist-get (dape--current-stack-frame conn) :line)
for instruction across instructions
for address = (address-to-int (plist-get instruction :address))
for current-instruction-p = (equal address ps)
for location =
(setq last-location
;; Forward fill all location if missing as per spec
(or (plist-get instruction :location) last-location))
for current-line-p =
(and (equal location source)
(equal (plist-get instruction :line) line))
do
(when-let* ((symbol (plist-get instruction :symbol))
((not (equal last-symbol symbol))))
(insert
(concat "; " (setq last-symbol symbol) " of "
(thread-first instruction
(plist-get :location)
(plist-get :name)))
":\n"))
(when current-instruction-p
(move-marker dape--disassemble-overlay-arrow (point)))
(insert
(propertize
(format "%s:\t%s\n"
(plist-get instruction :address)
(plist-get instruction :instruction))
'line-prefix
(when current-line-p
(dape--indicator "|" 'vertical-bar nil))
'dape--disassemble-instruction instruction)))
(setq-local revert-buffer-function
(lambda (&rest _) (dape-disassemble address)))
(when (or display-p (marker-position dape--disassemble-overlay-arrow))
(select-window (dape--display-buffer (current-buffer))))
(goto-char (or (marker-position dape--disassemble-overlay-arrow)
(point-min)))
(when (marker-position dape--disassemble-overlay-arrow)
(run-hooks 'dape-display-source-hook)))))))