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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 bool* destroy_request) = 0; | 96 bool* destroy_request) = 0; |
97 | 97 |
98 protected: | 98 protected: |
99 ~Interface() {} | 99 ~Interface() {} |
100 }; | 100 }; |
101 | 101 |
102 explicit ExcServer(Interface* interface); | 102 explicit ExcServer(Interface* interface); |
103 | 103 |
104 // MachMessageServer::Interface: | 104 // MachMessageServer::Interface: |
105 | 105 |
106 virtual bool MachMessageServerFunction( | 106 bool MachMessageServerFunction(const mach_msg_header_t* in_header, |
107 const mach_msg_header_t* in_header, | 107 mach_msg_header_t* out_header, |
108 mach_msg_header_t* out_header, | 108 bool* destroy_complex_request) override; |
109 bool* destroy_complex_request) override; | |
110 | 109 |
111 virtual mach_msg_size_t MachMessageServerRequestSize() override; | 110 mach_msg_size_t MachMessageServerRequestSize() override; |
112 virtual mach_msg_size_t MachMessageServerReplySize() override; | 111 mach_msg_size_t MachMessageServerReplySize() override; |
113 | 112 |
114 private: | 113 private: |
115 Interface* interface_; // weak | 114 Interface* interface_; // weak |
116 }; | 115 }; |
117 | 116 |
118 //! \brief A server interface for the `mach_exc` Mach subsystem. | 117 //! \brief A server interface for the `mach_exc` Mach subsystem. |
119 class MachExcServer : public MachMessageServer::Interface { | 118 class MachExcServer : public MachMessageServer::Interface { |
120 public: | 119 public: |
121 //! \brief An interface that the different request messages that are a part of | 120 //! \brief An interface that the different request messages that are a part of |
122 //! the `mach_exc` Mach subsystem can be dispatched to. | 121 //! the `mach_exc` Mach subsystem can be dispatched to. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 bool* destroy_request) = 0; | 183 bool* destroy_request) = 0; |
185 | 184 |
186 protected: | 185 protected: |
187 ~Interface() {} | 186 ~Interface() {} |
188 }; | 187 }; |
189 | 188 |
190 explicit MachExcServer(Interface* interface); | 189 explicit MachExcServer(Interface* interface); |
191 | 190 |
192 // MachMessageServer::Interface: | 191 // MachMessageServer::Interface: |
193 | 192 |
194 virtual bool MachMessageServerFunction( | 193 bool MachMessageServerFunction(const mach_msg_header_t* in_header, |
195 const mach_msg_header_t* in_header, | 194 mach_msg_header_t* out_header, |
196 mach_msg_header_t* out_header, | 195 bool* destroy_complex_request) override; |
197 bool* destroy_complex_request) override; | |
198 | 196 |
199 virtual mach_msg_size_t MachMessageServerRequestSize() override; | 197 mach_msg_size_t MachMessageServerRequestSize() override; |
200 virtual mach_msg_size_t MachMessageServerReplySize() override; | 198 mach_msg_size_t MachMessageServerReplySize() override; |
201 | 199 |
202 private: | 200 private: |
203 Interface* interface_; // weak | 201 Interface* interface_; // weak |
204 }; | 202 }; |
205 | 203 |
206 //! \brief A server interface for the `exc` Mach subsystem, simplified to have | 204 //! \brief A server interface for the `exc` Mach subsystem, simplified to have |
207 //! only a single interface method needing implementation. | 205 //! only a single interface method needing implementation. |
208 class SimplifiedExcServer : public ExcServer, public ExcServer::Interface { | 206 class SimplifiedExcServer : public ExcServer, public ExcServer::Interface { |
209 public: | 207 public: |
210 //! \brief An interface that the different request messages that are a part of | 208 //! \brief An interface that the different request messages that are a part of |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 bool* destroy_complex_request) = 0; | 240 bool* destroy_complex_request) = 0; |
243 | 241 |
244 protected: | 242 protected: |
245 ~Interface() {} | 243 ~Interface() {} |
246 }; | 244 }; |
247 | 245 |
248 explicit SimplifiedExcServer(Interface* interface); | 246 explicit SimplifiedExcServer(Interface* interface); |
249 | 247 |
250 // ExcServer::Interface: | 248 // ExcServer::Interface: |
251 | 249 |
252 virtual kern_return_t CatchExceptionRaise(exception_handler_t exception_port, | 250 kern_return_t CatchExceptionRaise(exception_handler_t exception_port, |
253 thread_t thread, | 251 thread_t thread, |
254 task_t task, | 252 task_t task, |
255 exception_type_t exception, | 253 exception_type_t exception, |
256 const exception_data_type_t* code, | 254 const exception_data_type_t* code, |
257 mach_msg_type_number_t code_count, | 255 mach_msg_type_number_t code_count, |
258 bool* destroy_request) override; | 256 bool* destroy_request) override; |
259 virtual kern_return_t CatchExceptionRaiseState( | 257 kern_return_t CatchExceptionRaiseState( |
260 exception_handler_t exception_port, | 258 exception_handler_t exception_port, |
261 exception_type_t exception, | 259 exception_type_t exception, |
262 const exception_data_type_t* code, | 260 const exception_data_type_t* code, |
263 mach_msg_type_number_t code_count, | 261 mach_msg_type_number_t code_count, |
264 thread_state_flavor_t* flavor, | 262 thread_state_flavor_t* flavor, |
265 const natural_t* old_state, | 263 const natural_t* old_state, |
266 mach_msg_type_number_t old_state_count, | 264 mach_msg_type_number_t old_state_count, |
267 thread_state_t new_state, | 265 thread_state_t new_state, |
268 mach_msg_type_number_t* new_state_count) override; | 266 mach_msg_type_number_t* new_state_count) override; |
269 virtual kern_return_t CatchExceptionRaiseStateIdentity( | 267 kern_return_t CatchExceptionRaiseStateIdentity( |
270 exception_handler_t exception_port, | 268 exception_handler_t exception_port, |
271 thread_t thread, | 269 thread_t thread, |
272 task_t task, | 270 task_t task, |
273 exception_type_t exception, | 271 exception_type_t exception, |
274 const exception_data_type_t* code, | 272 const exception_data_type_t* code, |
275 mach_msg_type_number_t code_count, | 273 mach_msg_type_number_t code_count, |
276 thread_state_flavor_t* flavor, | 274 thread_state_flavor_t* flavor, |
277 const natural_t* old_state, | 275 const natural_t* old_state, |
278 mach_msg_type_number_t old_state_count, | 276 mach_msg_type_number_t old_state_count, |
279 thread_state_t new_state, | 277 thread_state_t new_state, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 bool* destroy_complex_request) = 0; | 331 bool* destroy_complex_request) = 0; |
334 | 332 |
335 protected: | 333 protected: |
336 ~Interface() {} | 334 ~Interface() {} |
337 }; | 335 }; |
338 | 336 |
339 explicit SimplifiedMachExcServer(Interface* interface); | 337 explicit SimplifiedMachExcServer(Interface* interface); |
340 | 338 |
341 // MachExcServer::Interface: | 339 // MachExcServer::Interface: |
342 | 340 |
343 virtual kern_return_t CatchMachExceptionRaise( | 341 kern_return_t CatchMachExceptionRaise(exception_handler_t exception_port, |
344 exception_handler_t exception_port, | 342 thread_t thread, |
345 thread_t thread, | 343 task_t task, |
346 task_t task, | 344 exception_type_t exception, |
347 exception_type_t exception, | 345 const mach_exception_data_type_t* code, |
348 const mach_exception_data_type_t* code, | 346 mach_msg_type_number_t code_count, |
349 mach_msg_type_number_t code_count, | 347 bool* destroy_request) override; |
350 bool* destroy_request) override; | 348 kern_return_t CatchMachExceptionRaiseState( |
351 virtual kern_return_t CatchMachExceptionRaiseState( | |
352 exception_handler_t exception_port, | 349 exception_handler_t exception_port, |
353 exception_type_t exception, | 350 exception_type_t exception, |
354 const mach_exception_data_type_t* code, | 351 const mach_exception_data_type_t* code, |
355 mach_msg_type_number_t code_count, | 352 mach_msg_type_number_t code_count, |
356 thread_state_flavor_t* flavor, | 353 thread_state_flavor_t* flavor, |
357 const natural_t* old_state, | 354 const natural_t* old_state, |
358 mach_msg_type_number_t old_state_count, | 355 mach_msg_type_number_t old_state_count, |
359 thread_state_t new_state, | 356 thread_state_t new_state, |
360 mach_msg_type_number_t* new_state_count) override; | 357 mach_msg_type_number_t* new_state_count) override; |
361 virtual kern_return_t CatchMachExceptionRaiseStateIdentity( | 358 kern_return_t CatchMachExceptionRaiseStateIdentity( |
362 exception_handler_t exception_port, | 359 exception_handler_t exception_port, |
363 thread_t thread, | 360 thread_t thread, |
364 task_t task, | 361 task_t task, |
365 exception_type_t exception, | 362 exception_type_t exception, |
366 const mach_exception_data_type_t* code, | 363 const mach_exception_data_type_t* code, |
367 mach_msg_type_number_t code_count, | 364 mach_msg_type_number_t code_count, |
368 thread_state_flavor_t* flavor, | 365 thread_state_flavor_t* flavor, |
369 const natural_t* old_state, | 366 const natural_t* old_state, |
370 mach_msg_type_number_t old_state_count, | 367 mach_msg_type_number_t old_state_count, |
371 thread_state_t new_state, | 368 thread_state_t new_state, |
(...skipping 21 matching lines...) Expand all Loading... |
393 //! implementations. | 390 //! implementations. |
394 class UniversalMachExcServer | 391 class UniversalMachExcServer |
395 : public MachMessageServer::Interface, | 392 : public MachMessageServer::Interface, |
396 public internal::SimplifiedExcServer::Interface, | 393 public internal::SimplifiedExcServer::Interface, |
397 public internal::SimplifiedMachExcServer::Interface { | 394 public internal::SimplifiedMachExcServer::Interface { |
398 public: | 395 public: |
399 UniversalMachExcServer(); | 396 UniversalMachExcServer(); |
400 | 397 |
401 // MachMessageServer::Interface: | 398 // MachMessageServer::Interface: |
402 | 399 |
403 virtual bool MachMessageServerFunction( | 400 bool MachMessageServerFunction(const mach_msg_header_t* in_header, |
404 const mach_msg_header_t* in_header, | 401 mach_msg_header_t* out_header, |
405 mach_msg_header_t* out_header, | 402 bool* destroy_complex_request) override; |
406 bool* destroy_complex_request) override; | |
407 | 403 |
408 virtual mach_msg_size_t MachMessageServerRequestSize() override; | 404 mach_msg_size_t MachMessageServerRequestSize() override; |
409 virtual mach_msg_size_t MachMessageServerReplySize() override; | 405 mach_msg_size_t MachMessageServerReplySize() override; |
410 | 406 |
411 // internal::SimplifiedExcServer::Interface: | 407 // internal::SimplifiedExcServer::Interface: |
412 | 408 |
413 virtual kern_return_t CatchException(exception_behavior_t behavior, | 409 kern_return_t CatchException(exception_behavior_t behavior, |
414 exception_handler_t exception_port, | 410 exception_handler_t exception_port, |
415 thread_t thread, | 411 thread_t thread, |
416 task_t task, | 412 task_t task, |
417 exception_type_t exception, | 413 exception_type_t exception, |
418 const exception_data_type_t* code, | 414 const exception_data_type_t* code, |
419 mach_msg_type_number_t code_count, | 415 mach_msg_type_number_t code_count, |
420 thread_state_flavor_t* flavor, | 416 thread_state_flavor_t* flavor, |
421 const natural_t* old_state, | 417 const natural_t* old_state, |
422 mach_msg_type_number_t old_state_count, | 418 mach_msg_type_number_t old_state_count, |
423 thread_state_t new_state, | 419 thread_state_t new_state, |
424 mach_msg_type_number_t* new_state_count, | 420 mach_msg_type_number_t* new_state_count, |
425 bool* destroy_complex_request) override; | 421 bool* destroy_complex_request) override; |
426 | 422 |
427 private: | 423 private: |
428 internal::SimplifiedExcServer exc_server_; | 424 internal::SimplifiedExcServer exc_server_; |
429 internal::SimplifiedMachExcServer mach_exc_server_; | 425 internal::SimplifiedMachExcServer mach_exc_server_; |
430 }; | 426 }; |
431 | 427 |
432 //! \brief Recovers the original exception, first exception code, and signal | 428 //! \brief Recovers the original exception, first exception code, and signal |
433 //! from the encoded form of the first exception code delivered with | 429 //! from the encoded form of the first exception code delivered with |
434 //! `EXC_CRASH` exceptions. | 430 //! `EXC_CRASH` exceptions. |
435 //! | 431 //! |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 //! \a behavior is not a state-carrying behavior, or when it is a | 505 //! \a behavior is not a state-carrying behavior, or when it is a |
510 //! state-carrying behavior and \a set_thread_state is `true`. | 506 //! state-carrying behavior and \a set_thread_state is `true`. |
511 //! `MACH_RCV_PORT_DIED` is used when \a behavior is a state-carrying | 507 //! `MACH_RCV_PORT_DIED` is used when \a behavior is a state-carrying |
512 //! behavior and \a set_thread_state is `false`. | 508 //! behavior and \a set_thread_state is `false`. |
513 kern_return_t ExcServerSuccessfulReturnValue(exception_behavior_t behavior, | 509 kern_return_t ExcServerSuccessfulReturnValue(exception_behavior_t behavior, |
514 bool set_thread_state); | 510 bool set_thread_state); |
515 | 511 |
516 } // namespace crashpad | 512 } // namespace crashpad |
517 | 513 |
518 #endif // CRASHPAD_UTIL_MACH_EXC_SERVER_VARIANTS_H_ | 514 #endif // CRASHPAD_UTIL_MACH_EXC_SERVER_VARIANTS_H_ |
OLD | NEW |