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

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

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_server_variants.h ('k') | util/mach/exc_server_variants_test.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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 mach_msg_type_number_t code_count, 483 mach_msg_type_number_t code_count,
484 const mach_msg_trailer_t* trailer, 484 const mach_msg_trailer_t* trailer,
485 bool* destroy_request) { 485 bool* destroy_request) {
486 thread_state_flavor_t flavor = THREAD_STATE_NONE; 486 thread_state_flavor_t flavor = THREAD_STATE_NONE;
487 mach_msg_type_number_t new_state_count = 0; 487 mach_msg_type_number_t new_state_count = 0;
488 return interface_->CatchException(EXCEPTION_DEFAULT, 488 return interface_->CatchException(EXCEPTION_DEFAULT,
489 exception_port, 489 exception_port,
490 thread, 490 thread,
491 task, 491 task,
492 exception, 492 exception,
493 code, 493 code_count ? code : nullptr,
494 code_count, 494 code_count,
495 &flavor, 495 &flavor,
496 nullptr, 496 nullptr,
497 0, 497 0,
498 nullptr, 498 nullptr,
499 &new_state_count, 499 &new_state_count,
500 trailer, 500 trailer,
501 destroy_request); 501 destroy_request);
502 } 502 }
503 503
504 kern_return_t SimplifiedExcServer::CatchExceptionRaiseState( 504 kern_return_t SimplifiedExcServer::CatchExceptionRaiseState(
505 exception_handler_t exception_port, 505 exception_handler_t exception_port,
506 exception_type_t exception, 506 exception_type_t exception,
507 const exception_data_type_t* code, 507 const exception_data_type_t* code,
508 mach_msg_type_number_t code_count, 508 mach_msg_type_number_t code_count,
509 thread_state_flavor_t* flavor, 509 thread_state_flavor_t* flavor,
510 const natural_t* old_state, 510 const natural_t* old_state,
511 mach_msg_type_number_t old_state_count, 511 mach_msg_type_number_t old_state_count,
512 thread_state_t new_state, 512 thread_state_t new_state,
513 mach_msg_type_number_t* new_state_count, 513 mach_msg_type_number_t* new_state_count,
514 const mach_msg_trailer_t* trailer) { 514 const mach_msg_trailer_t* trailer) {
515 bool destroy_complex_request = false; 515 bool destroy_complex_request = false;
516 return interface_->CatchException(EXCEPTION_STATE, 516 return interface_->CatchException(EXCEPTION_STATE,
517 exception_port, 517 exception_port,
518 THREAD_NULL, 518 THREAD_NULL,
519 TASK_NULL, 519 TASK_NULL,
520 exception, 520 exception,
521 code, 521 code_count ? code : nullptr,
522 code_count, 522 code_count,
523 flavor, 523 flavor,
524 old_state, 524 old_state_count ? old_state : nullptr,
525 old_state_count, 525 old_state_count,
526 new_state, 526 new_state_count ? new_state : nullptr,
527 new_state_count, 527 new_state_count,
528 trailer, 528 trailer,
529 &destroy_complex_request); 529 &destroy_complex_request);
530 } 530 }
531 531
532 kern_return_t SimplifiedExcServer::CatchExceptionRaiseStateIdentity( 532 kern_return_t SimplifiedExcServer::CatchExceptionRaiseStateIdentity(
533 exception_handler_t exception_port, 533 exception_handler_t exception_port,
534 thread_t thread, 534 thread_t thread,
535 task_t task, 535 task_t task,
536 exception_type_t exception, 536 exception_type_t exception,
537 const exception_data_type_t* code, 537 const exception_data_type_t* code,
538 mach_msg_type_number_t code_count, 538 mach_msg_type_number_t code_count,
539 thread_state_flavor_t* flavor, 539 thread_state_flavor_t* flavor,
540 const natural_t* old_state, 540 const natural_t* old_state,
541 mach_msg_type_number_t old_state_count, 541 mach_msg_type_number_t old_state_count,
542 thread_state_t new_state, 542 thread_state_t new_state,
543 mach_msg_type_number_t* new_state_count, 543 mach_msg_type_number_t* new_state_count,
544 const mach_msg_trailer_t* trailer, 544 const mach_msg_trailer_t* trailer,
545 bool* destroy_request) { 545 bool* destroy_request) {
546 return interface_->CatchException(EXCEPTION_STATE_IDENTITY, 546 return interface_->CatchException(EXCEPTION_STATE_IDENTITY,
547 exception_port, 547 exception_port,
548 thread, 548 thread,
549 task, 549 task,
550 exception, 550 exception,
551 code, 551 code_count ? code : nullptr,
552 code_count, 552 code_count,
553 flavor, 553 flavor,
554 old_state, 554 old_state_count ? old_state : nullptr,
555 old_state_count, 555 old_state_count,
556 new_state, 556 new_state_count ? new_state : nullptr,
557 new_state_count, 557 new_state_count,
558 trailer, 558 trailer,
559 destroy_request); 559 destroy_request);
560 } 560 }
561 561
562 SimplifiedMachExcServer::SimplifiedMachExcServer( 562 SimplifiedMachExcServer::SimplifiedMachExcServer(
563 SimplifiedMachExcServer::Interface* interface) 563 SimplifiedMachExcServer::Interface* interface)
564 : MachExcServer(this), 564 : MachExcServer(this),
565 MachExcServer::Interface(), 565 MachExcServer::Interface(),
566 interface_(interface) { 566 interface_(interface) {
567 } 567 }
568 568
569 kern_return_t SimplifiedMachExcServer::CatchMachExceptionRaise( 569 kern_return_t SimplifiedMachExcServer::CatchMachExceptionRaise(
570 exception_handler_t exception_port, 570 exception_handler_t exception_port,
571 thread_t thread, 571 thread_t thread,
572 task_t task, 572 task_t task,
573 exception_type_t exception, 573 exception_type_t exception,
574 const mach_exception_data_type_t* code, 574 const mach_exception_data_type_t* code,
575 mach_msg_type_number_t code_count, 575 mach_msg_type_number_t code_count,
576 const mach_msg_trailer_t* trailer, 576 const mach_msg_trailer_t* trailer,
577 bool* destroy_request) { 577 bool* destroy_request) {
578 thread_state_flavor_t flavor = THREAD_STATE_NONE; 578 thread_state_flavor_t flavor = THREAD_STATE_NONE;
579 mach_msg_type_number_t new_state_count = 0; 579 mach_msg_type_number_t new_state_count = 0;
580 return interface_->CatchMachException( 580 return interface_->CatchMachException(
581 EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES, 581 EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES,
582 exception_port, 582 exception_port,
583 thread, 583 thread,
584 task, 584 task,
585 exception, 585 exception,
586 code, 586 code_count ? code : nullptr,
587 code_count, 587 code_count,
588 &flavor, 588 &flavor,
589 nullptr, 589 nullptr,
590 0, 590 0,
591 nullptr, 591 nullptr,
592 &new_state_count, 592 &new_state_count,
593 trailer, 593 trailer,
594 destroy_request); 594 destroy_request);
595 } 595 }
596 596
597 kern_return_t SimplifiedMachExcServer::CatchMachExceptionRaiseState( 597 kern_return_t SimplifiedMachExcServer::CatchMachExceptionRaiseState(
598 exception_handler_t exception_port, 598 exception_handler_t exception_port,
599 exception_type_t exception, 599 exception_type_t exception,
600 const mach_exception_data_type_t* code, 600 const mach_exception_data_type_t* code,
601 mach_msg_type_number_t code_count, 601 mach_msg_type_number_t code_count,
602 thread_state_flavor_t* flavor, 602 thread_state_flavor_t* flavor,
603 const natural_t* old_state, 603 const natural_t* old_state,
604 mach_msg_type_number_t old_state_count, 604 mach_msg_type_number_t old_state_count,
605 thread_state_t new_state, 605 thread_state_t new_state,
606 mach_msg_type_number_t* new_state_count, 606 mach_msg_type_number_t* new_state_count,
607 const mach_msg_trailer_t* trailer) { 607 const mach_msg_trailer_t* trailer) {
608 bool destroy_complex_request = false; 608 bool destroy_complex_request = false;
609 return interface_->CatchMachException(EXCEPTION_STATE | MACH_EXCEPTION_CODES, 609 return interface_->CatchMachException(EXCEPTION_STATE | MACH_EXCEPTION_CODES,
610 exception_port, 610 exception_port,
611 THREAD_NULL, 611 THREAD_NULL,
612 TASK_NULL, 612 TASK_NULL,
613 exception, 613 exception,
614 code, 614 code_count ? code : nullptr,
615 code_count, 615 code_count,
616 flavor, 616 flavor,
617 old_state, 617 old_state_count ? old_state : nullptr,
618 old_state_count, 618 old_state_count,
619 new_state, 619 new_state_count ? new_state : nullptr,
620 new_state_count, 620 new_state_count,
621 trailer, 621 trailer,
622 &destroy_complex_request); 622 &destroy_complex_request);
623 } 623 }
624 624
625 kern_return_t SimplifiedMachExcServer::CatchMachExceptionRaiseStateIdentity( 625 kern_return_t SimplifiedMachExcServer::CatchMachExceptionRaiseStateIdentity(
626 exception_handler_t exception_port, 626 exception_handler_t exception_port,
627 thread_t thread, 627 thread_t thread,
628 task_t task, 628 task_t task,
629 exception_type_t exception, 629 exception_type_t exception,
630 const mach_exception_data_type_t* code, 630 const mach_exception_data_type_t* code,
631 mach_msg_type_number_t code_count, 631 mach_msg_type_number_t code_count,
632 thread_state_flavor_t* flavor, 632 thread_state_flavor_t* flavor,
633 const natural_t* old_state, 633 const natural_t* old_state,
634 mach_msg_type_number_t old_state_count, 634 mach_msg_type_number_t old_state_count,
635 thread_state_t new_state, 635 thread_state_t new_state,
636 mach_msg_type_number_t* new_state_count, 636 mach_msg_type_number_t* new_state_count,
637 const mach_msg_trailer_t* trailer, 637 const mach_msg_trailer_t* trailer,
638 bool* destroy_request) { 638 bool* destroy_request) {
639 return interface_->CatchMachException( 639 return interface_->CatchMachException(
640 EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, 640 EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES,
641 exception_port, 641 exception_port,
642 thread, 642 thread,
643 task, 643 task,
644 exception, 644 exception,
645 code, 645 code_count ? code : nullptr,
646 code_count, 646 code_count,
647 flavor, 647 flavor,
648 old_state, 648 old_state_count ? old_state : nullptr,
649 old_state_count, 649 old_state_count,
650 new_state, 650 new_state_count ? new_state : nullptr,
651 new_state_count, 651 new_state_count,
652 trailer, 652 trailer,
653 destroy_request); 653 destroy_request);
654 } 654 }
655 655
656 } // namespace internal 656 } // namespace internal
657 657
658 UniversalMachExcServer::UniversalMachExcServer() 658 UniversalMachExcServer::UniversalMachExcServer(
659 UniversalMachExcServer::Interface* interface)
659 : MachMessageServer::Interface(), 660 : MachMessageServer::Interface(),
660 internal::SimplifiedExcServer::Interface(), 661 internal::SimplifiedExcServer::Interface(),
661 internal::SimplifiedMachExcServer::Interface(), 662 internal::SimplifiedMachExcServer::Interface(),
662 exc_server_(this), 663 exc_server_(this),
663 mach_exc_server_(this) { 664 mach_exc_server_(this),
665 interface_(interface) {
664 } 666 }
665 667
666 bool UniversalMachExcServer::MachMessageServerFunction( 668 bool UniversalMachExcServer::MachMessageServerFunction(
667 const mach_msg_header_t* in_header, 669 const mach_msg_header_t* in_header,
668 mach_msg_header_t* out_header, 670 mach_msg_header_t* out_header,
669 bool* destroy_complex_request) { 671 bool* destroy_complex_request) {
670 switch (in_header->msgh_id) { 672 switch (in_header->msgh_id) {
671 case kMachMessageIDMachExceptionRaise: 673 case kMachMessageIDMachExceptionRaise:
672 case kMachMessageIDMachExceptionRaiseState: 674 case kMachMessageIDMachExceptionRaiseState:
673 case kMachMessageIDMachExceptionRaiseStateIdentity: 675 case kMachMessageIDMachExceptionRaiseStateIdentity:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 thread_state_t new_state, 713 thread_state_t new_state,
712 mach_msg_type_number_t* new_state_count, 714 mach_msg_type_number_t* new_state_count,
713 const mach_msg_trailer_t* trailer, 715 const mach_msg_trailer_t* trailer,
714 bool* destroy_complex_request) { 716 bool* destroy_complex_request) {
715 std::vector<mach_exception_data_type_t> mach_codes; 717 std::vector<mach_exception_data_type_t> mach_codes;
716 mach_codes.reserve(code_count); 718 mach_codes.reserve(code_count);
717 for (size_t index = 0; index < code_count; ++index) { 719 for (size_t index = 0; index < code_count; ++index) {
718 mach_codes.push_back(code[index]); 720 mach_codes.push_back(code[index]);
719 } 721 }
720 722
721 return CatchMachException(behavior, 723 return interface_->CatchMachException(behavior,
722 exception_port, 724 exception_port,
723 thread, 725 thread,
724 task, 726 task,
725 exception, 727 exception,
726 code_count ? &mach_codes[0] : nullptr, 728 code_count ? &mach_codes[0] : nullptr,
727 code_count, 729 code_count,
728 flavor, 730 flavor,
729 old_state, 731 old_state_count ? old_state : nullptr,
730 old_state_count, 732 old_state_count,
731 new_state, 733 new_state_count ? new_state : nullptr,
732 new_state_count, 734 new_state_count,
733 trailer, 735 trailer,
734 destroy_complex_request); 736 destroy_complex_request);
737 }
738
739 kern_return_t UniversalMachExcServer::CatchMachException(
740 exception_behavior_t behavior,
741 exception_handler_t exception_port,
742 thread_t thread,
743 task_t task,
744 exception_type_t exception,
745 const mach_exception_data_type_t* code,
746 mach_msg_type_number_t code_count,
747 thread_state_flavor_t* flavor,
748 const natural_t* old_state,
749 mach_msg_type_number_t old_state_count,
750 thread_state_t new_state,
751 mach_msg_type_number_t* new_state_count,
752 const mach_msg_trailer_t* trailer,
753 bool* destroy_complex_request) {
754 return interface_->CatchMachException(behavior,
755 exception_port,
756 thread,
757 task,
758 exception,
759 code_count ? code : nullptr,
760 code_count,
761 flavor,
762 old_state_count ? old_state : nullptr,
763 old_state_count,
764 new_state_count ? new_state : nullptr,
765 new_state_count,
766 trailer,
767 destroy_complex_request);
735 } 768 }
736 769
737 exception_type_t ExcCrashRecoverOriginalException( 770 exception_type_t ExcCrashRecoverOriginalException(
738 mach_exception_code_t code_0, 771 mach_exception_code_t code_0,
739 mach_exception_code_t* original_code_0, 772 mach_exception_code_t* original_code_0,
740 int* signal) { 773 int* signal) {
741 // 10.9.4 xnu-2422.110.17/bsd/kern/kern_exit.c proc_prepareexit() sets code[0] 774 // 10.9.4 xnu-2422.110.17/bsd/kern/kern_exit.c proc_prepareexit() sets code[0]
742 // based on the signal value, original exception type, and low 20 bits of the 775 // based on the signal value, original exception type, and low 20 bits of the
743 // original code[0] before calling xnu-2422.110.17/osfmk/kern/exception.c 776 // original code[0] before calling xnu-2422.110.17/osfmk/kern/exception.c
744 // task_exception_notify() to raise an EXC_CRASH. 777 // task_exception_notify() to raise an EXC_CRASH.
(...skipping 19 matching lines...) Expand all
764 kern_return_t ExcServerSuccessfulReturnValue(exception_behavior_t behavior, 797 kern_return_t ExcServerSuccessfulReturnValue(exception_behavior_t behavior,
765 bool set_thread_state) { 798 bool set_thread_state) {
766 if (!set_thread_state && ExceptionBehaviorHasState(behavior)) { 799 if (!set_thread_state && ExceptionBehaviorHasState(behavior)) {
767 return MACH_RCV_PORT_DIED; 800 return MACH_RCV_PORT_DIED;
768 } 801 }
769 802
770 return KERN_SUCCESS; 803 return KERN_SUCCESS;
771 } 804 }
772 805
773 } // namespace crashpad 806 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/mach/exc_server_variants.h ('k') | util/mach/exc_server_variants_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698