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

Side by Side Diff: android_webview/crash_reporter/aw_microdump_crash_reporter.cc

Issue 1525023003: Distinguish in the browser between renderer crashes and kills (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finalized, RFC Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "android_webview/crash_reporter/aw_microdump_crash_reporter.h" 5 #include "android_webview/crash_reporter/aw_microdump_crash_reporter.h"
6 6
7 #include "android_webview/common/aw_version_info_values.h" 7 #include "android_webview/common/aw_version_info_values.h"
8 #include "base/debug/dump_without_crashing.h" 8 #include "base/debug/dump_without_crashing.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/scoped_native_library.h" 11 #include "base/scoped_native_library.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "components/crash/content/app/breakpad_linux.h" 14 #include "components/crash/content/app/breakpad_linux.h"
15 #include "components/crash/content/app/crash_reporter_client.h" 15 #include "components/crash/content/app/crash_reporter_client.h"
16 #include "content/public/common/content_switches.h"
16 17
17 namespace android_webview { 18 namespace android_webview {
18 namespace crash_reporter { 19 namespace crash_reporter {
19 20
20 namespace { 21 namespace {
21 22
22 class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient { 23 class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient {
23 public: 24 public:
24 AwCrashReporterClient() : dump_fd_(-1) {} 25 AwCrashReporterClient() : dump_fd_(-1) {}
25 26
27 // Does not use lock, can only be called immediately after creation.
28 void set_crash_signal_fd(int fd) { dump_fd_ = fd; }
29
26 // crash_reporter::CrashReporterClient implementation. 30 // crash_reporter::CrashReporterClient implementation.
27 bool IsRunningUnattended() override { return false; } 31 bool IsRunningUnattended() override { return false; }
28 bool GetCollectStatsConsent() override { return false; } 32 bool GetCollectStatsConsent() override { return false; }
29 33
30 void GetProductNameAndVersion(const char** product_name, 34 void GetProductNameAndVersion(const char** product_name,
31 const char** version) override { 35 const char** version) override {
32 *product_name = "WebView"; 36 *product_name = "WebView";
33 *version = PRODUCT_VERSION; 37 *version = PRODUCT_VERSION;
34 } 38 }
35 // Microdumps are always enabled in WebView builds, conversely to what happens 39 // Microdumps are always enabled in WebView builds, conversely to what happens
36 // in the case of the other Chrome for Android builds (where they are enabled 40 // in the case of the other Chrome for Android builds (where they are enabled
37 // only when NO_UNWIND_TABLES == 1). 41 // only when NO_UNWIND_TABLES == 1).
38 bool ShouldEnableBreakpadMicrodumps() override { return true; } 42 bool ShouldEnableBreakpadMicrodumps() override { return true; }
39 43
40 int GetAndroidMinidumpDescriptor() override { return dump_fd_; } 44 int GetAndroidMinidumpDescriptor() override { return dump_fd_; }
41 45
42 bool DumpWithoutCrashingToFd(int fd) { 46 bool DumpWithoutCrashingToFd(int fd) {
47 DCHECK(dump_fd_ == -1);
Torne 2015/12/16 14:48:35 Seems like we should have something at a higher le
mnaganov (inactive) 2015/12/16 19:10:12 I've already done that in my previous patch: https
43 base::AutoLock lock(dump_lock_); 48 base::AutoLock lock(dump_lock_);
44 dump_fd_ = fd; 49 dump_fd_ = fd;
45 base::debug::DumpWithoutCrashing(); 50 base::debug::DumpWithoutCrashing();
46 dump_fd_ = -1; 51 dump_fd_ = -1;
47 return true; 52 return true;
48 } 53 }
49 54
50 private: 55 private:
51 int dump_fd_; 56 int dump_fd_;
52 base::Lock dump_lock_; 57 base::Lock dump_lock_;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 return true; 107 return true;
103 } else { 108 } else {
104 DLOG(WARNING) << "Native bridge ver=" << version << "; too low"; 109 DLOG(WARNING) << "Native bridge ver=" << version << "; too low";
105 return false; 110 return false;
106 } 111 }
107 } 112 }
108 #endif 113 #endif
109 114
110 } // namespace 115 } // namespace
111 116
112 void EnableMicrodumpCrashReporter(const std::string& process_type) { 117 void EnableMicrodumpCrashReporter(const std::string& process_type,
118 int crash_signal_fd) {
113 if (g_enabled) { 119 if (g_enabled) {
114 NOTREACHED() << "EnableMicrodumpCrashReporter called more than once"; 120 NOTREACHED() << "EnableMicrodumpCrashReporter called more than once";
115 return; 121 return;
116 } 122 }
117 123
118 #if defined(ARCH_CPU_X86_FAMILY) 124 #if defined(ARCH_CPU_X86_FAMILY)
119 if (!SafeToUseSignalHandler()) { 125 if (!SafeToUseSignalHandler()) {
120 LOG(WARNING) << "Can't use breakpad to handle WebView crashes"; 126 LOG(WARNING) << "Can't use breakpad to handle WebView crashes";
121 return; 127 return;
122 } 128 }
123 #endif 129 #endif
124 130
125 ::crash_reporter::SetCrashReporterClient(g_crash_reporter_client.Pointer()); 131 AwCrashReporterClient* client = g_crash_reporter_client.Pointer();
132 if (process_type == switches::kRendererProcess && crash_signal_fd != -1) {
133 client->set_crash_signal_fd(crash_signal_fd);
134 }
135 ::crash_reporter::SetCrashReporterClient(client);
126 136
127 breakpad::InitMicrodumpCrashHandlerIfNecessary(process_type); 137 breakpad::InitMicrodumpCrashHandlerIfNecessary(process_type);
128 g_enabled = true; 138 g_enabled = true;
129 } 139 }
130 140
131 void AddGpuFingerprintToMicrodumpCrashHandler( 141 void AddGpuFingerprintToMicrodumpCrashHandler(
132 const std::string& gpu_fingerprint) { 142 const std::string& gpu_fingerprint) {
133 breakpad::AddGpuFingerprintToMicrodumpCrashHandler(gpu_fingerprint); 143 breakpad::AddGpuFingerprintToMicrodumpCrashHandler(gpu_fingerprint);
134 } 144 }
135 145
136 bool DumpWithoutCrashingToFd(int fd) { 146 bool DumpWithoutCrashingToFd(int fd) {
137 return g_crash_reporter_client.Pointer()->DumpWithoutCrashingToFd(fd); 147 return g_crash_reporter_client.Pointer()->DumpWithoutCrashingToFd(fd);
138 } 148 }
139 149
140 } // namespace crash_reporter 150 } // namespace crash_reporter
141 } // namespace android_webview 151 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698