diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 13:29:27 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 13:29:27 +0000 |
commit | b2be7a6889ea1af900760b6e69e22152f652e950 (patch) | |
tree | f2feb925c1ba004cb0ea7a3fb4a78a56a1bbf1cf /chrome/browser/chrome_application_mac.mm | |
parent | 82f8e12b5a00508fac88a19c94fc6b135269182c (diff) | |
download | chromium_src-b2be7a6889ea1af900760b6e69e22152f652e950.zip chromium_src-b2be7a6889ea1af900760b6e69e22152f652e950.tar.gz chromium_src-b2be7a6889ea1af900760b6e69e22152f652e950.tar.bz2 |
[Mac] Add breakpad info for crashes in the target/action dispatcher.
-[NSApplication sendAction:to:from:] is a central dispatcher for
target-action messages sent by controls. Backtraces from here often
contain only Cocoa messages, making it hard to tell where things are
at when a freed target gets messaged. Add additional info like the
action being requested and the tag of the sender.
http://crbug.com/24460
TEST=Browser continues to work.
Review URL: http://codereview.chromium.org/269039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28809 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chrome_application_mac.mm')
-rw-r--r-- | chrome/browser/chrome_application_mac.mm | 47 |
1 files changed, 47 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]; } |