Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1698)

Unified Diff: base/mac/crash_logging.mm

Issue 10408004: [Mac] Log stack trace for CHECK in bug 97285. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Forgot an OS_MACOSX check. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/mac/crash_logging.h ('k') | chrome/common/mac/objc_zombie.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac/crash_logging.mm
diff --git a/base/mac/crash_logging.mm b/base/mac/crash_logging.mm
index ce0db392a8239c9b991a9db35395fb1a81d6dfd2..89f5fba894d6ce7a06d7ffa3541afaca65057cd4 100644
--- a/base/mac/crash_logging.mm
+++ b/base/mac/crash_logging.mm
@@ -6,6 +6,8 @@
#import <Foundation/Foundation.h>
+#include "base/logging.h"
+
namespace base {
namespace mac {
@@ -28,6 +30,30 @@ void ClearCrashKey(NSString* key) {
g_clear_key_func(key);
}
+void SetCrashKeyFromAddresses(NSString* key,
+ const void* const* addresses,
+ size_t count) {
+ NSString* value = @"<null>";
+ if (addresses && count) {
+ const size_t kBreakpadValueMax = 255;
+
+ NSMutableArray* hexBacktrace = [NSMutableArray arrayWithCapacity:count];
+ size_t length = 0;
+ for (size_t i = 0; i < count; ++i) {
+ NSString* s = [NSString stringWithFormat:@"%p", addresses[i]];
+ length += 1 + [s length];
+ if (length > kBreakpadValueMax)
+ break;
+ [hexBacktrace addObject:s];
+ }
+ value = [hexBacktrace componentsJoinedByString:@" "];
+
+ // Warn someone if this exceeds the breakpad limits.
+ DCHECK_LE(strlen([value UTF8String]), kBreakpadValueMax);
+ }
+ base::mac::SetCrashKeyValue(key, value);
+}
+
ScopedCrashKey::ScopedCrashKey(NSString* key, NSString* value)
: crash_key_([key retain]) {
if (g_set_key_func)
« no previous file with comments | « base/mac/crash_logging.h ('k') | chrome/common/mac/objc_zombie.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698