OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_browser_application_mac.h" | 5 #import "chrome/browser/chrome_browser_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 "base/sys_string_conversions.h" | 10 #import "base/sys_string_conversions.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // interesting to track in aggregate (those relating to distributed | 78 // interesting to track in aggregate (those relating to distributed |
79 // objects, for instance). | 79 // objects, for instance). |
80 const size_t kKnownNSExceptionCount = 25; | 80 const size_t kKnownNSExceptionCount = 25; |
81 | 81 |
82 const size_t kUnknownNSException = kKnownNSExceptionCount; | 82 const size_t kUnknownNSException = kKnownNSExceptionCount; |
83 | 83 |
84 size_t BinForException(NSException* exception) { | 84 size_t BinForException(NSException* exception) { |
85 // A list of common known exceptions. The list position will | 85 // A list of common known exceptions. The list position will |
86 // determine where they live in the histogram, so never move them | 86 // determine where they live in the histogram, so never move them |
87 // around, only add to the end. | 87 // around, only add to the end. |
| 88 <<<<<<< HEAD |
88 static NSString* const kKnownNSExceptionNames[] = { | 89 static NSString* const kKnownNSExceptionNames[] = { |
| 90 ======= |
| 91 static NSString* kKnownNSExceptionNames[] = { |
| 92 >>>>>>> more |
89 // ??? | 93 // ??? |
90 NSGenericException, | 94 NSGenericException, |
91 | 95 |
92 // Out-of-range on NSString or NSArray. | 96 // Out-of-range on NSString or NSArray. |
93 NSRangeException, | 97 NSRangeException, |
94 | 98 |
95 // Invalid arg to method, unrecognized selector. | 99 // Invalid arg to method, unrecognized selector. |
96 NSInvalidArgumentException, | 100 NSInvalidArgumentException, |
97 | 101 |
98 // malloc() returned null in object creation, I think. | 102 // malloc() returned null in object creation, I think. |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 } | 273 } |
270 } | 274 } |
271 if (!found) { | 275 if (!found) { |
272 return NO; | 276 return NO; |
273 } | 277 } |
274 } | 278 } |
275 | 279 |
276 // When a Cocoa control is wired to a freed object, we get crashers | 280 // When a Cocoa control is wired to a freed object, we get crashers |
277 // in the call to |super| with no useful information in the | 281 // in the call to |super| with no useful information in the |
278 // backtrace. Attempt to add some useful information. | 282 // backtrace. Attempt to add some useful information. |
| 283 <<<<<<< HEAD |
279 static NSString* const kActionKey = @"sendaction"; | 284 static NSString* const kActionKey = @"sendaction"; |
| 285 ======= |
| 286 static NSString* kActionKey = @"sendaction"; |
| 287 >>>>>>> more |
280 | 288 |
281 // If the action is something generic like -commandDispatch:, then | 289 // If the action is something generic like -commandDispatch:, then |
282 // the tag is essential. | 290 // the tag is essential. |
283 NSInteger tag = 0; | 291 NSInteger tag = 0; |
284 if ([sender isKindOfClass:[NSControl class]]) { | 292 if ([sender isKindOfClass:[NSControl class]]) { |
285 tag = [sender tag]; | 293 tag = [sender tag]; |
286 if (tag == 0 || tag == -1) { | 294 if (tag == 0 || tag == -1) { |
287 tag = [sender selectedTag]; | 295 tag = [sender selectedTag]; |
288 } | 296 } |
289 } else if ([sender isKindOfClass:[NSMenuItem class]]) { | 297 } else if ([sender isKindOfClass:[NSMenuItem class]]) { |
(...skipping 21 matching lines...) Expand all Loading... |
311 if (!reportingException) { | 319 if (!reportingException) { |
312 reportingException = YES; | 320 reportingException = YES; |
313 chrome_browser_application_mac::RecordExceptionWithUma(anException); | 321 chrome_browser_application_mac::RecordExceptionWithUma(anException); |
314 | 322 |
315 // Store some human-readable information in breakpad keys in case | 323 // Store some human-readable information in breakpad keys in case |
316 // there is a crash. Since breakpad does not provide infinite | 324 // there is a crash. Since breakpad does not provide infinite |
317 // storage, we track two exceptions. The first exception thrown | 325 // storage, we track two exceptions. The first exception thrown |
318 // is tracked because it may be the one which caused the system to | 326 // is tracked because it may be the one which caused the system to |
319 // go off the rails. The last exception thrown is tracked because | 327 // go off the rails. The last exception thrown is tracked because |
320 // it may be the one most directly associated with the crash. | 328 // it may be the one most directly associated with the crash. |
| 329 <<<<<<< HEAD |
321 static NSString* const kFirstExceptionKey = @"firstexception"; | 330 static NSString* const kFirstExceptionKey = @"firstexception"; |
322 static BOOL trackedFirstException = NO; | 331 static BOOL trackedFirstException = NO; |
323 static NSString* const kLastExceptionKey = @"lastexception"; | 332 static NSString* const kLastExceptionKey = @"lastexception"; |
| 333 ======= |
| 334 static NSString* kFirstExceptionKey = @"firstexception"; |
| 335 static BOOL trackedFirstException = NO; |
| 336 static NSString* kLastExceptionKey = @"lastexception"; |
| 337 >>>>>>> more |
324 | 338 |
325 // TODO(shess): It would be useful to post some stacktrace info | 339 // TODO(shess): It would be useful to post some stacktrace info |
326 // from the exception. | 340 // from the exception. |
327 // 10.6 has -[NSException callStackSymbols] | 341 // 10.6 has -[NSException callStackSymbols] |
328 // 10.5 has -[NSException callStackReturnAddresses] | 342 // 10.5 has -[NSException callStackReturnAddresses] |
329 // 10.5 has backtrace_symbols(). | 343 // 10.5 has backtrace_symbols(). |
330 // I've tried to combine the latter two, but got nothing useful. | 344 // I've tried to combine the latter two, but got nothing useful. |
331 // The addresses are right, though, maybe we could train the crash | 345 // The addresses are right, though, maybe we could train the crash |
332 // server to decode them for us. | 346 // server to decode them for us. |
333 | 347 |
334 NSString* value = [NSString stringWithFormat:@"%@ reason %@", | 348 NSString* value = [NSString stringWithFormat:@"%@ reason %@", |
335 [anException name], [anException reason]]; | 349 [anException name], [anException reason]]; |
336 if (!trackedFirstException) { | 350 if (!trackedFirstException) { |
337 SetCrashKeyValue(kFirstExceptionKey, value); | 351 SetCrashKeyValue(kFirstExceptionKey, value); |
338 trackedFirstException = YES; | 352 trackedFirstException = YES; |
339 } else { | 353 } else { |
340 SetCrashKeyValue(kLastExceptionKey, value); | 354 SetCrashKeyValue(kLastExceptionKey, value); |
341 } | 355 } |
342 | 356 |
343 reportingException = NO; | 357 reportingException = NO; |
344 } | 358 } |
345 | 359 |
346 [super reportException:anException]; | 360 [super reportException:anException]; |
347 } | 361 } |
348 | 362 |
349 @end | 363 @end |
OLD | NEW |