| 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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 } | 760 } |
| 761 | 761 |
| 762 mach_msg_size_t UniversalMachExcServer::MachMessageServerRequestSize() { | 762 mach_msg_size_t UniversalMachExcServer::MachMessageServerRequestSize() { |
| 763 return impl_->MachMessageServerRequestSize(); | 763 return impl_->MachMessageServerRequestSize(); |
| 764 } | 764 } |
| 765 | 765 |
| 766 mach_msg_size_t UniversalMachExcServer::MachMessageServerReplySize() { | 766 mach_msg_size_t UniversalMachExcServer::MachMessageServerReplySize() { |
| 767 return impl_->MachMessageServerReplySize(); | 767 return impl_->MachMessageServerReplySize(); |
| 768 } | 768 } |
| 769 | 769 |
| 770 exception_type_t ExcCrashRecoverOriginalException( | |
| 771 mach_exception_code_t code_0, | |
| 772 mach_exception_code_t* original_code_0, | |
| 773 int* signal) { | |
| 774 // 10.9.4 xnu-2422.110.17/bsd/kern/kern_exit.c proc_prepareexit() sets code[0] | |
| 775 // based on the signal value, original exception type, and low 20 bits of the | |
| 776 // original code[0] before calling xnu-2422.110.17/osfmk/kern/exception.c | |
| 777 // task_exception_notify() to raise an EXC_CRASH. | |
| 778 // | |
| 779 // The list of core-generating signals (as used in proc_prepareexit()’s call | |
| 780 // to hassigprop()) is in 10.9.4 xnu-2422.110.17/bsd/sys/signalvar.h sigprop: | |
| 781 // entires with SA_CORE are in the set. These signals are SIGQUIT, SIGILL, | |
| 782 // SIGTRAP, SIGABRT, SIGEMT, SIGFPE, SIGBUS, SIGSEGV, and SIGSYS. Processes | |
| 783 // killed for code-signing reasons will be killed by SIGKILL and are also | |
| 784 // eligible for EXC_CRASH handling, but processes killed by SIGKILL for other | |
| 785 // reasons are not. | |
| 786 if (signal) { | |
| 787 *signal = (code_0 >> 24) & 0xff; | |
| 788 } | |
| 789 | |
| 790 if (original_code_0) { | |
| 791 *original_code_0 = code_0 & 0xfffff; | |
| 792 } | |
| 793 | |
| 794 return (code_0 >> 20) & 0xf; | |
| 795 } | |
| 796 | |
| 797 kern_return_t ExcServerSuccessfulReturnValue(exception_behavior_t behavior, | 770 kern_return_t ExcServerSuccessfulReturnValue(exception_behavior_t behavior, |
| 798 bool set_thread_state) { | 771 bool set_thread_state) { |
| 799 if (!set_thread_state && ExceptionBehaviorHasState(behavior)) { | 772 if (!set_thread_state && ExceptionBehaviorHasState(behavior)) { |
| 800 return MACH_RCV_PORT_DIED; | 773 return MACH_RCV_PORT_DIED; |
| 801 } | 774 } |
| 802 | 775 |
| 803 return KERN_SUCCESS; | 776 return KERN_SUCCESS; |
| 804 } | 777 } |
| 805 | 778 |
| 806 void ExcServerCopyState(exception_behavior_t behavior, | 779 void ExcServerCopyState(exception_behavior_t behavior, |
| 807 ConstThreadState old_state, | 780 ConstThreadState old_state, |
| 808 mach_msg_type_number_t old_state_count, | 781 mach_msg_type_number_t old_state_count, |
| 809 thread_state_t new_state, | 782 thread_state_t new_state, |
| 810 mach_msg_type_number_t* new_state_count) { | 783 mach_msg_type_number_t* new_state_count) { |
| 811 if (ExceptionBehaviorHasState(behavior)) { | 784 if (ExceptionBehaviorHasState(behavior)) { |
| 812 *new_state_count = std::min(old_state_count, *new_state_count); | 785 *new_state_count = std::min(old_state_count, *new_state_count); |
| 813 memcpy(new_state, old_state, *new_state_count * sizeof(old_state[0])); | 786 memcpy(new_state, old_state, *new_state_count * sizeof(old_state[0])); |
| 814 } | 787 } |
| 815 } | 788 } |
| 816 | 789 |
| 817 } // namespace crashpad | 790 } // namespace crashpad |
| OLD | NEW |