xref: /xnu-11215.61.5/osfmk/man/thread_set_exception_ports.html (revision 4f1223e81cd707a65cc109d0b8ad6653699da3c4)
1*4f1223e8SApple OSS Distributions<h2>thread_set_exception_ports</h2>
2*4f1223e8SApple OSS Distributions<hr>
3*4f1223e8SApple OSS Distributions<p>
4*4f1223e8SApple OSS Distributions<strong>Function</strong> - Set exception ports for a thread.
5*4f1223e8SApple OSS Distributions<h3>SYNOPSIS</h3>
6*4f1223e8SApple OSS Distributions<pre>
7*4f1223e8SApple OSS Distributions<strong>kern_return_t   thread_set_exception_ports</strong>
8*4f1223e8SApple OSS Distributions                <strong>(thread_act_t</strong>                            <var>thread</var>,
9*4f1223e8SApple OSS Distributions                 <strong>exception_mask_t</strong>               <var>exception_types</var>,
10*4f1223e8SApple OSS Distributions                 <strong>mach_port_t</strong>                     <var>exception_port</var>,
11*4f1223e8SApple OSS Distributions                 <strong>exception_behavior_t</strong>                  <var>behavior</var>,
12*4f1223e8SApple OSS Distributions                 <strong>thread_state_flavor_t</strong>                   <var>flavor</var><strong>);</strong>
13*4f1223e8SApple OSS Distributions</pre>
14*4f1223e8SApple OSS Distributions<h3>PARAMETERS</h3>
15*4f1223e8SApple OSS Distributions<dl>
16*4f1223e8SApple OSS Distributions<p>
17*4f1223e8SApple OSS Distributions<dt> <var>thread</var>
18*4f1223e8SApple OSS Distributions<dd>
19*4f1223e8SApple OSS Distributions[in thread send right]
20*4f1223e8SApple OSS DistributionsThe thread for which to set the ports.
21*4f1223e8SApple OSS Distributions<p>
22*4f1223e8SApple OSS Distributions<dt> <var>exception_types</var>
23*4f1223e8SApple OSS Distributions<dd>
24*4f1223e8SApple OSS Distributions[in scalar]
25*4f1223e8SApple OSS DistributionsA flag word indicating the types of exceptions for which the
26*4f1223e8SApple OSS Distributionsexception port applies:
27*4f1223e8SApple OSS Distributions<dl>
28*4f1223e8SApple OSS Distributions<p>
29*4f1223e8SApple OSS Distributions<dt> <strong>EXC_MASK_BAD_ACCESS</strong>
30*4f1223e8SApple OSS Distributions<dd>
31*4f1223e8SApple OSS DistributionsCould not access memory.
32*4f1223e8SApple OSS Distributions<p>
33*4f1223e8SApple OSS Distributions<dt> <strong>EXC_MASK_BAD_INSTRUCTION</strong>
34*4f1223e8SApple OSS Distributions<dd>
35*4f1223e8SApple OSS DistributionsInstruction failed.  Illegal or undefined instruction or operand.
36*4f1223e8SApple OSS Distributions<p>
37*4f1223e8SApple OSS Distributions<dt> <strong>EXC_MASK_ARITHMETIC</strong>
38*4f1223e8SApple OSS Distributions<dd>
39*4f1223e8SApple OSS DistributionsArithmetic exception.
40*4f1223e8SApple OSS Distributions<p>
41*4f1223e8SApple OSS Distributions<dt> <strong>EXC_MASK_EMULATION</strong>
42*4f1223e8SApple OSS Distributions<dd>
43*4f1223e8SApple OSS DistributionsEmulation instruction.  Emulation support instruction
44*4f1223e8SApple OSS Distributionsencountered.
45*4f1223e8SApple OSS Distributions<p>
46*4f1223e8SApple OSS Distributions<dt> <strong>EXC_MASK_SOFTWARE</strong>
47*4f1223e8SApple OSS Distributions<dd>
48*4f1223e8SApple OSS DistributionsSoftware generated exception.
49*4f1223e8SApple OSS Distributions<p>
50*4f1223e8SApple OSS Distributions<dt> <strong>EXC_MASK_BREAKPOINT</strong>
51*4f1223e8SApple OSS Distributions<dd>
52*4f1223e8SApple OSS DistributionsTrace, breakpoint, etc.
53*4f1223e8SApple OSS Distributions<p>
54*4f1223e8SApple OSS Distributions<dt> <strong>EXC_MASK_SYSCALL</strong>
55*4f1223e8SApple OSS Distributions<dd>
56*4f1223e8SApple OSS DistributionsSystem call requested.
57*4f1223e8SApple OSS Distributions<p>
58*4f1223e8SApple OSS Distributions<dt> <strong>EXC_MASK_MACH_SYSCALL</strong>
59*4f1223e8SApple OSS Distributions<dd>
60*4f1223e8SApple OSS DistributionsSystem call with a number in the Mach call range requested.
61*4f1223e8SApple OSS Distributions</dl>
62*4f1223e8SApple OSS Distributions<p>
63*4f1223e8SApple OSS Distributions<dt> <var>exception_port</var>
64*4f1223e8SApple OSS Distributions<dd>
65*4f1223e8SApple OSS Distributions[in exception send right]
66*4f1223e8SApple OSS DistributionsThe exception port for all selected exception
67*4f1223e8SApple OSS Distributionstypes.
68*4f1223e8SApple OSS Distributions<p>
69*4f1223e8SApple OSS Distributions<dt> <var>behavior</var>
70*4f1223e8SApple OSS Distributions<dd>
71*4f1223e8SApple OSS Distributions[in scalar]
72*4f1223e8SApple OSS DistributionsThe type of exception message to be sent.  Defined types are:
73*4f1223e8SApple OSS Distributions<dl>
74*4f1223e8SApple OSS Distributions<p>
75*4f1223e8SApple OSS Distributions<dt> <strong>EXCEPTION_DEFAULT</strong>
76*4f1223e8SApple OSS Distributions<dd>
77*4f1223e8SApple OSS DistributionsSend a <strong>catch_exception_raise</strong> message including the thread
78*4f1223e8SApple OSS Distributionsidentity.
79*4f1223e8SApple OSS Distributions<p>
80*4f1223e8SApple OSS Distributions<dt> <strong>EXCEPTION_DEFAULT_PROTECTED</strong>
81*4f1223e8SApple OSS Distributions<dd>
82*4f1223e8SApple OSS DistributionsSend a <strong>catch_exception_raise</strong> message including the thread
83*4f1223e8SApple OSS Distributionsidentity.  Mark the exception port (and associated exceptions)
84*4f1223e8SApple OSS Distributionsas protected.
85*4f1223e8SApple OSS Distributions<p>
86*4f1223e8SApple OSS Distributions<dt> <strong>EXCEPTION_STATE</strong>
87*4f1223e8SApple OSS Distributions<dd>
88*4f1223e8SApple OSS DistributionsSend a <strong>catch_exception_raise_state</strong> message including the
89*4f1223e8SApple OSS Distributionsthread state.
90*4f1223e8SApple OSS Distributions<p>
91*4f1223e8SApple OSS Distributions<dt> <strong>EXCEPTION_STATE_PROTECTED</strong>
92*4f1223e8SApple OSS Distributions<dd>
93*4f1223e8SApple OSS DistributionsSend a <strong>catch_exception_raise_state</strong> message including the
94*4f1223e8SApple OSS Distributionsthread state.  Mark the exception port (and associated
95*4f1223e8SApple OSS Distributionsexceptions) as protected.
96*4f1223e8SApple OSS Distributions<p>
97*4f1223e8SApple OSS Distributions<dt> <strong>EXCEPTION_STATE_IDENTITY</strong>
98*4f1223e8SApple OSS Distributions<dd>
99*4f1223e8SApple OSS DistributionsSend a <strong>catch_exception_raise_state_identity</strong> message
100*4f1223e8SApple OSS Distributionsincluding the thread identity and state.
101*4f1223e8SApple OSS Distributions<p>
102*4f1223e8SApple OSS Distributions<dt> <strong>EXCEPTION_STATE_IDENTITY_PROTECTED</strong>
103*4f1223e8SApple OSS Distributions<dd>
104*4f1223e8SApple OSS DistributionsSend a <strong>catch_exception_raise_state_identity</strong> message
105*4f1223e8SApple OSS Distributionsincluding the thread identity and state.  Mark the exception port
106*4f1223e8SApple OSS Distributions(and associated exceptions) as protected.
107*4f1223e8SApple OSS Distributions</dl>
108*4f1223e8SApple OSS Distributions<p>
109*4f1223e8SApple OSS Distributions<dt> <var>flavor</var>
110*4f1223e8SApple OSS Distributions<dd>
111*4f1223e8SApple OSS Distributions[in scalar]
112*4f1223e8SApple OSS DistributionsThe type of state to be sent with the exception message.
113*4f1223e8SApple OSS DistributionsThese types are defined in \*L<mach/thread_states.h>\*O.
114*4f1223e8SApple OSS Distributions</dl>
115*4f1223e8SApple OSS Distributions<h3>DESCRIPTION</h3>
116*4f1223e8SApple OSS Distributions<p>
117*4f1223e8SApple OSS DistributionsThe <strong>thread_set_exception_ports</strong> function sets a specified
118*4f1223e8SApple OSS Distributionsset of exception
119*4f1223e8SApple OSS Distributionsports belonging to <var>thread</var>.
120*4f1223e8SApple OSS Distributions<h3>NOTES</h3>
121*4f1223e8SApple OSS Distributions<p>
122*4f1223e8SApple OSS DistributionsIf the value of the <strong>EXC_MACH_SYSCALL</strong> exception class exception port is
123*4f1223e8SApple OSS Distributionsthe host name port, Mach kernel traps are executed by the kernel as expected;
124*4f1223e8SApple OSS Distributionsany other value causes the attempted execution of these system call numbers to
125*4f1223e8SApple OSS Distributionsbe considered an exception.
126*4f1223e8SApple OSS Distributions<p>
127*4f1223e8SApple OSS DistributionsA "protected" exception port is one which cannot be fetched and for which
128*4f1223e8SApple OSS Distributionsexception processing cannot be aborted (<strong>thread_abort</strong>).
129*4f1223e8SApple OSS Distributions<h3>RETURN VALUES</h3>
130*4f1223e8SApple OSS Distributions<p>
131*4f1223e8SApple OSS DistributionsOnly generic errors apply.
132*4f1223e8SApple OSS Distributions<h3>RELATED INFORMATION</h3>
133*4f1223e8SApple OSS Distributions<p>
134*4f1223e8SApple OSS DistributionsFunctions:
135*4f1223e8SApple OSS Distributions<a href="mach_thread_self.html"><strong>mach_thread_self</strong></a>,
136*4f1223e8SApple OSS Distributions<a href="task_get_exception_ports.html"><strong>task_get_exception_ports</strong></a>,
137*4f1223e8SApple OSS Distributions<a href="task_set_exception_ports.html"><strong>task_set_exception_ports</strong></a>,
138*4f1223e8SApple OSS Distributions<a href="task_swap_exception_ports.html"><strong>task_swap_exception_ports</strong></a>,
139*4f1223e8SApple OSS Distributions<a href="thread_create.html"><strong>thread_create</strong></a>,
140*4f1223e8SApple OSS Distributions<a href="thread_get_exception_ports.html"><strong>thread_get_exception_ports</strong></a>,
141*4f1223e8SApple OSS Distributions<a href="TS_exception_ports.html"><strong>thread_swap_exception_ports</strong></a>,
142*4f1223e8SApple OSS Distributions<a href="catch_exception_raise.html"><strong>catch_exception_raise</strong></a>,
143*4f1223e8SApple OSS Distributions<a href="thread_abort.html"><strong>thread_abort</strong></a>.
144