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

Unified Diff: chrome/app/breakpad_mac.mm

Issue 8401018: [Mac] Log CHECK() file, line and message into breakpad. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mark comments. Created 9 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/breakpad_mac.mm
diff --git a/chrome/app/breakpad_mac.mm b/chrome/app/breakpad_mac.mm
index f078271683fa448de75f40818ed7a9491d7ab3ac..40966f51c7e3f9fd486afac3e24c9a9cc98a4cbe 100644
--- a/chrome/app/breakpad_mac.mm
+++ b/chrome/app/breakpad_mac.mm
@@ -7,6 +7,7 @@
#include <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
+#include "base/auto_reset.h"
#include "base/base_switches.h"
#import "base/basictypes.h"
#include "base/command_line.h"
@@ -50,6 +51,40 @@ void ClearCrashKeyValue(NSString* key) {
BreakpadRemoveUploadParameter(gBreakpadRef, key);
}
+bool FatalMessageHandler(int severity, const char* file, int line,
+ size_t message_start, const std::string& str) {
+ // Do not handle non-FATAL.
+ if (severity != logging::LOG_FATAL)
+ return false;
+
+ // In case of OOM condition, this code could be reentered when
+ // constructing and storing the key. Using a static is not
+ // thread-safe, but if multiple threads are in the process of a
+ // fatal crash at the same time, this should work.
+ static bool guarded = false;
+ if (guarded)
+ return false;
+
+ AutoReset<bool> guard(&guarded, true);
+
+ // Only log last path component. This matches logging.cc.
+ if (file) {
+ const char* slash = strrchr(file, '/');
+ if (slash)
+ file = slash + 1;
+ }
+
+ NSString* fatal_key = @"LOG_FATAL";
+ NSString* fatal_value =
+ [NSString stringWithFormat:@"%s:%d: %s",
+ file, line, str.c_str() + message_start];
+ SetCrashKeyValue(fatal_key, fatal_value);
+
+ // Rather than including the code to force the crash here, allow the
+ // caller to do it.
+ return false;
+}
+
} // namespace
bool IsCrashReporterEnabled() {
@@ -176,7 +211,9 @@ void InitCrashReporter() {
std::string guid =
command_line->GetSwitchValueASCII(switches::kEnableCrashReporter);
child_process_logging::SetClientId(guid);
- }
+ }
+
+ logging::SetLogMessageHandler(&FatalMessageHandler);
}
void InitCrashProcessInfo() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698