Changeset 5072
- Timestamp:
- Sep 2, 2006, 10:11:43 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ccl/lisp-kernel/x86-exceptions.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/lisp-kernel/x86-exceptions.c
r5017 r5072 917 917 } 918 918 919 920 #ifdef DARWIN 921 /* 922 There seems to be a problem with thread-level exception handling; 923 Mach seems (under some cirumstances) to conclude that there's 924 no thread-level handler and exceptions get passed up to a 925 handler that raises Un*x signals. Ignore those signals so that 926 the exception will repropagate and eventually get caught by 927 catch_exception_raise() at the thread level. 928 929 Mach sucks, but no one understands how. 930 */ 931 void 932 bogus_signal_handler() 933 { 934 /* This does nothing, but does it with signals masked */ 935 } 936 #endif 937 919 938 void 920 939 altstack_signal_handler(int signum, siginfo_t *info, ExceptionInformation *context) … … 1064 1083 install_signal_handler(SIGSEGV,altstack_signal_handler); 1065 1084 install_signal_handler(SIGFPE, altstack_signal_handler); 1085 #else 1086 install_signal_handler(SIGTRAP,bogus_signal_handler); 1087 install_signal_handler(SIGILL, bogus_signal_handler); 1088 1089 install_signal_handler(SIGBUS, bogus_signal_handler); 1090 install_signal_handler(SIGSEGV,bogus_signal_handler); 1091 install_signal_handler(SIGFPE, bogus_signal_handler); 1066 1092 #endif 1067 1093 … … 1541 1567 1542 1568 pthread_mutex_t _mach_exception_lock, *mach_exception_lock; 1543 extern void pseudo_sigreturn(ExceptionInformation *); 1569 extern void pseudo_sigreturn(void); 1570 1544 1571 1545 1572 … … 1730 1757 1731 1758 1732 if (result != KERN_SUCCESS) {1733 get_tcr(true);1734 Bug(NULL, "Exception thread can't obtain thread state, Mach result = %d", result);1735 }1736 1759 stackp = (LispObj) find_foreign_rsp(ts->rsp,tcr->cs_area,tcr); 1737 1760 stackp = TRUNC_DOWN(stackp, C_REDZONE_LEN, C_STK_ALIGN); … … 1916 1939 int signum = 0, code = *code_vector, code1; 1917 1940 TCR *tcr = TCR_FROM_EXCEPTION_PORT(exception_port); 1918 kern_return_t kret ;1941 kern_return_t kret, call_kret; 1919 1942 #ifdef X8664 1920 1943 x86_thread_state64_t ts; … … 1933 1956 #ifdef X8664 1934 1957 thread_state_count = x86_THREAD_STATE64_COUNT; 1935 thread_get_state(thread,1936 x86_THREAD_STATE64,1937 (thread_state_t)&ts,1958 call_kret = thread_get_state(thread, 1959 x86_THREAD_STATE64, 1960 (thread_state_t)&ts, 1938 1961 &thread_state_count); 1962 MACH_CHECK_ERROR("getting thread state",call_kret); 1939 1963 #else 1940 1964 thread_state_count = x86_THREAD_STATE_COUNT; … … 2012 2036 2013 2037 2014 typedef struct { 2015 mach_msg_header_t Head; 2016 /* start of the kernel processed data */ 2017 mach_msg_body_t msgh_body; 2018 mach_msg_port_descriptor_t thread; 2019 mach_msg_port_descriptor_t task; 2020 /* end of the kernel processed data */ 2021 NDR_record_t NDR; 2022 exception_type_t exception; 2023 mach_msg_type_number_t codeCnt; 2024 integer_t code[2]; 2025 mach_msg_trailer_t trailer; 2026 } exceptionRequest; 2027 2028 2029 boolean_t 2030 openmcl_exc_server(mach_msg_header_t *in, mach_msg_header_t *out) 2031 { 2032 static NDR_record_t _NDR = {0}; 2033 kern_return_t handled; 2034 mig_reply_error_t *reply = (mig_reply_error_t *) out; 2035 exceptionRequest *req = (exceptionRequest *) in; 2036 2037 reply->NDR = _NDR; 2038 2039 out->msgh_bits = in->msgh_bits & MACH_MSGH_BITS_REMOTE_MASK; 2040 out->msgh_remote_port = in->msgh_remote_port; 2041 out->msgh_size = sizeof(mach_msg_header_t)+(3 * sizeof(unsigned)); 2042 out->msgh_local_port = MACH_PORT_NULL; 2043 out->msgh_id = in->msgh_id+100; 2044 2045 /* Could handle other exception flavors in the range 2401-2403 */ 2046 2047 2048 if (in->msgh_id != 2401) { 2049 reply->RetCode = MIG_BAD_ID; 2050 return FALSE; 2051 } 2052 handled = catch_exception_raise(req->Head.msgh_local_port, 2053 req->thread.name, 2054 req->task.name, 2055 req->exception, 2056 req->code, 2057 req->codeCnt); 2058 reply->RetCode = handled; 2059 return TRUE; 2060 } 2038 2061 2039 2062 2040 /* … … 2070 2048 mach_port_t p = TCR_TO_EXCEPTION_PORT(arg); 2071 2049 2072 mach_msg_server( openmcl_exc_server, 2048, p, 0);2050 mach_msg_server(exc_server, 256, p, 0); 2073 2051 /* Should never return. */ 2074 2052 abort();
Note:
See TracChangeset
for help on using the changeset viewer.
