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 (aver (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)
58 (define-alien-routine ("os_context_register_addr" context-register-addr)
60 (context (* os-context-t))
63 (define-alien-routine ("os_context_bd_cause" context-bd-cause-int)
65 (context (* os-context-t)))
67 ;;; FIXME: Should this and CONTEXT-PC be INLINE to reduce consing?
68 ;;; (Are they used in anything time-critical, or just the debugger?)
69 (defun context-register (context index)
70 (declare (type (alien (* os-context-t)) context))
71 (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)
84 (defun context-floating-point-modes (context)
85 (declare (ignore context))
86 (warn "stub CONTEXT-FLOATING-POINT-MODES")
89 ;;;; Internal-error-arguments.
91 ;;; INTERNAL-ERROR-ARGUMENTS -- interface.
93 ;;; Given the sigcontext, extract the internal error arguments from the
94 ;;; instruction stream.
96 (defun internal-error-args (context)
97 (declare (type (alien (* os-context-t)) context))
98 (/show0 "entering INTERNAL-ERROR-ARGS, CONTEXT=..")
100 (let ((pc (context-pc context))
101 (cause (context-bd-cause-int context)))
102 (declare (type system-area-pointer pc))
104 (/hexstr (sap-int pc))
105 ;; KLUDGE: This exposure of the branch delay mechanism hurts.
106 (when (logbitp 31 cause)
107 (setf pc (sap+ pc 4)))
108 (when (= (sap-ref-8 pc 4) 255)
109 (setf pc (sap+ pc 1)))
111 (/hexstr (sap-int pc))
112 (let* ((length (sap-ref-8 pc 4))
113 (vector (make-array length :element-type '(unsigned-byte 8))))
114 (declare (type (unsigned-byte 8) length)
115 (type (simple-array (unsigned-byte 8) (*)) vector))
116 (/show0 "LENGTH,VECTOR,ERROR-NUMBER=..")
119 (copy-ub8-from-system-area pc 5 vector 0 length)
121 (error-number (sb!c:read-var-integer vector index)))
122 (/hexstr error-number)
123 (collect ((sc-offsets))
127 (when (>= index length)
129 (sc-offsets (sb!c:read-var-integer vector index)))
130 (values error-number (sc-offsets)))))))