1.0.8.7: printer-control variables affecting MEMBER & ASSOC transforms
[sbcl.git] / src / compiler / target-disassem.lisp
index 3339a73..ae62e1a 100644 (file)
            (type (or null stream) stream))
 
   (let ((ispace (get-inst-space))
-        (prefix-p nil)) ; just processed a prefix inst
+        (prefix-p nil) ; just processed a prefix inst
+        (prefix-len 0)) ; length of any prefix instruction(s)
 
     (rewind-current-segment dstate segment)
 
                             (when prefilter
                               (funcall prefilter chunk dstate))
 
+                            (setf prefix-p (null (inst-printer inst)))
+
                             ;; print any instruction bytes recognized by the prefilter which calls read-suffix
                             ;; and updates next-offs
                             (when stream
                               (let ((suffix-len (- (dstate-next-offs dstate) orig-next)))
                                 (when (plusp suffix-len)
                                   (print-inst suffix-len stream dstate :offset (inst-length inst) :trailing-space nil))
-                              (dotimes (i (- *disassem-inst-column-width* (* 2 (+ (inst-length inst) suffix-len))))
-                                (write-char #\space stream)))
-                              (write-char #\space stream))
+                                (unless prefix-p
+                                  (dotimes (i (- *disassem-inst-column-width* (* 2 (+ (inst-length inst) suffix-len prefix-len))))
+                                    (write-char #\space stream))
+                                  (write-char #\space stream))
 
-                            (funcall function chunk inst)
+                                (setf prefix-len (+ (inst-length inst) suffix-len))))
 
-                            (setf prefix-p (null (inst-printer inst)))
+                            (funcall function chunk inst)
 
                             (when control
                               (funcall control chunk inst stream dstate))
 
       (unless (null stream)
         (unless prefix-p
+          (setf prefix-len 0)
           (print-notes-and-newline stream dstate))
         (setf (dstate-output-state dstate) nil)))))
 \f
 ;;; Make a disassembler-state object.
 (defun make-dstate (&optional (fun-hooks *default-dstate-hooks*))
   (let ((sap
+         ;; FIXME: What is this for? This cannot be safe!
          (sb!sys:vector-sap (coerce #() '(vector (unsigned-byte 8)))))
         (alignment *disassem-inst-alignment-bytes*)
         (arg-column
 \f
 ;;; A SAP-MAKER is a no-argument function that returns a SAP.
 
+;; FIXME: Are the objects we are taking saps for always pinned?
 #!-sb-fluid (declaim (inline sap-maker))
-
 (defun sap-maker (function input offset)
   (declare (optimize (speed 3))
            (type (function (t) sb!sys:system-area-pointer) function)
             (sfcache-form-number-mapping-table cache) mapping-table))
     (cond ((null toplevel-form)
            nil)
-          ((> form-number (length mapping-table))
+          ((>= form-number (length mapping-table))
            (warn "bogus form-number in form!  The source file has probably ~@
                   been changed too much to cope with.")
            (when cache