OLD | NEW |
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/common/crash_reporter/aw_microdump_crash_reporter.h" | 5 #include "android_webview/common/crash_reporter/aw_microdump_crash_reporter.h" |
6 | 6 |
7 #include "android_webview/common/aw_descriptors.h" | 7 #include "android_webview/common/aw_descriptors.h" |
8 #include "android_webview/common/aw_paths.h" | 8 #include "android_webview/common/aw_paths.h" |
9 #include "android_webview/common/aw_version_info_values.h" | 9 #include "android_webview/common/aw_version_info_values.h" |
10 #include "android_webview/common/crash_reporter/crash_keys.h" | 10 #include "android_webview/common/crash_reporter/crash_keys.h" |
11 #include "base/android/build_info.h" | 11 #include "base/android/build_info.h" |
12 #include "base/base_paths_android.h" | 12 #include "base/base_paths_android.h" |
| 13 #include "base/debug/crash_logging.h" |
13 #include "base/debug/dump_without_crashing.h" | 14 #include "base/debug/dump_without_crashing.h" |
14 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
15 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
16 #include "base/path_service.h" | 17 #include "base/path_service.h" |
17 #include "base/scoped_native_library.h" | 18 #include "base/scoped_native_library.h" |
18 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
20 #include "components/crash/content/app/breakpad_linux.h" | 21 #include "components/crash/content/app/breakpad_linux.h" |
21 #include "components/crash/content/app/crash_reporter_client.h" | 22 #include "components/crash/content/app/crash_reporter_client.h" |
22 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
23 | 24 |
24 namespace android_webview { | 25 namespace android_webview { |
25 namespace crash_reporter { | 26 namespace crash_reporter { |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient { | 30 class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient { |
30 public: | 31 public: |
31 AwCrashReporterClient() | 32 AwCrashReporterClient() |
32 : dump_fd_(kAndroidMinidumpDescriptor), crash_signal_fd_(-1) {} | 33 : dump_fd_(kAndroidMinidumpDescriptor), crash_signal_fd_(-1) {} |
33 | 34 |
34 // Does not use lock, can only be called immediately after creation. | 35 // Does not use lock, can only be called immediately after creation. |
35 void set_crash_signal_fd(int fd) { crash_signal_fd_ = fd; } | 36 void set_crash_signal_fd(int fd) { crash_signal_fd_ = fd; } |
36 | 37 |
37 // crash_reporter::CrashReporterClient implementation. | 38 // crash_reporter::CrashReporterClient implementation. |
38 size_t RegisterCrashKeys() override; | 39 size_t RegisterCrashKeys() override; |
| 40 std::vector<base::debug::CrashKey> GetWhiteListedCrashKeys() override; |
39 | 41 |
40 bool IsRunningUnattended() override { return false; } | 42 bool IsRunningUnattended() override { return false; } |
41 bool GetCollectStatsConsent() override { | 43 bool GetCollectStatsConsent() override { |
42 #if defined(GOOGLE_CHROME_BUILD) | 44 #if defined(GOOGLE_CHROME_BUILD) |
43 // TODO(gsennton): Enabling minidump-generation unconditionally means we | 45 // TODO(gsennton): Enabling minidump-generation unconditionally means we |
44 // will generate minidumps even if the user doesn't consent to minidump | 46 // will generate minidumps even if the user doesn't consent to minidump |
45 // uploads. However, we will check user-consent before uploading any | 47 // uploads. However, we will check user-consent before uploading any |
46 // minidumps, if we do not have user consent we will delete the minidumps. | 48 // minidumps, if we do not have user consent we will delete the minidumps. |
47 // We should investigate whether we can avoid generating minidumps | 49 // We should investigate whether we can avoid generating minidumps |
48 // altogether if we don't have user consent, see crbug.com/692485 | 50 // altogether if we don't have user consent, see crbug.com/692485 |
(...skipping 30 matching lines...) Expand all Loading... |
79 private: | 81 private: |
80 int dump_fd_; | 82 int dump_fd_; |
81 int crash_signal_fd_; | 83 int crash_signal_fd_; |
82 DISALLOW_COPY_AND_ASSIGN(AwCrashReporterClient); | 84 DISALLOW_COPY_AND_ASSIGN(AwCrashReporterClient); |
83 }; | 85 }; |
84 | 86 |
85 size_t AwCrashReporterClient::RegisterCrashKeys() { | 87 size_t AwCrashReporterClient::RegisterCrashKeys() { |
86 return crash_keys::RegisterWebViewCrashKeys(); | 88 return crash_keys::RegisterWebViewCrashKeys(); |
87 } | 89 } |
88 | 90 |
| 91 std::vector<base::debug::CrashKey> |
| 92 AwCrashReporterClient::GetWhiteListedCrashKeys() { |
| 93 return crash_keys::GetWhiteListedWebViewCrashKeys(); |
| 94 } |
| 95 |
89 base::LazyInstance<AwCrashReporterClient>::Leaky g_crash_reporter_client = | 96 base::LazyInstance<AwCrashReporterClient>::Leaky g_crash_reporter_client = |
90 LAZY_INSTANCE_INITIALIZER; | 97 LAZY_INSTANCE_INITIALIZER; |
91 | 98 |
92 bool g_enabled = false; | 99 bool g_enabled = false; |
93 | 100 |
94 #if defined(ARCH_CPU_X86_FAMILY) | 101 #if defined(ARCH_CPU_X86_FAMILY) |
95 bool SafeToUseSignalHandler() { | 102 bool SafeToUseSignalHandler() { |
96 // N+ shared library namespacing means that we are unable to dlopen | 103 // N+ shared library namespacing means that we are unable to dlopen |
97 // libnativebridge (because it isn't in the NDK). However we know | 104 // libnativebridge (because it isn't in the NDK). However we know |
98 // that, were we able to, the tests below would pass, so just return | 105 // that, were we able to, the tests below would pass, so just return |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 sanitization_info.address_within_principal_mapping = | 182 sanitization_info.address_within_principal_mapping = |
176 reinterpret_cast<uintptr_t>(&EnableCrashReporter); | 183 reinterpret_cast<uintptr_t>(&EnableCrashReporter); |
177 #endif // defined(COMPONENT_BUILD) | 184 #endif // defined(COMPONENT_BUILD) |
178 | 185 |
179 bool is_browser_process = | 186 bool is_browser_process = |
180 process_type.empty() || | 187 process_type.empty() || |
181 process_type == breakpad::kWebViewSingleProcessType || | 188 process_type == breakpad::kWebViewSingleProcessType || |
182 process_type == breakpad::kBrowserProcessType; | 189 process_type == breakpad::kBrowserProcessType; |
183 if (is_browser_process) { | 190 if (is_browser_process) { |
184 breakpad::InitCrashReporter("", sanitization_info); | 191 breakpad::InitCrashReporter("", sanitization_info); |
| 192 base::debug::SetCrashKeyValue("AW_DEBUG_KEY", "AW_DEBUG_VALUE"); |
185 } else { | 193 } else { |
186 breakpad::InitNonBrowserCrashReporterForAndroid(process_type, | 194 breakpad::InitNonBrowserCrashReporterForAndroid(process_type, |
187 sanitization_info); | 195 sanitization_info); |
188 } | 196 } |
189 g_enabled = true; | 197 g_enabled = true; |
190 } | 198 } |
191 | 199 |
192 bool GetCrashDumpLocation(base::FilePath* crash_dir) { | 200 bool GetCrashDumpLocation(base::FilePath* crash_dir) { |
193 return g_crash_reporter_client.Get().GetCrashDumpLocation(crash_dir); | 201 return g_crash_reporter_client.Get().GetCrashDumpLocation(crash_dir); |
194 } | 202 } |
(...skipping 10 matching lines...) Expand all Loading... |
205 bool IsCrashReporterEnabled() { | 213 bool IsCrashReporterEnabled() { |
206 return breakpad::IsCrashReporterEnabled(); | 214 return breakpad::IsCrashReporterEnabled(); |
207 } | 215 } |
208 | 216 |
209 void SuppressDumpGeneration() { | 217 void SuppressDumpGeneration() { |
210 breakpad::SuppressDumpGeneration(); | 218 breakpad::SuppressDumpGeneration(); |
211 } | 219 } |
212 | 220 |
213 } // namespace crash_reporter | 221 } // namespace crash_reporter |
214 } // namespace android_webview | 222 } // namespace android_webview |
OLD | NEW |