| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/chrome_application_mac.h" | 5 #import "chrome/browser/chrome_application_mac.h" |
| 6 | 6 |
| 7 #import "base/histogram.h" | 7 #import "base/histogram.h" |
| 8 #import "base/logging.h" | 8 #import "base/logging.h" |
| 9 #import "base/scoped_nsobject.h" | 9 #import "base/scoped_nsobject.h" |
| 10 #import "chrome/app/breakpad_mac.h" | 10 #import "chrome/app/breakpad_mac.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // we attempt to track and report them. | 189 // we attempt to track and report them. |
| 190 - (void)reportException:(NSException *)anException { | 190 - (void)reportException:(NSException *)anException { |
| 191 // If we throw an exception in this code, we can create an infinite | 191 // If we throw an exception in this code, we can create an infinite |
| 192 // loop. If we throw out of the if() without resetting | 192 // loop. If we throw out of the if() without resetting |
| 193 // |reportException|, we'll stop reporting exceptions for this run. | 193 // |reportException|, we'll stop reporting exceptions for this run. |
| 194 static BOOL reportingException = NO; | 194 static BOOL reportingException = NO; |
| 195 DCHECK(!reportingException); | 195 DCHECK(!reportingException); |
| 196 if (!reportingException) { | 196 if (!reportingException) { |
| 197 reportingException = YES; | 197 reportingException = YES; |
| 198 CrApplicationNSException::RecordExceptionWithUma(anException); | 198 CrApplicationNSException::RecordExceptionWithUma(anException); |
| 199 |
| 200 // Store some human-readable information in breakpad keys in case |
| 201 // there is a crash. Since breakpad does not provide infinite |
| 202 // storage, we track two exceptions. The first exception thrown |
| 203 // is tracked because it may be the one which caused the system to |
| 204 // go off the rails. The last exception thrown is tracked because |
| 205 // it may be the one most directly associated with the crash. |
| 206 static const NSString* kFirstExceptionKey = @"firstexception"; |
| 207 static BOOL trackedFirstException = NO; |
| 208 static const NSString* kLastExceptionKey = @"lastexception"; |
| 209 |
| 210 // TODO(shess): It would be useful to post some stacktrace info |
| 211 // from the exception. |
| 212 // 10.6 has -[NSException callStackSymbols] |
| 213 // 10.5 has -[NSException callStackReturnAddresses] |
| 214 // 10.5 has backtrace_symbols(). |
| 215 // I've tried to combine the latter two, but got nothing useful. |
| 216 // The addresses are right, though, maybe we could train the crash |
| 217 // server to decode them for us. |
| 218 |
| 219 NSString* value = [NSString stringWithFormat:@"%@ reason %@", |
| 220 [anException name], [anException reason]]; |
| 221 if (!trackedFirstException) { |
| 222 SetCrashKeyValue(kFirstExceptionKey, value); |
| 223 trackedFirstException = YES; |
| 224 } else { |
| 225 SetCrashKeyValue(kLastExceptionKey, value); |
| 226 } |
| 227 |
| 199 reportingException = NO; | 228 reportingException = NO; |
| 200 } | 229 } |
| 201 | 230 |
| 202 [super reportException:anException]; | 231 [super reportException:anException]; |
| 203 } | 232 } |
| 204 | 233 |
| 205 @end | 234 @end |
| 206 | 235 |
| 207 namespace CrApplicationCC { | 236 namespace CrApplicationCC { |
| 208 | 237 |
| 209 void Terminate() { | 238 void Terminate() { |
| 210 [NSApp terminate:nil]; | 239 [NSApp terminate:nil]; |
| 211 } | 240 } |
| 212 | 241 |
| 213 } // namespace CrApplicationCC | 242 } // namespace CrApplicationCC |
| OLD | NEW |