1 #ifndef _MACH_EXCEPTION_TYPES_H_ 2 #define _MACH_EXCEPTION_TYPES_H_ 3 4 #if defined(__i386__) || defined(__amd64__) 5 #define EXC_TYPES_COUNT 13 6 #else 7 #define EXC_TYPES_COUNT 2 8 #endif 9 10 #define EXC_MASK_MACHINE 0 11 12 /* 13 * Machine-independent exception definitions. 14 */ 15 16 #define EXC_BAD_ACCESS 1 /* Could not access memory */ 17 /* Code contains kern_return_t describing error. */ 18 /* Subcode contains bad memory address. */ 19 20 #define EXC_BAD_INSTRUCTION 2 /* Instruction failed */ 21 /* Illegal or undefined instruction or operand */ 22 23 #define EXC_ARITHMETIC 3 /* Arithmetic exception */ 24 /* Exact nature of exception is in code field */ 25 26 #define EXC_EMULATION 4 /* Emulation instruction */ 27 /* Emulation support instruction encountered */ 28 /* Details in code and subcode fields */ 29 30 #define EXC_SOFTWARE 5 /* Software generated exception */ 31 /* Exact exception is in code field. */ 32 /* Codes 0 - 0xFFFF reserved to hardware */ 33 /* Codes 0x10000 - 0x1FFFF reserved for OS emulation (Unix) */ 34 35 #define EXC_BREAKPOINT 6 /* Trace, breakpoint, etc. */ 36 /* Details in code field. */ 37 38 #define EXC_SYSCALL 7 /* System calls. */ 39 40 #define EXC_MACH_SYSCALL 8 /* Mach system calls. */ 41 42 #define EXC_RPC_ALERT 9 /* RPC alert */ 43 44 #define EXC_CRASH 10 /* Abnormal process exit */ 45 46 #define EXC_RESOURCE 11 /* Hit resource consumption limit */ 47 /* Exact resource is in code field. */ 48 49 #define EXC_GUARD 12 /* Violated guarded resource protections */ 50 51 #define EXC_MAX EXC_GUARD 52 53 #define EXC_MASK_BAD_ACCESS (1 << EXC_BAD_ACCESS) 54 #define EXC_MASK_BAD_INSTRUCTION (1 << EXC_BAD_INSTRUCTION) 55 #define EXC_MASK_ARITHMETIC (1 << EXC_ARITHMETIC) 56 #define EXC_MASK_EMULATION (1 << EXC_EMULATION) 57 #define EXC_MASK_SOFTWARE (1 << EXC_SOFTWARE) 58 #define EXC_MASK_BREAKPOINT (1 << EXC_BREAKPOINT) 59 #define EXC_MASK_SYSCALL (1 << EXC_SYSCALL) 60 #define EXC_MASK_MACH_SYSCALL (1 << EXC_MACH_SYSCALL) 61 #define EXC_MASK_RPC_ALERT (1 << EXC_RPC_ALERT) 62 #define EXC_MASK_CRASH (1 << EXC_CRASH) 63 #define EXC_MASK_RESOURCE (1 << EXC_RESOURCE) 64 #define EXC_MASK_GUARD (1 << EXC_GUARD) 65 66 #define EXC_MASK_ALL (EXC_MASK_BAD_ACCESS | \ 67 EXC_MASK_BAD_INSTRUCTION | \ 68 EXC_MASK_ARITHMETIC | \ 69 EXC_MASK_EMULATION | \ 70 EXC_MASK_SOFTWARE | \ 71 EXC_MASK_BREAKPOINT | \ 72 EXC_MASK_SYSCALL | \ 73 EXC_MASK_MACH_SYSCALL | \ 74 EXC_MASK_RPC_ALERT | \ 75 EXC_MASK_RESOURCE | \ 76 EXC_MASK_GUARD | \ 77 EXC_MASK_MACHINE) 78 79 80 81 82 #define EXCEPTION_DEFAULT 1 83 #define EXCEPTION_STATE 2 84 #define EXCEPTION_STATE_IDENTITY 3 85 86 #define MACH_EXCEPTION_CODES 0x80000000 87 /* Send 64-bit code and subcode in the exception header */ 88 89 #define FIRST_EXCEPTION 1 /* ZERO is illegal */ 90 91 92 93 #include <sys/mach/port.h> 94 #include <sys/mach/thread_status.h> 95 #include <sys/mach/vm_types.h> 96 /* 97 * Exported types 98 */ 99 100 typedef int exception_type_t; 101 typedef int exception_data_type_t; 102 typedef int64_t mach_exception_data_type_t; 103 typedef int exception_behavior_t; 104 typedef exception_data_type_t *exception_data_t; 105 typedef mach_exception_data_type_t *mach_exception_data_t; 106 typedef unsigned int exception_mask_t; 107 typedef exception_mask_t *exception_mask_array_t; 108 typedef exception_behavior_t *exception_behavior_array_t; 109 typedef thread_state_flavor_t *exception_flavor_array_t; 110 typedef mach_port_t *exception_port_array_t; 111 typedef mach_exception_data_type_t mach_exception_code_t; 112 typedef mach_exception_data_type_t mach_exception_subcode_t; 113 114 115 116 struct exception_action{ 117 struct ipc_port *port; /* exception port */ 118 thread_state_flavor_t flavor; /* state flavor to send */ 119 exception_behavior_t behavior; /* exception type to raise */ 120 }; 121 122 #endif 123