Changeset 16633


Ignore:
Timestamp:
Nov 2, 2015, 11:28:06 PM (6 years ago)
Author:
rme
Message:

New function x86-print-di-raw (not the greatest name). Use it in
x86-print-dissassembled-instruction when *disassemble-verbose*
is true.

It prints instructions like this:

+1973: 4c 8d 2d 44 (recover-fn-from-rip)

f8 ff ff

(This lets me avoid using gdb/lldb to see x86 instruction bytes.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/compiler/X86/x86-disassemble.lisp

    r16631 r16633  
    28992899              (write-x86-lap-operand t op2 ds)))))
    29002900      (format t ")~vt;~8<[~D]~>" (+ comment-start-offset tab-stop) pc))
    2901     (when *disassemble-verbose*
    2902       (let* ((istart (x86-di-start instruction))
    2903              (iend (x86-di-end instruction))
    2904              (nbytes (- iend istart))
    2905              (code-vector (x86-ds-code-vector ds))
    2906              (byteidx istart))
    2907         (dotimes (i (min nbytes 4))
    2908           (format t ";")
    2909           (format t " ~(~2,'0x~)" (aref code-vector byteidx))
    2910           (incf byteidx))
    2911         (format t "~%")
    2912         (decf nbytes 4)
    2913         (while (plusp nbytes)
    2914           (format t "~vt;~8<~>" (+ comment-start-offset tab-stop))
    2915           (dotimes (i (min nbytes 4))
    2916             (format t " ~(~2,'0x~)" (aref code-vector byteidx))
    2917             (incf byteidx))
    2918           (format t "~%")
    2919           (decf nbytes 4))))
    29202901    (format t "~&")))
     2902
     2903(defun x86-print-di-raw (ds instruction tab-stop pc)
     2904  (declare (ignore tab-stop))
     2905  (let* ((op0 (x86-di-op0 instruction))
     2906         (op1 (x86-di-op1 instruction))
     2907         (op2 (x86-di-op2 instruction))
     2908         (istart (x86-di-start instruction))
     2909         (iend (x86-di-end instruction))
     2910         (nbytes (- iend istart))
     2911         (code-vector (x86-ds-code-vector ds))
     2912         (byteidx istart))
     2913    (format t "~5@d: " pc)
     2914    (dotimes (i (min nbytes 4))
     2915      (format t "~(~2,'0x~) " (aref code-vector byteidx))
     2916      (incf byteidx))
     2917    (format t "~20t(~a" (x86-di-mnemonic instruction))
     2918    (when op0
     2919      (write-x86-lap-operand t op0 ds)
     2920      (when op1
     2921        (write-x86-lap-operand t op1 ds)
     2922        (when op2
     2923          (write-x86-lap-operand t op2 ds))))
     2924    (format t ")~&")
     2925    (decf nbytes 4)
     2926    (while (plusp nbytes)
     2927      (dotimes (i (min nbytes 4))
     2928        (format t "~7t~(~2,'0x~)" (aref code-vector byteidx))
     2929        (incf byteidx))
     2930      (format t "~%")
     2931      (decf nbytes 4))))
    29212932
    29222933(defun x86-print-disassembled-instruction (ds instruction seq function)
     
    29402951      (setq seq 0))
    29412952    (format t "~&")
    2942     (let ((tab-stop 4))
    2943       (x86-print-di-lap ds instruction tab-stop pc))
     2953    (let ((tab-stop 4)
     2954          (fn (if *disassemble-verbose*
     2955                'x86-print-di-raw
     2956                'x86-print-di-lap)))
     2957      (funcall fn ds instruction tab-stop pc))
    29442958    (1+ seq)))
    29452959
Note: See TracChangeset for help on using the changeset viewer.