summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/base.gypi2
-rw-r--r--base/mac/crash_logging.h56
-rw-r--r--base/mac/crash_logging_mac.mm44
-rw-r--r--chrome/browser/chrome_browser_application_mac.mm49
-rw-r--r--chrome/chrome_common.gypi2
-rw-r--r--chrome/common/crash_keys.cc26
-rw-r--r--chrome/common/crash_keys.h38
-rw-r--r--chrome/common/mac/objc_zombie.mm20
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mac.mm19
-rw-r--r--content/renderer/plugin_channel_host.cc10
-rw-r--r--content/renderer/renderer_main_platform_delegate_mac.mm1
-rw-r--r--media/video/capture/mac/video_capture_device_qtkit_mac.mm4
12 files changed, 116 insertions, 155 deletions
diff --git a/base/base.gypi b/base/base.gypi
index 69a844e..2ee97d3 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -208,8 +208,6 @@
'mac/bundle_locations.h',
'mac/bundle_locations.mm',
'mac/cocoa_protocols.h',
- 'mac/crash_logging.h',
- 'mac/crash_logging_mac.mm',
'mac/foundation_util.h',
'mac/foundation_util.mm',
'mac/launchd.cc',
diff --git a/base/mac/crash_logging.h b/base/mac/crash_logging.h
deleted file mode 100644
index 837a044..0000000
--- a/base/mac/crash_logging.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_MAC_CRASH_LOGGING_H_
-#define BASE_MAC_CRASH_LOGGING_H_
-
-#include "base/base_export.h"
-
-#if __OBJC__
-#import "base/memory/scoped_nsobject.h"
-
-@class NSString;
-#else
-class NSString;
-#endif
-
-// !!! DEPRECATED !!!!
-// Please use base/debug/crash_logging.h instead.
-//
-// TODO(rsesek): Convert all callers to the new API.
-
-namespace base {
-namespace mac {
-
-// Set and clear meta information for Minidump.
-// IMPORTANT: On OS X, the key/value pairs are sent to the crash server
-// out of bounds and not recorded on disk in the minidump, this means
-// that if you look at the minidump file locally you won't see them!
-BASE_EXPORT void SetCrashKeyValue(NSString* key, NSString* val);
-BASE_EXPORT void ClearCrashKey(NSString* key);
-
-// Format |count| items from |addresses| using %p, and set the
-// resulting string as value for crash key |key|. A maximum of 23
-// items will be encoded, since breakpad limits values to 255 bytes.
-BASE_EXPORT void SetCrashKeyFromAddresses(NSString* key,
- const void* const* addresses,
- size_t count);
-
-#if __OBJC__
-
-class BASE_EXPORT ScopedCrashKey {
- public:
- ScopedCrashKey(NSString* key, NSString* value);
- ~ScopedCrashKey();
- private:
- scoped_nsobject<NSString> crash_key_;
- DISALLOW_COPY_AND_ASSIGN(ScopedCrashKey);
-};
-
-#endif // __OBJC__
-
-} // namespace mac
-} // namespace base
-
-#endif // BASE_MAC_CRASH_LOGGING_H_
diff --git a/base/mac/crash_logging_mac.mm b/base/mac/crash_logging_mac.mm
deleted file mode 100644
index 85e5202..0000000
--- a/base/mac/crash_logging_mac.mm
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/mac/crash_logging.h"
-
-#import <Foundation/Foundation.h>
-
-#include "base/debug/crash_logging.h"
-#include "base/sys_string_conversions.h"
-
-namespace base {
-namespace mac {
-
-void SetCrashKeyValue(NSString* key, NSString* val) {
- base::debug::SetCrashKeyValue(
- base::SysNSStringToUTF8(key),
- base::SysNSStringToUTF8(val));
-}
-
-void ClearCrashKey(NSString* key) {
- base::debug::ClearCrashKey(base::SysNSStringToUTF8(key));
-}
-
-void SetCrashKeyFromAddresses(NSString* key,
- const void* const* addresses,
- size_t count) {
- base::debug::SetCrashKeyFromAddresses(
- base::SysNSStringToUTF8(key),
- addresses,
- count);
-}
-
-ScopedCrashKey::ScopedCrashKey(NSString* key, NSString* value)
- : crash_key_([key retain]) {
- SetCrashKeyValue(key, value);
-}
-
-ScopedCrashKey::~ScopedCrashKey() {
- ClearCrashKey(crash_key_);
-}
-
-} // namespace mac
-} // namespace base
diff --git a/chrome/browser/chrome_browser_application_mac.mm b/chrome/browser/chrome_browser_application_mac.mm
index b3f3533..791421d 100644
--- a/chrome/browser/chrome_browser_application_mac.mm
+++ b/chrome/browser/chrome_browser_application_mac.mm
@@ -5,14 +5,16 @@
#import "chrome/browser/chrome_browser_application_mac.h"
#import "base/auto_reset.h"
+#include "base/debug/crash_logging.h"
#import "base/logging.h"
-#include "base/mac/crash_logging.h"
#import "base/mac/scoped_nsexception_enabler.h"
#import "base/memory/scoped_nsobject.h"
#import "base/metrics/histogram.h"
+#include "base/stringprintf.h"
#import "base/sys_string_conversions.h"
#import "chrome/browser/app_controller_mac.h"
#include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
+#include "chrome/common/crash_keys.h"
#import "chrome/common/mac/objc_method_swizzle.h"
#import "chrome/common/mac/objc_zombie.h"
#include "content/public/browser/browser_accessibility_state.h"
@@ -61,10 +63,9 @@ static IMP gOriginalInitIMP = NULL;
if (!found) {
// Update breakpad with the exception info.
- static NSString* const kNSExceptionKey = @"nsexception";
- NSString* value =
- [NSString stringWithFormat:@"%@ reason %@", aName, aReason];
- base::mac::SetCrashKeyValue(kNSExceptionKey, value);
+ std::string value = base::StringPrintf("%s reason %s",
+ [aName UTF8String], [aReason UTF8String]);
+ base::debug::SetCrashKeyValue(crash_keys::mac::kNSException, value);
// Force crash for selected exceptions to generate crash dumps.
BOOL fatal = NO;
@@ -107,12 +108,12 @@ static IMP gOriginalInitIMP = NULL;
const bool allow = base::mac::GetNSExceptionsAllowed();
if (fatal && !allow) {
LOG(FATAL) << "Someone is trying to raise an exception! "
- << base::SysNSStringToUTF8(value);
+ << value;
} else {
// Make sure that developers see when their code throws
// exceptions.
DCHECK(allow) << "Someone is trying to raise an exception! "
- << base::SysNSStringToUTF8(value);
+ << value;
}
}
@@ -369,7 +370,6 @@ void SwizzleInit() {
// 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 NSString* const kActionKey = @"sendaction";
// If the action is something generic like -commandDispatch:, then
// the tag is essential.
@@ -384,14 +384,13 @@ void SwizzleInit() {
}
NSString* actionString = NSStringFromSelector(anAction);
- NSString* value =
- [NSString stringWithFormat:@"%@ tag %ld sending %@ to %p",
- [sender className],
- static_cast<long>(tag),
- actionString,
- aTarget];
+ std::string value = base::StringPrintf("%s tag %ld sending %s to %p",
+ [[sender className] UTF8String],
+ static_cast<long>(tag),
+ [actionString UTF8String],
+ aTarget);
- base::mac::ScopedCrashKey key(kActionKey, value);
+ base::debug::ScopedCrashKey key(crash_keys::mac::kSendAction, value);
// Certain third-party code, such as print drivers, can still throw
// exceptions and Chromium cannot fix them. This provides a way to
@@ -456,24 +455,22 @@ void SwizzleInit() {
// is tracked because it may be the one which caused the system to
// go off the rails. The last exception thrown is tracked because
// it may be the one most directly associated with the crash.
- static NSString* const kFirstExceptionKey = @"firstexception";
- static NSString* const kFirstExceptionBtKey = @"firstexception_bt";
static BOOL trackedFirstException = NO;
- static NSString* const kLastExceptionKey = @"lastexception";
- static NSString* const kLastExceptionBtKey = @"lastexception_bt";
- NSString* const kExceptionKey =
- trackedFirstException ? kLastExceptionKey : kFirstExceptionKey;
+ const char* const kExceptionKey =
+ trackedFirstException ? crash_keys::mac::kLastNSException
+ : crash_keys::mac::kFirstNSException;
NSString* value = [NSString stringWithFormat:@"%@ reason %@",
[anException name], [anException reason]];
- base::mac::SetCrashKeyValue(kExceptionKey, value);
+ base::debug::SetCrashKeyValue(kExceptionKey, [value UTF8String]);
// Encode the callstack from point of throw.
// TODO(shess): Our swizzle plus the 23-frame limit plus Cocoa
// overhead may make this less than useful. If so, perhaps skip
// some items and/or use two keys.
- NSString* const kExceptionBtKey =
- trackedFirstException ? kLastExceptionBtKey : kFirstExceptionBtKey;
+ const char* const kExceptionBtKey =
+ trackedFirstException ? crash_keys::mac::kLastNSExceptionTrace
+ : crash_keys::mac::kFirstNSExceptionTrace;
NSArray* addressArray = [anException callStackReturnAddresses];
NSUInteger addressCount = [addressArray count];
if (addressCount) {
@@ -487,10 +484,10 @@ void SwizzleInit() {
addresses[i] = reinterpret_cast<void*>(
[[addressArray objectAtIndex:i] unsignedIntegerValue]);
}
- base::mac::SetCrashKeyFromAddresses(
+ base::debug::SetCrashKeyFromAddresses(
kExceptionBtKey, addresses, static_cast<size_t>(addressCount));
} else {
- base::mac::ClearCrashKey(kExceptionBtKey);
+ base::debug::ClearCrashKey(kExceptionBtKey);
}
trackedFirstException = YES;
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 2f715b5..4665614 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -118,6 +118,8 @@
'common/content_settings_pattern_parser.cc',
'common/content_settings_pattern_parser.h',
'common/content_settings_types.h',
+ 'common/crash_keys.cc',
+ 'common/crash_keys.h',
'common/custom_handlers/protocol_handler.cc',
'common/custom_handlers/protocol_handler.h',
'common/descriptors_android.h',
diff --git a/chrome/common/crash_keys.cc b/chrome/common/crash_keys.cc
new file mode 100644
index 0000000..55b0864
--- /dev/null
+++ b/chrome/common/crash_keys.cc
@@ -0,0 +1,26 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/crash_keys.h"
+
+namespace crash_keys {
+
+namespace mac {
+
+const char kFirstNSException[] = "firstexception";
+const char kFirstNSExceptionTrace[] = "firstexception_bt";
+
+const char kLastNSException[] = "lastexception";
+const char kLastNSExceptionTrace[] = "lastexception_bt";
+
+const char kNSException[] = "nsexception";
+
+const char kSendAction[] = "sendaction";
+
+const char kZombie[] = "zombie";
+const char kZombieTrace[] = "zombie_dealloc_bt";
+
+} // namespace mac
+
+} // namespace crash_keys
diff --git a/chrome/common/crash_keys.h b/chrome/common/crash_keys.h
new file mode 100644
index 0000000..34f2589
--- /dev/null
+++ b/chrome/common/crash_keys.h
@@ -0,0 +1,38 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_CRASH_KEYS_H_
+#define CHROME_COMMON_CRASH_KEYS_H_
+
+namespace crash_keys {
+
+// Crash Key Name Constants ////////////////////////////////////////////////////
+
+namespace mac {
+
+// Used to report the first Cocoa/Mac NSException and its backtrace.
+extern const char kFirstNSException[];
+extern const char kFirstNSExceptionTrace[];
+
+// Used to report the last Cocoa/Mac NSException and its backtrace.
+extern const char kLastNSException[];
+extern const char kLastNSExceptionTrace[];
+
+// Records the current NSException as it's being created.
+extern const char kNSException[];
+
+// In the CrApplication, records information about the current event's
+// target-action.
+extern const char kSendAction[];
+
+// Records Cocoa zombie/used-after-freed objects that resulted in a
+// deliberate crash.
+extern const char kZombie[];
+extern const char kZombieTrace[];
+
+} // namespace mac
+
+} // namespace crash_keys
+
+#endif // CHROME_COMMON_CRASH_KEYS_H_
diff --git a/chrome/common/mac/objc_zombie.mm b/chrome/common/mac/objc_zombie.mm
index 0f01a52..a0cd90e 100644
--- a/chrome/common/mac/objc_zombie.mm
+++ b/chrome/common/mac/objc_zombie.mm
@@ -11,14 +11,15 @@
#include <algorithm>
+#include "base/debug/crash_logging.h"
#include "base/debug/stack_trace.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
-#include "base/mac/crash_logging.h"
+#include "base/stringprintf.h"
#include "base/synchronization/lock.h"
+#include "chrome/common/crash_keys.h"
#import "chrome/common/mac/objc_method_swizzle.h"
-
#if !defined(OS_IOS) && (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_6)
// Apparently objc/runtime.h doesn't define this with the 10.6 SDK yet.
// The docs say it exists since 10.6 however.
@@ -204,21 +205,20 @@ void ZombieObjectCrash(id object, SEL aSelector, SEL viaSelector) {
}
const char* wasaName = (wasa ? class_getName(wasa) : "<unknown>");
- NSString* aString =
- [NSString stringWithFormat:@"Zombie <%s: %p> received -%s",
- wasaName, object, sel_getName(aSelector)];
+ std::string aString = base::StringPrintf("Zombie <%s: %p> received -%s",
+ wasaName, object, sel_getName(aSelector));
if (viaSelector != NULL) {
const char* viaName = sel_getName(viaSelector);
- aString = [aString stringByAppendingFormat:@" (via -%s)", viaName];
+ base::StringAppendF(&aString, " (via -%s)", viaName);
}
// Set a value for breakpad to report.
- base::mac::SetCrashKeyValue(@"zombie", aString);
+ base::debug::SetCrashKeyValue(crash_keys::mac::kZombie, aString);
// Encode trace into a breakpad key.
if (found) {
- base::mac::SetCrashKeyFromAddresses(
- @"zombie_dealloc_bt", record.trace, record.traceDepth);
+ base::debug::SetCrashKeyFromAddresses(
+ crash_keys::mac::kZombieTrace, record.trace, record.traceDepth);
}
// Log -dealloc backtrace in debug builds then crash with a useful
@@ -228,7 +228,7 @@ void ZombieObjectCrash(id object, SEL aSelector, SEL viaSelector) {
} else {
DLOG(INFO) << "Unable to generate backtrace from -dealloc.";
}
- DLOG(FATAL) << [aString UTF8String];
+ DLOG(FATAL) << aString;
// This is how about:crash is implemented. Using instead of
// |base::debug::BreakDebugger()| or |LOG(FATAL)| to make the top of
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 7880b8b..152617e 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -8,15 +8,16 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/debug/crash_logging.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
-#include "base/mac/crash_logging.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
#import "base/mac/scoped_nsautorelease_pool.h"
#import "base/memory/scoped_nsobject.h"
#include "base/message_loop.h"
#include "base/metrics/histogram.h"
+#include "base/stringprintf.h"
#include "base/string_util.h"
#include "base/sys_info.h"
#include "base/sys_string_conversions.h"
@@ -1044,16 +1045,16 @@ bool RenderWidgetHostViewMac::CompositorSwapBuffers(uint64 surface_handle,
// http://crbug.com/148882
NSWindow* window = [cocoa_view_ window];
if ([window windowNumber] <= 0) {
- NSString* const kCrashKey = @"rwhvm_window";
+ const char* const kCrashKey = "rwhvm_window";
if (!window) {
- base::mac::SetCrashKeyValue(kCrashKey, @"Missing window");
+ base::debug::SetCrashKeyValue(kCrashKey, "Missing window");
} else {
- NSString* value =
- [NSString stringWithFormat:@"window %s delegate %s controller %s",
- object_getClassName(window),
- object_getClassName([window delegate]),
- object_getClassName([window windowController])];
- base::mac::SetCrashKeyValue(kCrashKey, value);
+ std::string value =
+ base::StringPrintf("window %s delegate %s controller %s",
+ object_getClassName(window),
+ object_getClassName([window delegate]),
+ object_getClassName([window windowController]));
+ base::debug::SetCrashKeyValue(kCrashKey, value);
}
return true;
diff --git a/content/renderer/plugin_channel_host.cc b/content/renderer/plugin_channel_host.cc
index 5d251b6..b9450b60 100644
--- a/content/renderer/plugin_channel_host.cc
+++ b/content/renderer/plugin_channel_host.cc
@@ -27,8 +27,8 @@
// the backtrace from any such nested call should be sufficient to
// drive a repro.
#if defined(OS_MACOSX)
+#include "base/debug/crash_logging.h"
#include "base/debug/stack_trace.h"
-#include "base/mac/crash_logging.h"
#include "base/sys_string_conversions.h"
namespace {
@@ -169,8 +169,8 @@ void PluginChannelHost::RemoveRoute(int route_id) {
base::debug::StackTrace trace;
size_t count = 0;
const void* const* addresses = trace.Addresses(&count);
- base::mac::SetCrashKeyFromAddresses(
- base::SysUTF8ToNSString(kRemoveRouteTraceKey), addresses, count);
+ base::debug::SetCrashKeyFromAddresses(
+ kRemoveRouteTraceKey, addresses, count);
}
#endif
@@ -214,8 +214,8 @@ void PluginChannelHost::OnChannelError() {
base::debug::StackTrace trace;
size_t count = 0;
const void* const* addresses = trace.Addresses(&count);
- base::mac::SetCrashKeyFromAddresses(
- base::SysUTF8ToNSString(kChannelErrorTraceKey), addresses, count);
+ base::debug::SetCrashKeyFromAddresses(
+ kChannelErrorTraceKey, addresses, count);
}
#endif
diff --git a/content/renderer/renderer_main_platform_delegate_mac.mm b/content/renderer/renderer_main_platform_delegate_mac.mm
index 1e87401..96cde25 100644
--- a/content/renderer/renderer_main_platform_delegate_mac.mm
+++ b/content/renderer/renderer_main_platform_delegate_mac.mm
@@ -11,7 +11,6 @@
#include "base/command_line.h"
#include "base/logging.h"
#import "base/mac/foundation_util.h"
-#import "base/mac/crash_logging.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/sys_string_conversions.h"
#include "content/common/sandbox_mac.h"
diff --git a/media/video/capture/mac/video_capture_device_qtkit_mac.mm b/media/video/capture/mac/video_capture_device_qtkit_mac.mm
index 0318f5f..3c405f4 100644
--- a/media/video/capture/mac/video_capture_device_qtkit_mac.mm
+++ b/media/video/capture/mac/video_capture_device_qtkit_mac.mm
@@ -6,8 +6,8 @@
#import <QTKit/QTKit.h>
+#include "base/debug/crash_logging.h"
#include "base/logging.h"
-#include "base/mac/crash_logging.h"
#include "media/video/capture/mac/video_capture_device_mac.h"
#include "media/video/capture/video_capture_device.h"
#include "media/video/capture/video_capture_types.h"
@@ -99,7 +99,7 @@
// This key can be used to check if video capture code was related to a
// particular crash.
- base::mac::SetCrashKeyValue(@"VideoCaptureDeviceQTKit", @"OpenedDevice");
+ base::debug::SetCrashKeyValue("VideoCaptureDeviceQTKit", "OpenedDevice");
return YES;
} else {