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 (defun machine-version ()
12 "Returns a string describing the version of the local machine."
16 ;;;; FIXUP-CODE-OBJECT
18 (defun fixup-code-object (code offset value kind)
19 (unless (zerop (rem offset n-word-bytes))
20 (error "Unaligned instruction? offset=#x~X." offset))
22 (let* ((sap (truly-the system-area-pointer
23 (%primitive sb!kernel::code-instructions code)))
24 (inst (sap-ref-32 sap offset)))
25 (setf (sap-ref-32 sap offset)
28 (logior (ash (ldb (byte 11 0) value) 1)
29 (logand inst #xffffc000)))
31 (let ((low-bits (ldb (byte 11 0) value)))
32 (assert (<= 0 low-bits (1- (ash 1 4))))
33 (logior (ash low-bits 17)
34 (logand inst #xffe0ffff))))
36 (logior (ash (ldb (byte 5 13) value) 16)
37 (ash (ldb (byte 2 18) value) 14)
38 (ash (ldb (byte 2 11) value) 12)
39 (ash (ldb (byte 11 20) value) 1)
40 (ldb (byte 1 31) value)
41 (logand inst #xffe00000)))
43 (let ((bits (ldb (byte 9 2) value)))
44 (assert (zerop (ldb (byte 2 0) value)))
46 (logand inst #xffe0e002)))))))))
48 (define-alien-routine ("os_context_pc_addr" context-pc-addr) (* unsigned-int)
49 (context (* os-context-t)))
51 (defun context-pc (context)
52 (declare (type (alien (* os-context-t)) context))
53 (int-sap (logandc2 (deref (context-pc-addr context)) 3)))
55 (define-alien-routine ("os_context_register_addr" context-register-addr)
57 (context (* os-context-t))
60 ;;; FIXME: Should this and CONTEXT-PC be INLINE to reduce consing?
61 ;;; (Are they used in anything time-critical, or just the debugger?)
62 (defun context-register (context index)
63 (declare (type (alien (* os-context-t)) context))
64 (deref (context-register-addr context index)))
66 (defun %set-context-register (context index new)
67 (declare (type (alien (* os-context-t)) context))
68 (setf (deref (context-register-addr context index))
73 (defun context-floating-point-modes (context)
74 (warn "stub CONTEXT-FLOATING-POINT-MODES")
77 ;;;; Internal-error-arguments.
79 ;;; INTERNAL-ERROR-ARGUMENTS -- interface.
81 ;;; Given the sigcontext, extract the internal error arguments from the
82 ;;; instruction stream.
84 (defun internal-error-args (context)
85 (declare (type (alien (* os-context-t)) context))
86 (let ((pc (context-pc context)))
87 (declare (type system-area-pointer pc))
88 (let* ((length (sap-ref-8 pc 4))
89 (vector (make-array length :element-type '(unsigned-byte 8))))
90 (declare (type (unsigned-byte 8) length)
91 (type (simple-array (unsigned-byte 8) (*)) vector))
92 (copy-from-system-area pc (* n-byte-bits 5)
95 (* length n-byte-bits))
97 (error-number (sb!c:read-var-integer vector index)))
98 (collect ((sc-offsets))
100 (when (>= index length)
102 (sc-offsets (sb!c:read-var-integer vector index)))
103 (values error-number (sc-offsets)))))))