- (format stream "#X~X[~D]~:[ (#X~X)~;~*~]~@[ in ~S~]"
- addr
- (seg-length seg)
- (= (seg-virtual-location seg) addr)
- (seg-virtual-location seg)
- (seg-code seg)))))
-\f
-;;; All state during disassembly. We store some seemingly redundant
-;;; information so that we can allow garbage collect during disassembly and
-;;; not get tripped up by a code block being moved...
-(defstruct (disassem-state (:conc-name dstate-)
- (:constructor %make-dstate))
- (cur-offs 0 :type offset) ; offset of current pos in segment
- (next-offs 0 :type offset) ; offset of next position
-
- (segment-sap (required-argument) :type sb!sys:system-area-pointer)
- ; a sap pointing to our segment
- (segment nil :type (or null segment)) ; the current segment
-
- (alignment sb!vm:word-bytes :type alignment) ; what to align to in most cases
- (byte-order :little-endian
- :type (member :big-endian :little-endian))
-
- (properties nil :type list) ; for user code to hang stuff off of
- (filtered-values (make-array max-filtered-value-index)
- :type filtered-value-vector)
-
- (addr-print-len nil :type ; used for prettifying printing
- (or null (integer 0 20)))
- (argument-column 0 :type column)
- (output-state :beginning ; to make output look nicer
- :type (member :beginning
- :block-boundary
- nil))
-
- (labels nil :type list) ; alist of (address . label-number)
- (label-hash (make-hash-table) ; same thing in a different form
- :type hash-table)
-
- (fun-hooks nil :type list) ; list of function
-
- ;; these next two are popped as they are used
- (cur-labels nil :type list) ; alist of (address . label-number)
- (cur-offs-hooks nil :type list) ; list of offs-hook
-
- (notes nil :type list) ; for the current location
-
- (current-valid-locations nil ; currently active source variables
- :type (or null (vector bit))))
-(def!method print-object ((dstate disassem-state) stream)
- (print-unreadable-object (dstate stream :type t)
- (format stream
- "+~D~@[ in ~S~]"
- (dstate-cur-offs dstate)
- (dstate-segment dstate))))
-
-(defun dstate-cur-addr (dstate)
- #!+sb-doc
- "Returns the absolute address of the current instruction in DSTATE."
- (the address (+ (seg-virtual-location (dstate-segment dstate))
- (dstate-cur-offs dstate))))
-
-(defun dstate-next-addr (dstate)
- #!+sb-doc
- "Returns the absolute address of the next instruction in DSTATE."
- (the address (+ (seg-virtual-location (dstate-segment dstate))
- (dstate-next-offs dstate))))