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 ()
13 #!+little-endian "little-endian"
14 #!-little-endian "big-endian")
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!c::code-instructions code))))
26 (assert (zerop (ash value -28)))
27 (setf (ldb (byte 26 0) (sap-ref-32 sap offset))
31 #!+little-endian offset
32 #!-little-endian (+ offset 2))
34 (if (logbitp 15 value) 1 0))))
37 #!+little-endian offset
38 #!-little-endian (+ offset 2))
39 (ldb (byte 16 0) value)))))))
42 (define-alien-routine ("os_context_pc_addr" context-pc-addr) (* unsigned-int)
43 (context (* os-context-t)))
45 (defun context-pc (context)
46 (declare (type (alien (* os-context-t)) context))
47 ;; KLUDGE: this sucks, and furthermore will break on either of (a)
48 ;; porting back to IRIX or (b) running on proper 64-bit support.
49 ;; Linux on the MIPS defines its registers in the sigcontext as
50 ;; 64-bit quantities ("unsigned long long"), presumably to be
51 ;; binary-compatible with 64-bit mode. Since there appears not to
52 ;; be ALIEN support for 64-bit return values, we have to do the
53 ;; hacky pointer arithmetic thing. -- CSR, 2002-09-01
54 (int-sap (deref (context-pc-addr context)
59 (define-alien-routine ("os_context_register_addr" context-register-addr)
61 (context (* os-context-t))
64 (define-alien-routine ("os_context_bd_cause" context-bd-cause-int)
66 (context (* os-context-t)))
68 ;;; FIXME: Should this and CONTEXT-PC be INLINE to reduce consing?
69 ;;; (Are they used in anything time-critical, or just the debugger?)
70 (defun context-register (context index)
71 (declare (type (alien (* os-context-t)) context))
72 (deref (context-register-addr context index)
76 (defun %set-context-register (context index new)
77 (declare (type (alien (* os-context-t)) context))
78 (setf (deref (context-register-addr context index)
85 (defun context-floating-point-modes (context)
86 (declare (ignore context))
87 (warn "stub CONTEXT-FLOATING-POINT-MODES")
90 ;;;; Internal-error-arguments.
92 ;;; INTERNAL-ERROR-ARGUMENTS -- interface.
94 ;;; Given the sigcontext, extract the internal error arguments from the
95 ;;; instruction stream.
97 (defun internal-error-args (context)
98 (declare (type (alien (* os-context-t)) context))
99 (/show0 "entering INTERNAL-ERROR-ARGS, CONTEXT=..")
101 (let ((pc (context-pc context))
102 (cause (context-bd-cause-int context)))
103 (declare (type system-area-pointer pc))
105 (/hexstr (sap-int pc))
106 ;; KLUDGE: This exposure of the branch delay mechanism hurts.
107 (when (logbitp 31 cause)
108 (setf pc (sap+ pc 4)))
109 (when (= (sap-ref-8 pc 4) 255)
110 (setf pc (sap+ pc 1)))
112 (/hexstr (sap-int pc))
113 (let* ((length (sap-ref-8 pc 4))
114 (vector (make-array length :element-type '(unsigned-byte 8))))
115 (declare (type (unsigned-byte 8) length)
116 (type (simple-array (unsigned-byte 8) (*)) vector))
117 (/show0 "LENGTH,VECTOR,ERROR-NUMBER=..")
120 (copy-from-system-area pc (* n-byte-bits 5)
121 vector (* n-word-bits
123 (* length n-byte-bits))
125 (error-number (sb!c:read-var-integer vector index)))
126 (/hexstr error-number)
127 (collect ((sc-offsets))
131 (when (>= index length)
133 (sc-offsets (sb!c:read-var-integer vector index)))
134 (values error-number (sc-offsets)))))))