1 ;;;; x86 support for the debugger
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
17 (define-vop (debug-cur-sp)
18 (:translate current-sp)
20 (:results (res :scs (sap-reg sap-stack)))
21 (:result-types system-area-pointer)
25 (define-vop (debug-cur-fp)
26 (:translate current-fp)
28 (:results (res :scs (sap-reg sap-stack)))
29 (:result-types system-area-pointer)
33 ;;; Stack-ref and %set-stack-ref can be used to read and store
34 ;;; descriptor objects on the control stack. Use the sap-ref
35 ;;; functions to access other data types.
36 (define-vop (read-control-stack)
37 (:translate stack-ref)
39 (:args (sap :scs (sap-reg) :to :eval)
40 (offset :scs (any-reg) :target temp))
41 (:arg-types system-area-pointer positive-fixnum)
42 (:temporary (:sc unsigned-reg :from (:argument 1)) temp)
43 (:results (result :scs (descriptor-reg)))
49 (make-ea :dword :base sap :disp (- word-bytes) :index temp))))
51 (define-vop (read-control-stack-c)
52 (:translate stack-ref)
54 (:args (sap :scs (sap-reg)))
56 (:arg-types system-area-pointer (:constant (signed-byte 30)))
57 (:results (result :scs (descriptor-reg)))
60 (inst mov result (make-ea :dword :base sap
61 :disp (- (* (1+ index) word-bytes))))))
63 (define-vop (write-control-stack)
64 (:translate %set-stack-ref)
66 (:args (sap :scs (sap-reg) :to :eval)
67 (offset :scs (any-reg) :target temp)
68 (value :scs (descriptor-reg) :to :result :target result))
69 (:arg-types system-area-pointer positive-fixnum *)
70 (:temporary (:sc unsigned-reg :from (:argument 1) :to :result) temp)
71 (:results (result :scs (descriptor-reg)))
77 (make-ea :dword :base sap :disp (- word-bytes) :index temp) value)
80 (define-vop (write-control-stack-c)
81 (:translate %set-stack-ref)
83 (:args (sap :scs (sap-reg))
84 (value :scs (descriptor-reg) :target result))
86 (:arg-types system-area-pointer (:constant (signed-byte 30)) *)
87 (:results (result :scs (descriptor-reg)))
90 (inst mov (make-ea :dword :base sap
91 :disp (- (* (1+ index) word-bytes)))
95 (define-vop (code-from-mumble)
97 (:args (thing :scs (descriptor-reg)))
98 (:results (code :scs (descriptor-reg)))
99 (:temporary (:sc unsigned-reg) temp)
100 (:variant-vars lowtag)
102 (let ((bogus (gen-label))
104 (loadw temp thing 0 lowtag)
105 (inst shr temp type-bits)
107 (inst shl temp (1- (integer-length word-bytes)))
108 (unless (= lowtag other-pointer-type)
109 (inst add temp (- lowtag other-pointer-type)))
113 (assemble (*elsewhere*)
115 (inst mov code nil-value)
118 (define-vop (code-from-lra code-from-mumble)
119 (:translate sb!di::lra-code-header)
120 (:variant other-pointer-type))
122 (define-vop (code-from-function code-from-mumble)
123 (:translate sb!di::function-code-header)
124 (:variant function-pointer-type))
126 (define-vop (make-lisp-obj)
128 (:translate sb!di::make-lisp-obj)
129 (:args (value :scs (unsigned-reg unsigned-stack) :target result))
130 (:arg-types unsigned-num)
131 (:results (result :scs (descriptor-reg)
132 :load-if (not (sc-is value unsigned-reg))
135 (move result value)))
137 (define-vop (get-lisp-obj-address)
139 (:translate sb!di::get-lisp-obj-address)
140 (:args (thing :scs (descriptor-reg control-stack) :target result))
141 (:results (result :scs (unsigned-reg)
142 :load-if (not (and (sc-is thing descriptor-reg)
143 (sc-is result unsigned-stack)))))
144 (:result-types unsigned-num)
146 (move result thing)))
149 (define-vop (function-word-offset)
151 (:translate sb!di::function-word-offset)
152 (:args (fun :scs (descriptor-reg)))
153 (:results (res :scs (unsigned-reg)))
154 (:result-types positive-fixnum)
156 (loadw res fun 0 function-pointer-type)
157 (inst shr res type-bits)))