Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: util/mach/exc_server_variants.h

Issue 775943005: UniversalMachExcServer: eliminate multiple implementation inheritance (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « util/mach/exc_client_variants_test.cc ('k') | util/mach/exc_server_variants.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 public MachExcServer::Interface { 322 public MachExcServer::Interface {
323 public: 323 public:
324 //! \brief An interface that the different request messages that are a part of 324 //! \brief An interface that the different request messages that are a part of
325 //! the `mach_exc` Mach subsystem can be dispatched to. 325 //! the `mach_exc` Mach subsystem can be dispatched to.
326 class Interface { 326 class Interface {
327 public: 327 public:
328 //! \brief Handles exceptions raised by `mach_exception_raise()`, 328 //! \brief Handles exceptions raised by `mach_exception_raise()`,
329 //! `mach_exception_raise_state()`, and 329 //! `mach_exception_raise_state()`, and
330 //! `mach_exception_raise_state_identity()`. 330 //! `mach_exception_raise_state_identity()`.
331 //! 331 //!
332 //! When used with UniversalMachExcServer, this also handles exceptions
333 //! raised by `exception_raise()`, `exception_raise_state()`, and
334 //! `exception_raise_state_identity()`.
335 //!
336 //! For convenience in implementation, these different “behaviors” of 332 //! For convenience in implementation, these different “behaviors” of
337 //! exception messages are all mapped to a single interface method. The 333 //! exception messages are all mapped to a single interface method. The
338 //! exception’s original “behavior” is specified in the \a behavior 334 //! exception’s original “behavior” is specified in the \a behavior
339 //! parameter. Only parameters that were supplied in the request message 335 //! parameter. Only parameters that were supplied in the request message
340 //! are populated, other parameters are set to reasonable default values. 336 //! are populated, other parameters are set to reasonable default values.
341 //! 337 //!
342 //! The meanings of most parameters are identical to that of 338 //! The meanings of most parameters are identical to that of
343 //! MachExcServer::Interface::CatchMachExceptionRaiseStateIdentity(). 339 //! MachExcServer::Interface::CatchMachExceptionRaiseStateIdentity().
344 //! 340 //!
345 //! \param[in] behavior `MACH_EXCEPTION_CODES | EXCEPTION_DEFAULT`, 341 //! \param[in] behavior `MACH_EXCEPTION_CODES | EXCEPTION_DEFAULT`,
346 //! `MACH_EXCEPTION_CODES | EXCEPTION_STATE`, or 342 //! `MACH_EXCEPTION_CODES | EXCEPTION_STATE`, or
347 //! `MACH_EXCEPTION_CODES | EXCEPTION_STATE_IDENTITY`, identifying which 343 //! `MACH_EXCEPTION_CODES | EXCEPTION_STATE_IDENTITY`, identifying which
348 //! exception request message was processed and thus which other 344 //! exception request message was processed and thus which other
349 //! parameters are valid. When used with UniversalMachExcServer, \a 345 //! parameters are valid.
350 //! behavior can also be `EXCEPTION_DEFAULT`, `EXCEPTION_STATE`, or
351 //! `EXCEPTION_STATE_IDENTITY`.
352 virtual kern_return_t CatchMachException( 346 virtual kern_return_t CatchMachException(
353 exception_behavior_t behavior, 347 exception_behavior_t behavior,
354 exception_handler_t exception_port, 348 exception_handler_t exception_port,
355 thread_t thread, 349 thread_t thread,
356 task_t task, 350 task_t task,
357 exception_type_t exception, 351 exception_type_t exception,
358 const mach_exception_data_type_t* code, 352 const mach_exception_data_type_t* code,
359 mach_msg_type_number_t code_count, 353 mach_msg_type_number_t code_count,
360 thread_state_flavor_t* flavor, 354 thread_state_flavor_t* flavor,
361 const natural_t* old_state, 355 const natural_t* old_state,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 //! field, from `exception_data_type_t` to `mach_exception_data_type_t`. 423 //! field, from `exception_data_type_t` to `mach_exception_data_type_t`.
430 //! This is achieved by implementing SimplifiedExcServer::Interface and having 424 //! This is achieved by implementing SimplifiedExcServer::Interface and having
431 //! it forward translated messages to SimplifiedMachExcServer::Interface, which 425 //! it forward translated messages to SimplifiedMachExcServer::Interface, which
432 //! is left unimplemented here so that users of this class can provide their own 426 //! is left unimplemented here so that users of this class can provide their own
433 //! implementations. 427 //! implementations.
434 class UniversalMachExcServer 428 class UniversalMachExcServer
435 : public MachMessageServer::Interface, 429 : public MachMessageServer::Interface,
436 public internal::SimplifiedExcServer::Interface, 430 public internal::SimplifiedExcServer::Interface,
437 public internal::SimplifiedMachExcServer::Interface { 431 public internal::SimplifiedMachExcServer::Interface {
438 public: 432 public:
433 //! \brief An interface that the different request messages that are a part of
434 //! the `exc` and `mach_exc` Mach subsystems can be dispatched to.
435 class Interface {
436 public:
437 //! \brief Handles exceptions raised by `exception_raise()`,
438 //! `exception_raise_state()`, `exception_raise_state_identity()`,
439 //! `mach_exception_raise()`, `mach_exception_raise_state()`, and
440 //! `mach_exception_raise_state_identity()`.
441 //!
442 //! For convenience in implementation, these different “behaviors” of
443 //! exception messages are all mapped to a single interface method. The
444 //! exception’s original “behavior” is specified in the \a behavior
445 //! parameter. Only parameters that were supplied in the request message
446 //! are populated, other parameters are set to reasonable default values.
447 //!
448 //! The meanings of most parameters are identical to that of
449 //! MachExcServer::Interface::CatchMachExceptionRaiseStateIdentity().
450 //!
451 //! \param[in] behavior `EXCEPTION_DEFAULT`, `EXCEPTION_STATE`,
452 //! or `EXCEPTION_STATE_IDENTITY`, possibly with `MACH_EXCEPTION_CODES`
453 //! ORed in. This identifies which exception request message was
454 //! processed and thus which other parameters are valid.
455 virtual kern_return_t CatchMachException(
456 exception_behavior_t behavior,
457 exception_handler_t exception_port,
458 thread_t thread,
459 task_t task,
460 exception_type_t exception,
461 const mach_exception_data_type_t* code,
462 mach_msg_type_number_t code_count,
463 thread_state_flavor_t* flavor,
464 const natural_t* old_state,
465 mach_msg_type_number_t old_state_count,
466 thread_state_t new_state,
467 mach_msg_type_number_t* new_state_count,
468 const mach_msg_trailer_t* trailer,
469 bool* destroy_complex_request) = 0;
470
471 protected:
472 ~Interface() {}
473 };
474
439 //! \brief Constructs an object of this class. 475 //! \brief Constructs an object of this class.
440 UniversalMachExcServer(); 476 //!
477 //! \param[in] interface The interface to dispatch requests to. Weak.
478 explicit UniversalMachExcServer(Interface* interface);
441 479
442 // MachMessageServer::Interface: 480 // MachMessageServer::Interface:
443 481
444 bool MachMessageServerFunction(const mach_msg_header_t* in_header, 482 bool MachMessageServerFunction(const mach_msg_header_t* in_header,
445 mach_msg_header_t* out_header, 483 mach_msg_header_t* out_header,
446 bool* destroy_complex_request) override; 484 bool* destroy_complex_request) override;
447 485
448 mach_msg_size_t MachMessageServerRequestSize() override; 486 mach_msg_size_t MachMessageServerRequestSize() override;
449 mach_msg_size_t MachMessageServerReplySize() override; 487 mach_msg_size_t MachMessageServerReplySize() override;
450 488
451 // internal::SimplifiedExcServer::Interface: 489 // internal::SimplifiedExcServer::Interface:
452 490
453 kern_return_t CatchException(exception_behavior_t behavior, 491 kern_return_t CatchException(exception_behavior_t behavior,
454 exception_handler_t exception_port, 492 exception_handler_t exception_port,
455 thread_t thread, 493 thread_t thread,
456 task_t task, 494 task_t task,
457 exception_type_t exception, 495 exception_type_t exception,
458 const exception_data_type_t* code, 496 const exception_data_type_t* code,
459 mach_msg_type_number_t code_count, 497 mach_msg_type_number_t code_count,
460 thread_state_flavor_t* flavor, 498 thread_state_flavor_t* flavor,
461 const natural_t* old_state, 499 const natural_t* old_state,
462 mach_msg_type_number_t old_state_count, 500 mach_msg_type_number_t old_state_count,
463 thread_state_t new_state, 501 thread_state_t new_state,
464 mach_msg_type_number_t* new_state_count, 502 mach_msg_type_number_t* new_state_count,
465 const mach_msg_trailer_t* trailer, 503 const mach_msg_trailer_t* trailer,
466 bool* destroy_complex_request) override; 504 bool* destroy_complex_request) override;
467 505
506 // internal::SimplifiedMachExcServer::Interface:
507
508 kern_return_t CatchMachException(exception_behavior_t behavior,
509 exception_handler_t exception_port,
510 thread_t thread,
511 task_t task,
512 exception_type_t exception,
513 const mach_exception_data_type_t* code,
514 mach_msg_type_number_t code_count,
515 thread_state_flavor_t* flavor,
516 const natural_t* old_state,
517 mach_msg_type_number_t old_state_count,
518 thread_state_t new_state,
519 mach_msg_type_number_t* new_state_count,
520 const mach_msg_trailer_t* trailer,
521 bool* destroy_complex_request) override;
522
468 private: 523 private:
469 internal::SimplifiedExcServer exc_server_; 524 internal::SimplifiedExcServer exc_server_;
470 internal::SimplifiedMachExcServer mach_exc_server_; 525 internal::SimplifiedMachExcServer mach_exc_server_;
526 Interface* interface_; // weak
471 527
472 DISALLOW_COPY_AND_ASSIGN(UniversalMachExcServer); 528 DISALLOW_COPY_AND_ASSIGN(UniversalMachExcServer);
473 }; 529 };
474 530
475 //! \brief Recovers the original exception, first exception code, and signal 531 //! \brief Recovers the original exception, first exception code, and signal
476 //! from the encoded form of the first exception code delivered with 532 //! from the encoded form of the first exception code delivered with
477 //! `EXC_CRASH` exceptions. 533 //! `EXC_CRASH` exceptions.
478 //! 534 //!
479 //! `EXC_CRASH` exceptions are generated when the kernel has committed to 535 //! `EXC_CRASH` exceptions are generated when the kernel has committed to
480 //! terminating a process as a result of a core-generating POSIX signal and, for 536 //! terminating a process as a result of a core-generating POSIX signal and, for
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 //! \a behavior is not a state-carrying behavior, or when it is a 608 //! \a behavior is not a state-carrying behavior, or when it is a
553 //! state-carrying behavior and \a set_thread_state is `true`. 609 //! state-carrying behavior and \a set_thread_state is `true`.
554 //! `MACH_RCV_PORT_DIED` is used when \a behavior is a state-carrying 610 //! `MACH_RCV_PORT_DIED` is used when \a behavior is a state-carrying
555 //! behavior and \a set_thread_state is `false`. 611 //! behavior and \a set_thread_state is `false`.
556 kern_return_t ExcServerSuccessfulReturnValue(exception_behavior_t behavior, 612 kern_return_t ExcServerSuccessfulReturnValue(exception_behavior_t behavior,
557 bool set_thread_state); 613 bool set_thread_state);
558 614
559 } // namespace crashpad 615 } // namespace crashpad
560 616
561 #endif // CRASHPAD_UTIL_MACH_EXC_SERVER_VARIANTS_H_ 617 #endif // CRASHPAD_UTIL_MACH_EXC_SERVER_VARIANTS_H_
OLDNEW
« no previous file with comments | « util/mach/exc_client_variants_test.cc ('k') | util/mach/exc_server_variants.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698