OLD | NEW |
---|---|
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 //! search for other exception handlers. An exception handler should return the | 143 //! search for other exception handlers. An exception handler should return the |
144 //! value returned by this function. | 144 //! value returned by this function. |
145 //! | 145 //! |
146 //! This function is useful even for `EXC_CRASH` handlers, where returning | 146 //! This function is useful even for `EXC_CRASH` handlers, where returning |
147 //! `KERN_SUCCESS` and allowing the kernel to set a new thread state has been | 147 //! `KERN_SUCCESS` and allowing the kernel to set a new thread state has been |
148 //! observed to cause a perceptible and unnecessary waste of time. The victim | 148 //! observed to cause a perceptible and unnecessary waste of time. The victim |
149 //! task in an `EXC_CRASH` handler is already being terminated and is no longer | 149 //! task in an `EXC_CRASH` handler is already being terminated and is no longer |
150 //! schedulable, so there is no point in setting the states of any of its | 150 //! schedulable, so there is no point in setting the states of any of its |
151 //! threads. | 151 //! threads. |
152 //! | 152 //! |
153 //! On OS X 10.11, the `MACH_RCV_PORT_DIED` mechanism cannot be used with an | |
154 //! `EXC_CRASH` handler without triggering an undesirable `EXC_CORPSE_NOTIFY` | |
155 //! exception. In that case, `KERN_SUCCESS` is always returned. Because this | |
156 //! function may return `KERN_SUCCESS` for a state-carrying exception, it is | |
157 //! important to ensure that the state returned by a state-carrying exception | |
158 //! handler is valid, because it will be passed to `thread_set_status()`. | |
Robert Sesek
2015/09/04 17:29:49
Do you need the `` here since thread_set_status ha
Mark Mentovai
2015/09/04 18:26:01
Robert Sesek wrote:
| |
159 //! ExcServerCopyState() may be used to achieve this. | |
160 //! | |
161 //! \param[in] exception The exception type passed to the exception handler. | |
162 //! This may be taken directly from the \a exception parameter of | |
163 //! internal::SimplifiedExcServer::Interface::CatchException(), for example. | |
153 //! \param[in] behavior The behavior of the exception handler as invoked. This | 164 //! \param[in] behavior The behavior of the exception handler as invoked. This |
154 //! may be taken directly from the \a behavior parameter of | 165 //! may be taken directly from the \a behavior parameter of |
155 //! internal::SimplifiedExcServer::Interface::CatchException(), for example. | 166 //! internal::SimplifiedExcServer::Interface::CatchException(), for example. |
156 //! \param[in] set_thread_state `true` if the handler would like its caller to | 167 //! \param[in] set_thread_state `true` if the handler would like its caller to |
157 //! set the new thread state using the \a flavor, \a new_state, and \a | 168 //! set the new thread state using the \a flavor, \a new_state, and \a |
158 //! new_state_count out parameters. This can only happen when \a behavior is | 169 //! new_state_count out parameters. This can only happen when \a behavior is |
159 //! a state-carrying behavior. | 170 //! a state-carrying behavior. |
160 //! | 171 //! |
161 //! \return `KERN_SUCCESS` or `MACH_RCV_PORT_DIED`. `KERN_SUCCESS` is used when | 172 //! \return `KERN_SUCCESS` or `MACH_RCV_PORT_DIED`. `KERN_SUCCESS` is used when |
162 //! \a behavior is not a state-carrying behavior, or when it is a | 173 //! \a behavior is not a state-carrying behavior, or when it is a |
163 //! state-carrying behavior and \a set_thread_state is `true`. | 174 //! state-carrying behavior and \a set_thread_state is `true`, or for |
164 //! `MACH_RCV_PORT_DIED` is used when \a behavior is a state-carrying | 175 //! `EXC_CRASH` exceptions on OS X 10.11 and later. Otherwise, |
165 //! behavior and \a set_thread_state is `false`. | 176 //! `MACH_RCV_PORT_DIED` is used. |
166 kern_return_t ExcServerSuccessfulReturnValue(exception_behavior_t behavior, | 177 kern_return_t ExcServerSuccessfulReturnValue(exception_type_t exception, |
178 exception_behavior_t behavior, | |
167 bool set_thread_state); | 179 bool set_thread_state); |
168 | 180 |
169 //! \brief Copies the old state to the new state for state-carrying exceptions. | 181 //! \brief Copies the old state to the new state for state-carrying exceptions. |
170 //! | 182 //! |
171 //! When the kernel sends a state-carrying exception request and the response is | 183 //! When the kernel sends a state-carrying exception request and the response is |
172 //! successful (`MACH_MSG_SUCCESS`, a synonym for `KERN_SUCCESS`), it will set | 184 //! successful (`MACH_MSG_SUCCESS`, a synonym for `KERN_SUCCESS`), it will set |
173 //! a new thread state based on \a new_state and \a new_state_count. To ease | 185 //! a new thread state based on \a new_state and \a new_state_count. To ease |
174 //! initialization of the new state, this function copies \a old_state and | 186 //! initialization of the new state, this function copies \a old_state and |
175 //! \a old_state_count. This is only done if \a behavior indicates a | 187 //! \a old_state_count. This is only done if \a behavior indicates a |
176 //! state-carrying exception. | 188 //! state-carrying exception. |
(...skipping 22 matching lines...) Expand all Loading... | |
199 //! large as \a old_state_count. | 211 //! large as \a old_state_count. |
200 void ExcServerCopyState(exception_behavior_t behavior, | 212 void ExcServerCopyState(exception_behavior_t behavior, |
201 ConstThreadState old_state, | 213 ConstThreadState old_state, |
202 mach_msg_type_number_t old_state_count, | 214 mach_msg_type_number_t old_state_count, |
203 thread_state_t new_state, | 215 thread_state_t new_state, |
204 mach_msg_type_number_t* new_state_count); | 216 mach_msg_type_number_t* new_state_count); |
205 | 217 |
206 } // namespace crashpad | 218 } // namespace crashpad |
207 | 219 |
208 #endif // CRASHPAD_UTIL_MACH_EXC_SERVER_VARIANTS_H_ | 220 #endif // CRASHPAD_UTIL_MACH_EXC_SERVER_VARIANTS_H_ |
OLD | NEW |