3 (define-alien-type os-context-t
(struct os-context-t-struct
))
5 ;;;; MACHINE-TYPE and MACHINE-VERSION
8 "Returns a string describing the type of the local machine."
11 ;;; support for CL:MACHINE-VERSION defined OAOO elsewhere
12 (defun get-machine-version ()
15 ;;;; FIXUP-CODE-OBJECT
16 ;FIX-lav: unify code with genesis.lisp fixup
17 (defun fixup-code-object (code offset value kind
)
18 (unless (zerop (rem offset n-word-bytes
))
19 (error "Unaligned instruction? offset=#x~X." offset
))
21 (let* ((sap (%primitive sb
!kernel
::code-instructions code
))
22 (inst (sap-ref-32 sap offset
)))
23 (setf (sap-ref-32 sap offset
)
26 (logior (mask-field (byte 18 14) value
)
28 (1+ (ash (ldb (byte 13 0) value
) 1))
29 (ash (ldb (byte 13 0) value
) 1))))
31 (logior (if (< value
0)
32 (1+ (ash (ldb (byte 10 0) value
) 1))
33 (ash (ldb (byte 11 0) value
) 1))
34 (mask-field (byte 18 14) inst
)))
36 (let ((low-bits (ldb (byte 11 0) value
)))
37 (aver (<= 0 low-bits
(1- (ash 1 4))))
38 (logior (ash (dpb (ldb (byte 4 0) value
)
40 (ldb (byte 1 4) value
)) 17)
41 (logand inst
#xffe0ffff
))))
43 (logior (ash (ldb (byte 5 13) value
) 16)
44 (ash (ldb (byte 2 18) value
) 14)
45 (ash (ldb (byte 2 11) value
) 12)
46 (ash (ldb (byte 11 20) value
) 1)
47 (ldb (byte 1 31) value
)
48 (logand inst
#xffe00000
)))
50 (let ((bits (ldb (byte 9 2) value
)))
51 (aver (zerop (ldb (byte 2 0) value
)))
53 (mask-field (byte 1 1) inst
)
54 (mask-field (byte 3 13) inst
)
55 (mask-field (byte 11 21) inst
)))))))))
57 (define-alien-routine ("os_context_pc_addr" context-pc-addr
) (* unsigned-int
)
58 (context (* os-context-t
)))
60 (defun context-pc (context)
61 (declare (type (alien (* os-context-t
)) context
))
62 (int-sap (logandc2 (deref (context-pc-addr context
)) 3)))
64 (define-alien-routine ("os_context_register_addr" context-register-addr
)
66 (context (* os-context-t
))
69 ;;; FIXME: Should this and CONTEXT-PC be INLINE to reduce consing?
70 ;;; (Are they used in anything time-critical, or just the debugger?)
71 (defun context-register (context index
)
72 (declare (type (alien (* os-context-t
)) context
))
73 (deref (context-register-addr context index
)))
75 (defun %set-context-register
(context index new
)
76 (declare (type (alien (* os-context-t
)) context
))
77 (setf (deref (context-register-addr context index
))
82 (defun context-floating-point-modes (context)
83 (warn "stub CONTEXT-FLOATING-POINT-MODES")
86 ;;;; Internal-error-arguments.
88 ;;; INTERNAL-ERROR-ARGUMENTS -- interface.
90 ;;; Given the sigcontext, extract the internal error arguments from the
91 ;;; instruction stream.
93 (defun internal-error-args (context)
94 (declare (type (alien (* os-context-t
)) context
))
95 (let ((pc (context-pc context
)))
96 (declare (type system-area-pointer pc
))
97 (let* ((length (sap-ref-8 pc
4))
98 (vector (make-array length
:element-type
'(unsigned-byte 8))))
99 (declare (type (unsigned-byte 8) length
)
100 (type (simple-array (unsigned-byte 8) (*)) vector
))
101 (copy-ub8-from-system-area pc
5 vector
0 length
)
103 (error-number (sb!c
:read-var-integer vector index
)))
104 (collect ((sc-offsets))
106 (when (>= index length
)
108 (sc-offsets (sb!c
:read-var-integer vector index
)))
109 (values error-number
(sc-offsets)))))))