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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 codes_.push_back(code[code_index]); | 59 codes_.push_back(code[code_index]); |
60 } | 60 } |
61 | 61 |
62 exception_ = exception; | 62 exception_ = exception; |
63 mach_exception_code_t exception_code_0 = code[0]; | 63 mach_exception_code_t exception_code_0 = code[0]; |
64 | 64 |
65 if (exception_ == EXC_CRASH) { | 65 if (exception_ == EXC_CRASH) { |
66 exception_ = ExcCrashRecoverOriginalException( | 66 exception_ = ExcCrashRecoverOriginalException( |
67 exception_code_0, &exception_code_0, nullptr); | 67 exception_code_0, &exception_code_0, nullptr); |
68 | 68 |
69 if (exception_ == EXC_RESOURCE || exception_ == EXC_GUARD) { | 69 if (exception_ == EXC_CRASH || |
70 // These are software exceptions that are never mapped to EXC_CRASH. The | 70 exception_ == EXC_RESOURCE || |
71 // only time EXC_CRASH is generated is for processes exiting due to an | 71 exception_ == EXC_GUARD) { |
72 // unhandled core-generating signal or being killed by SIGKILL for | 72 // EXC_CRASH should never be wrapped in another EXC_CRASH. |
73 // code-signing reasons. Neither of these applies to EXC_RESOURCE or | |
74 // EXC_GUARD. See 10.10 xnu-2782.1.97/bsd/kern/kern_exit.c | |
75 // proc_prepareexit(). | |
76 // | 73 // |
77 // Receiving these exception types wrapped in EXC_CRASH would lose | 74 // EXC_RESOURCE and EXC_GUARD are software exceptions that are never |
78 // information because their code[0] uses all 64 bits (see below) and the | 75 // wrapped in EXC_CRASH. The only time EXC_CRASH is generated is for |
79 // code[0] recovered from EXC_CRASH only contains 20 significant bits. | 76 // processes exiting due to an unhandled core-generating signal or being |
| 77 // killed by SIGKILL for code-signing reasons. Neither of these applies to |
| 78 // EXC_RESOURCE or EXC_GUARD. See 10.10 xnu-2782.1.97/bsd/kern/kern_exit.c |
| 79 // proc_prepareexit(). Receiving these exception types wrapped in |
| 80 // EXC_CRASH would lose information because their code[0] uses all 64 bits |
| 81 // (see below) and the code[0] recovered from EXC_CRASH only contains 20 |
| 82 // significant bits. |
80 LOG(WARNING) << base::StringPrintf( | 83 LOG(WARNING) << base::StringPrintf( |
81 "exception %s invalid in EXC_CRASH", | 84 "exception %s invalid in EXC_CRASH", |
82 ExceptionToString(exception_, kUseFullName | kUnknownIsNumeric) | 85 ExceptionToString(exception_, kUseFullName | kUnknownIsNumeric) |
83 .c_str()); | 86 .c_str()); |
84 } | 87 } |
85 } | 88 } |
86 | 89 |
87 // The operations that follow put exception_code_0 (a mach_exception_code_t, | 90 // The operations that follow put exception_code_0 (a mach_exception_code_t, |
88 // a typedef for int64_t) into exception_code_0_ (a uint32_t). The range | 91 // a typedef for int64_t) into exception_code_0_ (a uint32_t). The range |
89 // checks and bit shifts involved need the same signedness on both sides to | 92 // checks and bit shifts involved need the same signedness on both sides to |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 return exception_address_; | 244 return exception_address_; |
242 } | 245 } |
243 | 246 |
244 const std::vector<uint64_t>& ExceptionSnapshotMac::Codes() const { | 247 const std::vector<uint64_t>& ExceptionSnapshotMac::Codes() const { |
245 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 248 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
246 return codes_; | 249 return codes_; |
247 } | 250 } |
248 | 251 |
249 } // namespace internal | 252 } // namespace internal |
250 } // namespace crashpad | 253 } // namespace crashpad |
OLD | NEW |