aw: Add webview crash keys to minidumps.
This enables the crash key infrastructure for WebView minidumps
and also populates the GPU related crash keys.
BUG=655614
Review-Url: https://codereview.chromium.org/2681343002
Cr-Commit-Position: refs/heads/master@{#449686}
diff --git a/android_webview/BUILD.gn b/android_webview/BUILD.gn
index 2d3b3cf..1f47b9a 100644
--- a/android_webview/BUILD.gn
+++ b/android_webview/BUILD.gn
@@ -493,6 +493,8 @@
"common/aw_switches.h",
"common/crash_reporter/aw_microdump_crash_reporter.cc",
"common/crash_reporter/aw_microdump_crash_reporter.h",
+ "common/crash_reporter/crash_keys.cc",
+ "common/crash_reporter/crash_keys.h",
"common/devtools_instrumentation.h",
"common/render_view_messages.cc",
"common/render_view_messages.h",
diff --git a/android_webview/common/aw_content_client.cc b/android_webview/common/aw_content_client.cc
index 6acfe16..353da6a 100644
--- a/android_webview/common/aw_content_client.cc
+++ b/android_webview/common/aw_content_client.cc
@@ -7,8 +7,10 @@
#include "android_webview/common/aw_media_client_android.h"
#include "android_webview/common/aw_resource.h"
#include "android_webview/common/aw_version_info_values.h"
+#include "android_webview/common/crash_reporter/crash_keys.h"
#include "android_webview/common/url_constants.h"
#include "base/command_line.h"
+#include "base/debug/crash_logging.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/user_agent.h"
#include "gpu/config/gpu_info.h"
@@ -80,6 +82,15 @@
gpu_info.gl_renderer;
std::replace_if(gpu_fingerprint_.begin(), gpu_fingerprint_.end(),
[](char c) { return !::isprint(c); }, '_');
+
+ base::debug::SetCrashKeyValue(crash_keys::kGPUDriverVersion,
+ gpu_info.driver_version);
+ base::debug::SetCrashKeyValue(crash_keys::kGPUPixelShaderVersion,
+ gpu_info.pixel_shader_version);
+ base::debug::SetCrashKeyValue(crash_keys::kGPUVertexShaderVersion,
+ gpu_info.vertex_shader_version);
+ base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor);
+ base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer);
}
bool AwContentClient::UsingSynchronousCompositing() {
diff --git a/android_webview/common/crash_reporter/aw_microdump_crash_reporter.cc b/android_webview/common/crash_reporter/aw_microdump_crash_reporter.cc
index 059645d..3cf45d6bd 100644
--- a/android_webview/common/crash_reporter/aw_microdump_crash_reporter.cc
+++ b/android_webview/common/crash_reporter/aw_microdump_crash_reporter.cc
@@ -7,6 +7,7 @@
#include "android_webview/common/aw_descriptors.h"
#include "android_webview/common/aw_paths.h"
#include "android_webview/common/aw_version_info_values.h"
+#include "android_webview/common/crash_reporter/crash_keys.h"
#include "base/android/build_info.h"
#include "base/base_paths_android.h"
#include "base/debug/dump_without_crashing.h"
@@ -34,6 +35,8 @@
void set_crash_signal_fd(int fd) { crash_signal_fd_ = fd; }
// crash_reporter::CrashReporterClient implementation.
+ size_t RegisterCrashKeys() override;
+
bool IsRunningUnattended() override { return false; }
bool GetCollectStatsConsent() override { return false; }
@@ -67,6 +70,10 @@
DISALLOW_COPY_AND_ASSIGN(AwCrashReporterClient);
};
+size_t AwCrashReporterClient::RegisterCrashKeys() {
+ return crash_keys::RegisterWebViewCrashKeys();
+}
+
base::LazyInstance<AwCrashReporterClient>::Leaky g_crash_reporter_client =
LAZY_INSTANCE_INITIALIZER;
diff --git a/android_webview/common/crash_reporter/crash_keys.cc b/android_webview/common/crash_reporter/crash_keys.cc
new file mode 100644
index 0000000..cd82afc3
--- /dev/null
+++ b/android_webview/common/crash_reporter/crash_keys.cc
@@ -0,0 +1,44 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "android_webview/common/crash_reporter/crash_keys.h"
+
+#include "base/debug/crash_logging.h"
+#include "components/crash/core/common/crash_keys.h"
+
+using namespace crash_keys;
+
+namespace android_webview {
+namespace crash_keys {
+
+const char kGPUDriverVersion[] = "gpu-driver";
+const char kGPUPixelShaderVersion[] = "gpu-psver";
+const char kGPUVertexShaderVersion[] = "gpu-vsver";
+const char kGPUVendor[] = "gpu-gl-vendor";
+const char kGPURenderer[] = "gpu-gl-renderer";
+
+size_t RegisterWebViewCrashKeys() {
+ base::debug::CrashKey fixed_keys[] = {
+ { kGPUDriverVersion, kSmallSize },
+ { kGPUPixelShaderVersion, kSmallSize },
+ { kGPUVertexShaderVersion, kSmallSize },
+ { kGPUVendor, kSmallSize },
+ { kGPURenderer, kSmallSize },
+
+ // content/:
+ { "bad_message_reason", kSmallSize },
+ { "discardable-memory-allocated", kSmallSize },
+ { "discardable-memory-free", kSmallSize },
+ { "mojo-message-error", kMediumSize },
+ { "total-discardable-memory-allocated", kSmallSize },
+ };
+
+ std::vector<base::debug::CrashKey> keys(fixed_keys,
+ fixed_keys + arraysize(fixed_keys));
+
+ return base::debug::InitCrashKeys(&keys.at(0), keys.size(), kChunkMaxLength);
+}
+}
+
+} // namespace crash_keys
diff --git a/android_webview/common/crash_reporter/crash_keys.h b/android_webview/common/crash_reporter/crash_keys.h
new file mode 100644
index 0000000..03b2e2a4
--- /dev/null
+++ b/android_webview/common/crash_reporter/crash_keys.h
@@ -0,0 +1,30 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ANDROID_WEBVIEW_COMMON_CRASH_KEYS_H_
+#define ANDROID_WEBVIEW_COMMON_CRASH_KEYS_H_
+
+#include <stddef.h>
+
+namespace android_webview {
+namespace crash_keys {
+
+// Registers all of the potential crash keys that can be sent to the crash
+// reporting server. Returns the size of the union of all keys.
+size_t RegisterWebViewCrashKeys();
+
+// Crash Key Name Constants ////////////////////////////////////////////////////
+
+// GPU information.
+extern const char kGPUDriverVersion[];
+extern const char kGPUPixelShaderVersion[];
+extern const char kGPUVertexShaderVersion[];
+extern const char kGPUVendor[];
+extern const char kGPURenderer[];
+
+
+} // namespace crash_keys
+} // namespace android_webview
+
+#endif // ANDROID_WEBVIEW_COMMON_CRASH_KEYS_H_