diff options
-rw-r--r-- | chrome/browser/chrome_application_mac.mm | 47 | ||||
-rwxr-xr-x | chrome/chrome.gyp | 1 |
2 files changed, 48 insertions, 0 deletions
diff --git a/chrome/browser/chrome_application_mac.mm b/chrome/browser/chrome_application_mac.mm index a81326f..2457dc2 100644 --- a/chrome/browser/chrome_application_mac.mm +++ b/chrome/browser/chrome_application_mac.mm @@ -4,6 +4,30 @@ #import "chrome/browser/chrome_application_mac.h" +#import "base/scoped_nsobject.h" +#import "chrome/app/breakpad_mac.h" + +namespace { + +// Helper to make it easy to get crash keys right. +// TODO(shess): Find a better home for this. app/breakpad_mac.h +// doesn't work. +class ScopedCrashKey { + public: + ScopedCrashKey(NSString* key, NSString* value) + : crash_key_([key retain]) { + SetCrashKeyValue(crash_key_.get(), value); + } + ~ScopedCrashKey() { + ClearCrashKeyValue(crash_key_.get()); + } + + private: + scoped_nsobject<NSString> crash_key_; +}; + +} // namespace + @implementation CrApplication // -terminate: is the entry point for orderly "quit" operations in Cocoa. @@ -80,6 +104,29 @@ } } + // When a Cocoa control is wired to a freed object, we get crashers + // in the call to |super| with no useful information in the + // backtrace. Attempt to add some useful information. + static const NSString* kActionKey = @"sendaction"; + + // If the action is something generic like -commandDispatch:, then + // the tag is essential. + NSInteger tag = 0; + if ([sender isKindOfClass:[NSControl class]]) { + tag = [sender tag]; + if (tag == 0 || tag == -1) { + tag = [sender selectedTag]; + } + } else if ([sender isKindOfClass:[NSMenuItem class]]) { + tag = [sender tag]; + } + + NSString* actionString = NSStringFromSelector(anAction); + NSString* value = + [NSString stringWithFormat:@"%@ tag %d sending %@ to %p", + [sender className], tag, actionString, aTarget]; + + ScopedCrashKey key(kActionKey, value); return [super sendAction:anAction to:aTarget from:sender]; } diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 3fa1905..4387938 100755 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -4028,6 +4028,7 @@ 'sources': [ 'app/keystone_glue.h', 'app/keystone_glue.m', + 'app/breakpad_mac_stubs.mm', ], 'sources!': [ # TODO(port) |