4 (define-alien-type os-context-t (struct os-context-t-struct))
7 ;;;; MACHINE-TYPE and MACHINE-VERSION
10 "Returns a string describing the type of the local machine."
13 ;;; support for CL:MACHINE-VERSION defined OAOO elsewhere
14 (defun get-machine-version ()
15 #!+little-endian "little-endian"
16 #!-little-endian "big-endian")
19 ;;;; FIXUP-CODE-OBJECT
21 (defun fixup-code-object (code offset value kind)
22 (unless (zerop (rem offset n-word-bytes))
23 (error "Unaligned instruction? offset=#x~X." offset))
25 (let ((sap (truly-the system-area-pointer
26 (%primitive sb!c::code-instructions code))))
29 (aver (zerop (ash value -28)))
30 (setf (ldb (byte 26 0) (sap-ref-32 sap offset))
34 #!+little-endian offset
35 #!-little-endian (+ offset 2))
37 (if (logbitp 15 value) 1 0))))
40 #!+little-endian offset
41 #!-little-endian (+ offset 2))
42 (ldb (byte 16 0) value)))))))
45 (define-alien-routine ("os_context_pc_addr" context-pc-addr) (* unsigned-int)
46 (context (* os-context-t)))
48 (defun context-pc (context)
49 (declare (type (alien (* os-context-t)) context))
50 ;; KLUDGE: this sucks, and furthermore will break on either of (a)
51 ;; porting back to IRIX or (b) running on proper 64-bit support.
52 ;; Linux on the MIPS defines its registers in the sigcontext as
53 ;; 64-bit quantities ("unsigned long long"), presumably to be
54 ;; binary-compatible with 64-bit mode. Since there appears not to
55 ;; be ALIEN support for 64-bit return values, we have to do the
56 ;; hacky pointer arithmetic thing. -- CSR, 2002-09-01
57 (int-sap (deref (context-pc-addr context)
61 (define-alien-routine ("os_context_register_addr" context-register-addr)
63 (context (* os-context-t))
66 (define-alien-routine ("os_context_bd_cause" context-bd-cause-int)
68 (context (* os-context-t)))
70 ;;; FIXME: Should this and CONTEXT-PC be INLINE to reduce consing?
71 ;;; (Are they used in anything time-critical, or just the debugger?)
72 (defun context-register (context index)
73 (declare (type (alien (* os-context-t)) context))
74 (deref (context-register-addr context index)
78 (defun %set-context-register (context index new)
79 (declare (type (alien (* os-context-t)) context))
80 (setf (deref (context-register-addr context index)
87 (defun context-floating-point-modes (context)
88 (declare (ignore context))
89 (warn "stub CONTEXT-FLOATING-POINT-MODES")
92 ;;;; Internal-error-arguments.
94 ;;; INTERNAL-ERROR-ARGUMENTS -- interface.
96 ;;; Given the sigcontext, extract the internal error arguments from the
97 ;;; instruction stream.
99 (defun internal-error-args (context)
100 (declare (type (alien (* os-context-t)) context))
101 (/show0 "entering INTERNAL-ERROR-ARGS, CONTEXT=..")
103 (let ((pc (context-pc context))
104 (cause (context-bd-cause-int context)))
105 (declare (type system-area-pointer pc))
106 ;; KLUDGE: This exposure of the branch delay mechanism hurts.
107 (when (logbitp 31 cause)
108 (setf pc (sap+ pc 4)))
109 (args-for-unimp-inst pc)))
111 (defun args-for-unimp-inst (pc)
112 (declare (type system-area-pointer 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 (copy-ub8-from-system-area pc 5 vector 0 length)
119 (error-number (sb!c:read-var-integer vector index)))
120 (collect ((sc-offsets))
122 (when (>= index length)
124 (sc-offsets (sb!c:read-var-integer vector index)))
125 (values error-number (sc-offsets))))))