OLD | NEW |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 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 13 matching lines...) Expand all Loading... |
24 #include "client/settings.h" | 24 #include "client/settings.h" |
25 #include "minidump/minidump_file_writer.h" | 25 #include "minidump/minidump_file_writer.h" |
26 #include "snapshot/mac/crashpad_info_client_options.h" | 26 #include "snapshot/mac/crashpad_info_client_options.h" |
27 #include "snapshot/mac/process_snapshot_mac.h" | 27 #include "snapshot/mac/process_snapshot_mac.h" |
28 #include "util/file/file_writer.h" | 28 #include "util/file/file_writer.h" |
29 #include "util/mach/exc_client_variants.h" | 29 #include "util/mach/exc_client_variants.h" |
30 #include "util/mach/exception_behaviors.h" | 30 #include "util/mach/exception_behaviors.h" |
31 #include "util/mach/mach_extensions.h" | 31 #include "util/mach/mach_extensions.h" |
32 #include "util/mach/mach_message.h" | 32 #include "util/mach/mach_message.h" |
33 #include "util/mach/scoped_task_suspend.h" | 33 #include "util/mach/scoped_task_suspend.h" |
| 34 #include "util/mach/symbolic_constants_mach.h" |
34 #include "util/misc/tri_state.h" | 35 #include "util/misc/tri_state.h" |
35 #include "util/misc/uuid.h" | 36 #include "util/misc/uuid.h" |
36 | 37 |
37 namespace crashpad { | 38 namespace crashpad { |
38 | 39 |
39 namespace { | 40 namespace { |
40 | 41 |
41 // Calls CrashReportDatabase::ErrorWritingCrashReport() upon destruction unless | 42 // Calls CrashReportDatabase::ErrorWritingCrashReport() upon destruction unless |
42 // disarmed by calling Disarm(). Armed upon construction. | 43 // disarmed by calling Disarm(). Armed upon construction. |
43 class CallErrorWritingCrashReport { | 44 class CallErrorWritingCrashReport { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 mach_msg_type_number_t* new_state_count, | 95 mach_msg_type_number_t* new_state_count, |
95 const mach_msg_trailer_t* trailer, | 96 const mach_msg_trailer_t* trailer, |
96 bool* destroy_complex_request) { | 97 bool* destroy_complex_request) { |
97 *destroy_complex_request = true; | 98 *destroy_complex_request = true; |
98 | 99 |
99 // The expected behavior is EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, | 100 // The expected behavior is EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, |
100 // but it’s possible to deal with any exception behavior as long as it | 101 // but it’s possible to deal with any exception behavior as long as it |
101 // carries identity information (valid thread and task ports). | 102 // carries identity information (valid thread and task ports). |
102 if (!ExceptionBehaviorHasIdentity(behavior)) { | 103 if (!ExceptionBehaviorHasIdentity(behavior)) { |
103 LOG(ERROR) << base::StringPrintf( | 104 LOG(ERROR) << base::StringPrintf( |
104 "unexpected exception behavior 0x%x, rejecting", behavior); | 105 "unexpected exception behavior %s, rejecting", |
| 106 ExceptionBehaviorToString( |
| 107 behavior, kUseFullName | kUnknownIsNumeric | kUseOr).c_str()); |
105 return KERN_FAILURE; | 108 return KERN_FAILURE; |
106 } else if (behavior != (EXCEPTION_STATE_IDENTITY | kMachExceptionCodes)) { | 109 } else if (behavior != (EXCEPTION_STATE_IDENTITY | kMachExceptionCodes)) { |
107 LOG(WARNING) << base::StringPrintf( | 110 LOG(WARNING) << base::StringPrintf( |
108 "unexpected exception behavior 0x%x, proceeding", behavior); | 111 "unexpected exception behavior %s, proceeding", |
| 112 ExceptionBehaviorToString( |
| 113 behavior, kUseFullName | kUnknownIsNumeric | kUseOr).c_str()); |
109 } | 114 } |
110 | 115 |
111 if (task == mach_task_self()) { | 116 if (task == mach_task_self()) { |
112 LOG(ERROR) << "cannot suspend myself"; | 117 LOG(ERROR) << "cannot suspend myself"; |
113 return KERN_FAILURE; | 118 return KERN_FAILURE; |
114 } | 119 } |
115 | 120 |
116 ScopedTaskSuspend suspend(task); | 121 ScopedTaskSuspend suspend(task); |
117 | 122 |
118 ProcessSnapshotMac process_snapshot; | 123 ProcessSnapshotMac process_snapshot; |
(...skipping 14 matching lines...) Expand all Loading... |
133 if (exception_pid != audit_pid) { | 138 if (exception_pid != audit_pid) { |
134 LOG(WARNING) << "exception for pid " << exception_pid << " sent by pid " | 139 LOG(WARNING) << "exception for pid " << exception_pid << " sent by pid " |
135 << audit_pid; | 140 << audit_pid; |
136 } | 141 } |
137 } | 142 } |
138 | 143 |
139 CrashpadInfoClientOptions client_options; | 144 CrashpadInfoClientOptions client_options; |
140 process_snapshot.GetCrashpadOptions(&client_options); | 145 process_snapshot.GetCrashpadOptions(&client_options); |
141 | 146 |
142 if (client_options.crashpad_handler_behavior != TriState::kDisabled) { | 147 if (client_options.crashpad_handler_behavior != TriState::kDisabled) { |
143 if (!process_snapshot.InitializeException(thread, | 148 if (!process_snapshot.InitializeException(behavior, |
| 149 thread, |
144 exception, | 150 exception, |
145 code, | 151 code, |
146 code_count, | 152 code_count, |
147 *flavor, | 153 *flavor, |
148 old_state, | 154 old_state, |
149 old_state_count)) { | 155 old_state_count)) { |
150 return KERN_FAILURE; | 156 return KERN_FAILURE; |
151 } | 157 } |
152 | 158 |
153 UUID client_id; | 159 UUID client_id; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 exception == EXC_RESOURCE || | 205 exception == EXC_RESOURCE || |
200 exception == EXC_GUARD)) { | 206 exception == EXC_GUARD)) { |
201 // Don’t forward simulated exceptions such as kMachExceptionSimulated to the | 207 // Don’t forward simulated exceptions such as kMachExceptionSimulated to the |
202 // system crash reporter. Only forward the types of exceptions that it would | 208 // system crash reporter. Only forward the types of exceptions that it would |
203 // receive under normal conditions. Although the system crash reporter is | 209 // receive under normal conditions. Although the system crash reporter is |
204 // able to deal with other exceptions including simulated ones, forwarding | 210 // able to deal with other exceptions including simulated ones, forwarding |
205 // them to the system crash reporter could present the system’s crash UI for | 211 // them to the system crash reporter could present the system’s crash UI for |
206 // processes that haven’t actually crashed, and could result in reports not | 212 // processes that haven’t actually crashed, and could result in reports not |
207 // actually associated with crashes being sent to the operating system | 213 // actually associated with crashes being sent to the operating system |
208 // vendor. | 214 // vendor. |
| 215 // |
| 216 // Note that normally, EXC_RESOURCE and EXC_GUARD exceptions are sent to the |
| 217 // system-level com.apple.ReportCrash.Root job, and not to the user-level |
| 218 // job that they are forwarded to here. |
209 mach_port_t system_crash_reporter_port; | 219 mach_port_t system_crash_reporter_port; |
210 const char kSystemCrashReporterServiceName[] = "com.apple.ReportCrash"; | 220 const char kSystemCrashReporterServiceName[] = "com.apple.ReportCrash"; |
211 kern_return_t kr = bootstrap_look_up(bootstrap_port, | 221 kern_return_t kr = bootstrap_look_up(bootstrap_port, |
212 kSystemCrashReporterServiceName, | 222 kSystemCrashReporterServiceName, |
213 &system_crash_reporter_port); | 223 &system_crash_reporter_port); |
214 if (kr != BOOTSTRAP_SUCCESS) { | 224 if (kr != BOOTSTRAP_SUCCESS) { |
215 BOOTSTRAP_LOG(ERROR, kr) << "bootstrap_look_up " | 225 BOOTSTRAP_LOG(ERROR, kr) << "bootstrap_look_up " |
216 << kSystemCrashReporterServiceName; | 226 << kSystemCrashReporterServiceName; |
217 } else { | 227 } else { |
218 // Make copies of mutable out parameters so that the system crash reporter | 228 // Make copies of mutable out parameters so that the system crash reporter |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 265 |
256 if (!forwarded) { | 266 if (!forwarded) { |
257 ExcServerCopyState( | 267 ExcServerCopyState( |
258 behavior, old_state, old_state_count, new_state, new_state_count); | 268 behavior, old_state, old_state_count, new_state, new_state_count); |
259 } | 269 } |
260 | 270 |
261 return ExcServerSuccessfulReturnValue(behavior, false); | 271 return ExcServerSuccessfulReturnValue(behavior, false); |
262 } | 272 } |
263 | 273 |
264 } // namespace crashpad | 274 } // namespace crashpad |
OLD | NEW |