OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/mac/exception_processor.h" | 5 #import "chrome/browser/mac/exception_processor.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 #include <libunwind.h> | 8 #include <libunwind.h> |
9 #include <objc/objc-exception.h> | 9 #include <objc/objc-exception.h> |
10 | 10 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 static objc_exception_preprocessor g_next_preprocessor = nullptr; | 77 static objc_exception_preprocessor g_next_preprocessor = nullptr; |
78 | 78 |
79 static const char* const kExceptionSinkholes[] = { | 79 static const char* const kExceptionSinkholes[] = { |
80 "CFRunLoopRunSpecific", | 80 "CFRunLoopRunSpecific", |
81 "_dispatch_client_callout", | 81 "_dispatch_client_callout", |
82 }; | 82 }; |
83 | 83 |
84 // This function is used to make it clear to the crash processor that this is | 84 // This function is used to make it clear to the crash processor that this is |
85 // a forced exception crash. | 85 // a forced exception crash. |
86 static NOINLINE void TERMINATING_FROM_UNCAUGHT_NSEXCEPTION(id exception) { | 86 static NOINLINE void TERMINATING_FROM_UNCAUGHT_NSEXCEPTION(id exception) { |
87 LOG(FATAL) << "Terminating from Objective-C exception: " | 87 NSString* exception_message_ns = [NSString |
88 << base::SysNSStringToUTF8([exception name]) | 88 stringWithFormat:@"%@: %@", [exception name], [exception reason]]; |
89 << ": " << base::SysNSStringToUTF8([exception reason]); | 89 std::string exception_message = base::SysNSStringToUTF8(exception_message_ns); |
| 90 base::debug::SetCrashKeyValue(crash_keys::mac::kNSException, |
| 91 exception_message); |
| 92 LOG(FATAL) << "Terminating from Objective-C exception: " << exception_message; |
90 } | 93 } |
91 | 94 |
92 static id ObjcExceptionPreprocessor(id exception) { | 95 static id ObjcExceptionPreprocessor(id exception) { |
93 static bool seen_first_exception = false; | 96 static bool seen_first_exception = false; |
94 | 97 |
95 // Record UMA and crash keys about the exception. | 98 // Record UMA and crash keys about the exception. |
96 RecordExceptionWithUma(exception); | 99 RecordExceptionWithUma(exception); |
97 | 100 |
98 const char* const kExceptionKey = | 101 const char* const kExceptionKey = |
99 seen_first_exception ? crash_keys::mac::kLastNSException | 102 seen_first_exception ? crash_keys::mac::kLastNSException |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 g_next_preprocessor = | 171 g_next_preprocessor = |
169 objc_setExceptionPreprocessor(&ObjcExceptionPreprocessor); | 172 objc_setExceptionPreprocessor(&ObjcExceptionPreprocessor); |
170 } | 173 } |
171 | 174 |
172 void UninstallObjcExceptionPreprocessor() { | 175 void UninstallObjcExceptionPreprocessor() { |
173 objc_setExceptionPreprocessor(g_next_preprocessor); | 176 objc_setExceptionPreprocessor(g_next_preprocessor); |
174 g_next_preprocessor = nullptr; | 177 g_next_preprocessor = nullptr; |
175 } | 178 } |
176 | 179 |
177 } // namespace chrome | 180 } // namespace chrome |
OLD | NEW |