7 #include <mach/mach_error.h>
8 #include <mach/thread_status.h>
9 #include <mach/exception.h>
10 #include <mach/task.h>
15 #define SS_DISABLE SA_DISABLE
18 /* This is not defined in any header, although documented. */
20 /* http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/exc_server.html says:
21 The exc_server function is the MIG generated server handling function
22 to handle messages from the kernel relating to the occurrence of an
23 exception in a thread. Such messages are delivered to the exception port
24 set via thread_set_exception_ports or task_set_exception_ports. When an
25 exception occurs in a thread, the thread sends an exception message to its
26 exception port, blocking in the kernel waiting for the receipt of a reply.
27 The exc_server function performs all necessary argument handling for this
28 kernel message and calls catch_exception_raise, catch_exception_raise_state
29 or catch_exception_raise_state_identity, which should handle the exception.
30 If the called routine returns KERN_SUCCESS, a reply message will be sent,
31 allowing the thread to continue from the point of the exception; otherwise,
32 no reply message is sent and the called routine must have dealt with the
33 exception thread directly. */
35 exc_server (mach_msg_header_t *request_msg,
36 mach_msg_header_t *reply_msg);
39 /* http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/catch_exception_raise.html
40 These functions are defined in this file, and called by exc_server.
41 FIXME: What needs to be done when this code is put into a shared library? */
43 catch_exception_raise (mach_port_t exception_port,
46 exception_type_t exception,
47 exception_data_t code,
48 mach_msg_type_number_t code_count);
50 catch_exception_raise_state (mach_port_t exception_port,
51 exception_type_t exception,
52 exception_data_t code,
53 mach_msg_type_number_t code_count,
54 thread_state_flavor_t *flavor,
55 thread_state_t in_state,
56 mach_msg_type_number_t in_state_count,
57 thread_state_t out_state,
58 mach_msg_type_number_t *out_state_count);
60 catch_exception_raise_state_identity (mach_port_t exception_port,
63 exception_type_t exception,
64 exception_data_t code,
65 mach_msg_type_number_t codeCnt,
66 thread_state_flavor_t *flavor,
67 thread_state_t in_state,
68 mach_msg_type_number_t in_state_count,
69 thread_state_t out_state,
70 mach_msg_type_number_t *out_state_count);
72 int mach_initialize ();