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.
14 (define-vop (debug-cur-sp)
15 (:translate current-sp)
17 (:results (res :scs (sap-reg sap-stack)))
18 (:result-types system-area-pointer)
22 (define-vop (debug-cur-fp)
23 (:translate current-fp)
25 (:results (res :scs (sap-reg sap-stack)))
26 (:result-types system-area-pointer)
30 ;;; Stack-ref and %set-stack-ref can be used to read and store
31 ;;; descriptor objects on the control stack. Use the sap-ref
32 ;;; functions to access other data types.
33 (define-vop (read-control-stack)
34 (:translate stack-ref)
36 (:args (sap :scs (sap-reg) :to :eval)
37 (offset :scs (any-reg) :target temp))
38 (:arg-types system-area-pointer positive-fixnum)
39 (:temporary (:sc unsigned-reg :from (:argument 1)) temp)
40 (:results (result :scs (descriptor-reg)))
46 (make-ea :qword :base sap :disp (frame-byte-offset 0) :index temp
47 :scale (ash 1 (- word-shift n-fixnum-tag-bits))))))
49 (define-vop (read-control-stack-c)
50 (:translate stack-ref)
52 (:args (sap :scs (sap-reg)))
54 (:arg-types system-area-pointer (:constant (signed-byte 29)))
55 (:results (result :scs (descriptor-reg)))
58 (inst mov result (make-ea :qword :base sap
59 :disp (frame-byte-offset index)))))
61 (define-vop (write-control-stack)
62 (:translate %set-stack-ref)
64 (:args (sap :scs (sap-reg) :to :eval)
65 (offset :scs (any-reg) :target temp)
66 (value :scs (descriptor-reg) :to :result :target result))
67 (:arg-types system-area-pointer positive-fixnum *)
68 (:temporary (:sc unsigned-reg :from (:argument 1) :to :result) temp)
69 (:results (result :scs (descriptor-reg)))
75 (make-ea :qword :base sap :disp (frame-byte-offset 0) :index temp
76 :scale (ash 1 (- word-shift n-fixnum-tag-bits)))
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 29)) *)
87 (:results (result :scs (descriptor-reg)))
90 (inst mov (make-ea :qword :base sap :disp (frame-byte-offset index))
94 (define-vop (code-from-mumble)
96 (:args (thing :scs (descriptor-reg)))
97 (:results (code :scs (descriptor-reg)))
98 (:temporary (:sc unsigned-reg) temp)
99 (:variant-vars lowtag)
101 (let ((bogus (gen-label))
103 (loadw temp thing 0 lowtag)
104 (inst shr temp n-widetag-bits)
106 (inst shl temp (1- (integer-length n-word-bytes)))
107 (unless (= lowtag other-pointer-lowtag)
108 (inst add temp (- lowtag other-pointer-lowtag)))
112 (assemble (*elsewhere*)
114 (inst mov code nil-value)
117 (define-vop (code-from-lra code-from-mumble)
118 (:translate sb!di::lra-code-header)
119 (:variant other-pointer-lowtag))
121 (define-vop (code-from-function code-from-mumble)
122 (:translate sb!di::fun-code-header)
123 (:variant fun-pointer-lowtag))
125 (define-vop (%make-lisp-obj)
127 (:translate %make-lisp-obj)
128 (:args (value :scs (unsigned-reg unsigned-stack) :target result))
129 (:arg-types unsigned-num)
130 (:results (result :scs (descriptor-reg)
131 :load-if (not (sc-is value unsigned-reg))
134 (move result value)))
136 (define-vop (get-lisp-obj-address)
138 (:translate sb!di::get-lisp-obj-address)
139 (:args (thing :scs (descriptor-reg control-stack) :target result))
140 (:results (result :scs (unsigned-reg)
141 :load-if (not (and (sc-is thing descriptor-reg)
142 (sc-is result unsigned-stack)))))
143 (:result-types unsigned-num)
145 (move result thing)))
148 (define-vop (fun-word-offset)
150 (:translate sb!di::fun-word-offset)
151 (:args (fun :scs (descriptor-reg)))
152 (:results (res :scs (unsigned-reg)))
153 (:result-types positive-fixnum)
155 (loadw res fun 0 fun-pointer-lowtag)
156 (inst shr res n-widetag-bits)))