| 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 //! request message is not complex (it does not carry the \a thread or \a | 269 //! request message is not complex (it does not carry the \a thread or \a |
| 270 //! task port rights) and thus there is nothing to destroy. | 270 //! task port rights) and thus there is nothing to destroy. |
| 271 //! | 271 //! |
| 272 //! \param[in] trailer The trailer received with the request message. | 272 //! \param[in] trailer The trailer received with the request message. |
| 273 virtual kern_return_t CatchExceptionRaiseState( | 273 virtual kern_return_t CatchExceptionRaiseState( |
| 274 exception_handler_t exception_port, | 274 exception_handler_t exception_port, |
| 275 exception_type_t exception, | 275 exception_type_t exception, |
| 276 const typename Traits::ExceptionCode* code, | 276 const typename Traits::ExceptionCode* code, |
| 277 mach_msg_type_number_t code_count, | 277 mach_msg_type_number_t code_count, |
| 278 thread_state_flavor_t* flavor, | 278 thread_state_flavor_t* flavor, |
| 279 const natural_t* old_state, | 279 ConstThreadState old_state, |
| 280 mach_msg_type_number_t old_state_count, | 280 mach_msg_type_number_t old_state_count, |
| 281 thread_state_t new_state, | 281 thread_state_t new_state, |
| 282 mach_msg_type_number_t* new_state_count, | 282 mach_msg_type_number_t* new_state_count, |
| 283 const mach_msg_trailer_t* trailer) = 0; | 283 const mach_msg_trailer_t* trailer) = 0; |
| 284 | 284 |
| 285 //! \brief Handles exceptions raised by `exception_raise_state_identity()` | 285 //! \brief Handles exceptions raised by `exception_raise_state_identity()` |
| 286 //! or `mach_exception_raise_state_identity()`. | 286 //! or `mach_exception_raise_state_identity()`. |
| 287 //! | 287 //! |
| 288 //! This behaves equivalently to a `catch_exception_raise_state_identity()` | 288 //! This behaves equivalently to a `catch_exception_raise_state_identity()` |
| 289 //! function used with `exc_server()`, or a | 289 //! function used with `exc_server()`, or a |
| 290 //! `catch_mach_exception_raise_state_identity()` function used with | 290 //! `catch_mach_exception_raise_state_identity()` function used with |
| 291 //! `mach_exc_server()`. | 291 //! `mach_exc_server()`. |
| 292 //! | 292 //! |
| 293 //! \param[in] trailer The trailer received with the request message. | 293 //! \param[in] trailer The trailer received with the request message. |
| 294 //! \param[out] destroy_request `true` if the request message is to be | 294 //! \param[out] destroy_request `true` if the request message is to be |
| 295 //! destroyed even when this method returns success. See | 295 //! destroyed even when this method returns success. See |
| 296 //! MachMessageServer::Interface. | 296 //! MachMessageServer::Interface. |
| 297 virtual kern_return_t CatchExceptionRaiseStateIdentity( | 297 virtual kern_return_t CatchExceptionRaiseStateIdentity( |
| 298 exception_handler_t exception_port, | 298 exception_handler_t exception_port, |
| 299 thread_t thread, | 299 thread_t thread, |
| 300 task_t task, | 300 task_t task, |
| 301 exception_type_t exception, | 301 exception_type_t exception, |
| 302 const typename Traits::ExceptionCode* code, | 302 const typename Traits::ExceptionCode* code, |
| 303 mach_msg_type_number_t code_count, | 303 mach_msg_type_number_t code_count, |
| 304 thread_state_flavor_t* flavor, | 304 thread_state_flavor_t* flavor, |
| 305 const natural_t* old_state, | 305 ConstThreadState old_state, |
| 306 mach_msg_type_number_t old_state_count, | 306 mach_msg_type_number_t old_state_count, |
| 307 thread_state_t new_state, | 307 thread_state_t new_state, |
| 308 mach_msg_type_number_t* new_state_count, | 308 mach_msg_type_number_t* new_state_count, |
| 309 const mach_msg_trailer_t* trailer, | 309 const mach_msg_trailer_t* trailer, |
| 310 bool* destroy_request) = 0; | 310 bool* destroy_request) = 0; |
| 311 | 311 |
| 312 protected: | 312 protected: |
| 313 ~Interface() {} | 313 ~Interface() {} |
| 314 }; | 314 }; |
| 315 | 315 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 //! be ORed in to this parameter. | 516 //! be ORed in to this parameter. |
| 517 virtual kern_return_t CatchException( | 517 virtual kern_return_t CatchException( |
| 518 exception_behavior_t behavior, | 518 exception_behavior_t behavior, |
| 519 exception_handler_t exception_port, | 519 exception_handler_t exception_port, |
| 520 thread_t thread, | 520 thread_t thread, |
| 521 task_t task, | 521 task_t task, |
| 522 exception_type_t exception, | 522 exception_type_t exception, |
| 523 const typename Traits::ExceptionCode* code, | 523 const typename Traits::ExceptionCode* code, |
| 524 mach_msg_type_number_t code_count, | 524 mach_msg_type_number_t code_count, |
| 525 thread_state_flavor_t* flavor, | 525 thread_state_flavor_t* flavor, |
| 526 const natural_t* old_state, | 526 ConstThreadState old_state, |
| 527 mach_msg_type_number_t old_state_count, | 527 mach_msg_type_number_t old_state_count, |
| 528 thread_state_t new_state, | 528 thread_state_t new_state, |
| 529 mach_msg_type_number_t* new_state_count, | 529 mach_msg_type_number_t* new_state_count, |
| 530 const mach_msg_trailer_t* trailer, | 530 const mach_msg_trailer_t* trailer, |
| 531 bool* destroy_complex_request) = 0; | 531 bool* destroy_complex_request) = 0; |
| 532 | 532 |
| 533 protected: | 533 protected: |
| 534 ~Interface() {} | 534 ~Interface() {} |
| 535 }; | 535 }; |
| 536 | 536 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 trailer, | 570 trailer, |
| 571 destroy_request); | 571 destroy_request); |
| 572 } | 572 } |
| 573 | 573 |
| 574 kern_return_t CatchExceptionRaiseState( | 574 kern_return_t CatchExceptionRaiseState( |
| 575 exception_handler_t exception_port, | 575 exception_handler_t exception_port, |
| 576 exception_type_t exception, | 576 exception_type_t exception, |
| 577 const typename Traits::ExceptionCode* code, | 577 const typename Traits::ExceptionCode* code, |
| 578 mach_msg_type_number_t code_count, | 578 mach_msg_type_number_t code_count, |
| 579 thread_state_flavor_t* flavor, | 579 thread_state_flavor_t* flavor, |
| 580 const natural_t* old_state, | 580 ConstThreadState old_state, |
| 581 mach_msg_type_number_t old_state_count, | 581 mach_msg_type_number_t old_state_count, |
| 582 thread_state_t new_state, | 582 thread_state_t new_state, |
| 583 mach_msg_type_number_t* new_state_count, | 583 mach_msg_type_number_t* new_state_count, |
| 584 const mach_msg_trailer_t* trailer) override { | 584 const mach_msg_trailer_t* trailer) override { |
| 585 bool destroy_complex_request = false; | 585 bool destroy_complex_request = false; |
| 586 return interface_->CatchException( | 586 return interface_->CatchException( |
| 587 Traits::kExceptionBehavior | EXCEPTION_STATE, | 587 Traits::kExceptionBehavior | EXCEPTION_STATE, |
| 588 exception_port, | 588 exception_port, |
| 589 THREAD_NULL, | 589 THREAD_NULL, |
| 590 TASK_NULL, | 590 TASK_NULL, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 601 } | 601 } |
| 602 | 602 |
| 603 kern_return_t CatchExceptionRaiseStateIdentity( | 603 kern_return_t CatchExceptionRaiseStateIdentity( |
| 604 exception_handler_t exception_port, | 604 exception_handler_t exception_port, |
| 605 thread_t thread, | 605 thread_t thread, |
| 606 task_t task, | 606 task_t task, |
| 607 exception_type_t exception, | 607 exception_type_t exception, |
| 608 const typename Traits::ExceptionCode* code, | 608 const typename Traits::ExceptionCode* code, |
| 609 mach_msg_type_number_t code_count, | 609 mach_msg_type_number_t code_count, |
| 610 thread_state_flavor_t* flavor, | 610 thread_state_flavor_t* flavor, |
| 611 const natural_t* old_state, | 611 ConstThreadState old_state, |
| 612 mach_msg_type_number_t old_state_count, | 612 mach_msg_type_number_t old_state_count, |
| 613 thread_state_t new_state, | 613 thread_state_t new_state, |
| 614 mach_msg_type_number_t* new_state_count, | 614 mach_msg_type_number_t* new_state_count, |
| 615 const mach_msg_trailer_t* trailer, | 615 const mach_msg_trailer_t* trailer, |
| 616 bool* destroy_request) override { | 616 bool* destroy_request) override { |
| 617 return interface_->CatchException( | 617 return interface_->CatchException( |
| 618 Traits::kExceptionBehavior | EXCEPTION_STATE_IDENTITY, | 618 Traits::kExceptionBehavior | EXCEPTION_STATE_IDENTITY, |
| 619 exception_port, | 619 exception_port, |
| 620 thread, | 620 thread, |
| 621 task, | 621 task, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 | 662 |
| 663 // SimplifiedExcServer<ExcTraits>::Interface: | 663 // SimplifiedExcServer<ExcTraits>::Interface: |
| 664 kern_return_t CatchException(exception_behavior_t behavior, | 664 kern_return_t CatchException(exception_behavior_t behavior, |
| 665 exception_handler_t exception_port, | 665 exception_handler_t exception_port, |
| 666 thread_t thread, | 666 thread_t thread, |
| 667 task_t task, | 667 task_t task, |
| 668 exception_type_t exception, | 668 exception_type_t exception, |
| 669 const exception_data_type_t* code, | 669 const exception_data_type_t* code, |
| 670 mach_msg_type_number_t code_count, | 670 mach_msg_type_number_t code_count, |
| 671 thread_state_flavor_t* flavor, | 671 thread_state_flavor_t* flavor, |
| 672 const natural_t* old_state, | 672 ConstThreadState old_state, |
| 673 mach_msg_type_number_t old_state_count, | 673 mach_msg_type_number_t old_state_count, |
| 674 thread_state_t new_state, | 674 thread_state_t new_state, |
| 675 mach_msg_type_number_t* new_state_count, | 675 mach_msg_type_number_t* new_state_count, |
| 676 const mach_msg_trailer_t* trailer, | 676 const mach_msg_trailer_t* trailer, |
| 677 bool* destroy_complex_request) { | 677 bool* destroy_complex_request) { |
| 678 std::vector<mach_exception_data_type_t> mach_codes; | 678 std::vector<mach_exception_data_type_t> mach_codes; |
| 679 mach_codes.reserve(code_count); | 679 mach_codes.reserve(code_count); |
| 680 for (size_t index = 0; index < code_count; ++index) { | 680 for (size_t index = 0; index < code_count; ++index) { |
| 681 mach_codes.push_back(code[index]); | 681 mach_codes.push_back(code[index]); |
| 682 } | 682 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 699 | 699 |
| 700 // SimplifiedExcServer<MachExcTraits>::Interface: | 700 // SimplifiedExcServer<MachExcTraits>::Interface: |
| 701 kern_return_t CatchException(exception_behavior_t behavior, | 701 kern_return_t CatchException(exception_behavior_t behavior, |
| 702 exception_handler_t exception_port, | 702 exception_handler_t exception_port, |
| 703 thread_t thread, | 703 thread_t thread, |
| 704 task_t task, | 704 task_t task, |
| 705 exception_type_t exception, | 705 exception_type_t exception, |
| 706 const mach_exception_data_type_t* code, | 706 const mach_exception_data_type_t* code, |
| 707 mach_msg_type_number_t code_count, | 707 mach_msg_type_number_t code_count, |
| 708 thread_state_flavor_t* flavor, | 708 thread_state_flavor_t* flavor, |
| 709 const natural_t* old_state, | 709 ConstThreadState old_state, |
| 710 mach_msg_type_number_t old_state_count, | 710 mach_msg_type_number_t old_state_count, |
| 711 thread_state_t new_state, | 711 thread_state_t new_state, |
| 712 mach_msg_type_number_t* new_state_count, | 712 mach_msg_type_number_t* new_state_count, |
| 713 const mach_msg_trailer_t* trailer, | 713 const mach_msg_trailer_t* trailer, |
| 714 bool* destroy_complex_request) { | 714 bool* destroy_complex_request) { |
| 715 return interface_->CatchMachException(behavior, | 715 return interface_->CatchMachException(behavior, |
| 716 exception_port, | 716 exception_port, |
| 717 thread, | 717 thread, |
| 718 task, | 718 task, |
| 719 exception, | 719 exception, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 kern_return_t ExcServerSuccessfulReturnValue(exception_behavior_t behavior, | 797 kern_return_t ExcServerSuccessfulReturnValue(exception_behavior_t behavior, |
| 798 bool set_thread_state) { | 798 bool set_thread_state) { |
| 799 if (!set_thread_state && ExceptionBehaviorHasState(behavior)) { | 799 if (!set_thread_state && ExceptionBehaviorHasState(behavior)) { |
| 800 return MACH_RCV_PORT_DIED; | 800 return MACH_RCV_PORT_DIED; |
| 801 } | 801 } |
| 802 | 802 |
| 803 return KERN_SUCCESS; | 803 return KERN_SUCCESS; |
| 804 } | 804 } |
| 805 | 805 |
| 806 void ExcServerCopyState(exception_behavior_t behavior, | 806 void ExcServerCopyState(exception_behavior_t behavior, |
| 807 const natural_t* old_state, | 807 ConstThreadState old_state, |
| 808 mach_msg_type_number_t old_state_count, | 808 mach_msg_type_number_t old_state_count, |
| 809 thread_state_t new_state, | 809 thread_state_t new_state, |
| 810 mach_msg_type_number_t* new_state_count) { | 810 mach_msg_type_number_t* new_state_count) { |
| 811 if (ExceptionBehaviorHasState(behavior)) { | 811 if (ExceptionBehaviorHasState(behavior)) { |
| 812 *new_state_count = std::min(old_state_count, *new_state_count); | 812 *new_state_count = std::min(old_state_count, *new_state_count); |
| 813 memcpy(new_state, old_state, *new_state_count * sizeof(old_state[0])); | 813 memcpy(new_state, old_state, *new_state_count * sizeof(old_state[0])); |
| 814 } | 814 } |
| 815 } | 815 } |
| 816 | 816 |
| 817 } // namespace crashpad | 817 } // namespace crashpad |
| OLD | NEW |