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

Unified Diff: components/crash/content/app/crashpad.cc

Issue 2377963002: restore LOG_FATAL crash key on windows
Patch Set: move CrashMessageHandler out of base Created 4 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 | « chrome/common/crash_keys.cc ('k') | components/crash/core/common/crash_keys.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/crash/content/app/crashpad.cc
diff --git a/components/crash/content/app/crashpad.cc b/components/crash/content/app/crashpad.cc
index 76f67348ab0fcb6cd0e7ed3412a410d31be569da..060904b17f0f0dcdf832270e7d0c6e1920156660 100644
--- a/components/crash/content/app/crashpad.cc
+++ b/components/crash/content/app/crashpad.cc
@@ -52,42 +52,17 @@ void ClearCrashKey(const base::StringPiece& key) {
g_simple_string_dictionary->RemoveKey(key.data());
}
-bool LogMessageHandler(int severity,
- const char* file,
- int line,
- size_t message_start,
- const std::string& string) {
- // Only handle FATAL.
- if (severity != logging::LOG_FATAL) {
- return false;
- }
-
+// Please keep synced with child_process_logging.cc.
+void CrashMessageHandler(const std::string& message) {
// In case of an out-of-memory 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.
+ // 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;
- }
- base::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;
- }
+ if (!guarded) {
+ base::AutoReset<bool> guard(&guarded, true);
+ SetCrashKeyValue("LOG_FATAL", message);
}
-
- CHECK_LE(message_start, string.size());
- std::string message = base::StringPrintf("%s:%d: %s", file, line,
- string.c_str() + message_start);
- SetCrashKeyValue("LOG_FATAL", message);
-
- // Rather than including the code to force the crash here, allow the caller to
- // do it.
- return false;
}
void DumpWithoutCrashing() {
@@ -154,6 +129,8 @@ void InitializeCrashpadImpl(bool initial_client,
// On Windows chrome_elf registers crash keys. This should work identically
// for component and non component builds.
base::debug::SetCrashKeyReportingFunctions(SetCrashKeyValue, ClearCrashKey);
+ logging::SetCrashMessageHandler(CrashMessageHandler);
+
crash_reporter_client->RegisterCrashKeys();
SetCrashKeyValue("ptype", browser_process ? base::StringPiece("browser")
@@ -164,8 +141,6 @@ void InitializeCrashpadImpl(bool initial_client,
SetCrashKeyValue("pid", base::IntToString(::GetCurrentProcessId()));
#endif
- logging::SetLogMessageHandler(LogMessageHandler);
-
// If clients called CRASHPAD_SIMULATE_CRASH() instead of
// base::debug::DumpWithoutCrashing(), these dumps would appear as crashes in
// the correct function, at the correct file and line. This would be
« no previous file with comments | « chrome/common/crash_keys.cc ('k') | components/crash/core/common/crash_keys.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698