Skip to content

Commit

Permalink
crash_keys: Convert keys in //content to the new API.
Browse files Browse the repository at this point in the history
- "ax_tree_error"
- "ax_tree_update"
- "bad_message_reason"
- "font_key_name"
- "input-event-filter-send-failure"
- "mojo-message-error"
- "ppapi_path"
- "text-input-context-client"

Bug: 598854
Change-Id: Ia5d033e828ffb4341d43085a906551bb1c354e62
Reviewed-on: https://chromium-review.googlesource.com/811896
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522426}
  • Loading branch information
rsesek authored and Commit Bot committed Dec 7, 2017
1 parent 2892bfc commit 1419427
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 75 deletions.
13 changes: 0 additions & 13 deletions android_webview/common/crash_reporter/crash_keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ namespace crash_keys {

const char kActiveURL[] = "url-chunk";

const char kFontKeyName[] = "font_key_name";

const char kShutdownType[] = "shutdown-type";
const char kBrowserUnpinTrace[] = "browser-unpin-trace";

Expand All @@ -26,8 +24,6 @@ const char kAppPackageVersionCode[] = "app-package-version-code";

const char kAndroidSdkInt[] = "android-sdk-int";

const char kInputEventFilterSendFailure[] = "input-event-filter-send-failure";

const char kViewCount[] = "view-count";

const char kZeroEncodeDetails[] = "zero-encode-details";
Expand Down Expand Up @@ -56,15 +52,10 @@ size_t RegisterWebViewCrashKeys() {
{gpu::crash_keys::kGPUGLContextIsVirtual, kSmallSize},

// content/:
{"bad_message_reason", kSmallSize},
{"discardable-memory-allocated", kSmallSize},
{"discardable-memory-free", kSmallSize},
{kFontKeyName, kSmallSize},
{"mojo-message-error", kMediumSize},
{"ppapi_path", kMediumSize},
{"subresource_url", kLargeSize},
{"total-discardable-memory-allocated", kSmallSize},
{kInputEventFilterSendFailure, kSmallSize},
{kViewCount, kSmallSize},

// media/:
Expand All @@ -85,10 +76,6 @@ size_t RegisterWebViewCrashKeys() {

// TODO(sunnyps): Remove after fixing crbug.com/724999.
{"gl-context-set-current-stack-trace", kMediumSize},

// Accessibility keys. Temporary for http://crbug.com/765490.
{"ax_tree_error", kSmallSize},
{"ax_tree_update", kMediumSize},
};

// This dynamic set of keys is used for sets of key value pairs when gathering
Expand Down
12 changes: 0 additions & 12 deletions chrome/app/chrome_crash_reporter_client_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ namespace {
// RegisterCrashKeys function in the crash_keys::CrashReporterClient interface
// and the snprintf function defined here.
constexpr char kActiveURL[] = "url-chunk";
constexpr char kFontKeyName[] = "font_key_name";

// Installed extensions. |kExtensionID| should be formatted with an integer,
// in the range [0, kExtensionIDMaxCount).
Expand All @@ -58,8 +57,6 @@ constexpr char kHungRendererOutstandingEventType[] =
"hung-outstanding-event-type";
constexpr char kHungRendererLastEventType[] = "hung-last-event-type";
constexpr char kHungRendererReason[] = "hung-reason";
constexpr char kInputEventFilterSendFailure[] =
"input-event-filter-send-failure";

constexpr char kIsEnterpriseManaged[] = "is-enterprise-managed";

Expand Down Expand Up @@ -114,20 +111,15 @@ size_t RegisterCrashKeysHelper() {
{kIsEnterpriseManaged, kSmallSize},

// content/:
{"bad_message_reason", kSmallSize},
{"discardable-memory-allocated", kSmallSize},
{"discardable-memory-free", kSmallSize},
{kFontKeyName, kSmallSize},
{"mojo-message-error", kMediumSize},
{"ppapi_path", kMediumSize},
{"subresource_url", kLargeSize},
{"total-discardable-memory-allocated", kSmallSize},
{kViewCount, kSmallSize},
{kHungRendererOutstandingAckCount, kSmallSize},
{kHungRendererOutstandingEventType, kSmallSize},
{kHungRendererLastEventType, kSmallSize},
{kHungRendererReason, kSmallSize},
{kInputEventFilterSendFailure, kSmallSize},

// media/:
{kZeroEncodeDetails, kSmallSize},
Expand All @@ -144,10 +136,6 @@ size_t RegisterCrashKeysHelper() {

// TODO(sunnyps): Remove after fixing crbug.com/724999.
{"gl-context-set-current-stack-trace", kMediumSize},

// Accessibility keys. Temporary for http://crbug.com/765490.
{"ax_tree_error", kSmallSize},
{"ax_tree_update", kMediumSize},
};

// This dynamic set of keys is used for sets of key value pairs when gathering
Expand Down
18 changes: 0 additions & 18 deletions chrome/common/crash_keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ namespace crash_keys {

const char kActiveURL[] = "url-chunk";

const char kFontKeyName[] = "font_key_name";

const char kExtensionID[] = "extension-%" PRIuS;
const char kNumExtensionsCount[] = "num-extensions";

Expand All @@ -50,8 +48,6 @@ const char kApValue[] = "ap";
const char kCohortName[] = "cohort-name";
#endif

const char kInputEventFilterSendFailure[] = "input-event-filter-send-failure";

const char kPrinterInfo[] = "prn-info-%" PRIuS;

const char kViewCount[] = "view-count";
Expand Down Expand Up @@ -103,12 +99,8 @@ size_t RegisterChromeCrashKeys() {
{gpu::crash_keys::kGPUGLContextIsVirtual, kSmallSize},

// content/:
{"bad_message_reason", kSmallSize},
{"discardable-memory-allocated", kSmallSize},
{"discardable-memory-free", kSmallSize},
{kFontKeyName, kSmallSize},
{"mojo-message-error", kMediumSize},
{"ppapi_path", kMediumSize},
{"subresource_url", kLargeSize},
{"total-discardable-memory-allocated", kSmallSize},
#if defined(OS_WIN)
Expand All @@ -117,12 +109,6 @@ size_t RegisterChromeCrashKeys() {
{kHungRendererLastEventType, kSmallSize},
{kHungRendererReason, kSmallSize},
{kIsEnterpriseManaged, kSmallSize},
#endif
{kInputEventFilterSendFailure, kSmallSize},
#if defined(OS_MACOSX)
// content/:
{"text-input-context-client", kMediumSize},
// media/:
#endif
{kViewCount, kSmallSize},

Expand All @@ -143,10 +129,6 @@ size_t RegisterChromeCrashKeys() {

// TODO(sunnyps): Remove after fixing crbug.com/724999.
{"gl-context-set-current-stack-trace", kMediumSize},

// Accessibility keys. Temporary for http://crbug.com/765490.
{"ax_tree_error", kSmallSize},
{"ax_tree_update", kMediumSize},
};

// This dynamic set of keys is used for sets of key value pairs when gathering
Expand Down
4 changes: 0 additions & 4 deletions chrome/common/crash_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ extern const char kApValue[];
extern const char kCohortName[];
#endif

// Number of input event send IPC failures. Added to debug
// crbug.com/615090.
extern const char kInputEventFilterSendFailure[];

// The user's printers, up to kPrinterInfoCount. Should be set with
// ScopedPrinterInfo.
const size_t kPrinterInfoCount = 4;
Expand Down
9 changes: 0 additions & 9 deletions chromecast/crash/cast_crash_keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,10 @@ size_t RegisterCastCrashKeys() {
{gpu::crash_keys::kGPUGLContextIsVirtual, ::crash_keys::kSmallSize},

// content/:
{"bad_message_reason", ::crash_keys::kSmallSize},
{"discardable-memory-allocated", ::crash_keys::kSmallSize},
{"discardable-memory-free", ::crash_keys::kSmallSize},
{"font_key_name", ::crash_keys::kSmallSize},
{"mojo-message-error", ::crash_keys::kMediumSize},
{"ppapi_path", ::crash_keys::kMediumSize},
{"subresource_url", ::crash_keys::kLargeSize},
{"total-discardable-memory-allocated", ::crash_keys::kSmallSize},
{"input-event-filter-send-failure", ::crash_keys::kSmallSize},
{"view-count", ::crash_keys::kSmallSize},

// media/:
Expand All @@ -68,10 +63,6 @@ size_t RegisterCastCrashKeys() {

// TODO(sunnyps): Remove after fixing crbug.com/724999.
{"gl-context-set-current-stack-trace", ::crash_keys::kMediumSize},

// Accessibility keys. Temporary for http://crbug.com/765490.
{"ax_tree_error", ::crash_keys::kSmallSize},
{"ax_tree_update", ::crash_keys::kMediumSize},
};

return base::debug::InitCrashKeys(fixed_keys, arraysize(fixed_keys),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,17 @@ BrowserAccessibilityManager::~BrowserAccessibilityManager() {
void BrowserAccessibilityManager::Initialize(
const ui::AXTreeUpdate& initial_tree) {
if (!tree_->Unserialize(initial_tree)) {
static auto* ax_tree_error = base::debug::AllocateCrashKeyString(
"ax_tree_error", base::debug::CrashKeySize::Size32);
static auto* ax_tree_update = base::debug::AllocateCrashKeyString(
"ax_tree_update", base::debug::CrashKeySize::Size64);
// Temporarily log some additional crash keys so we can try to
// figure out why we're getting bad accessibility trees here.
// http://crbug.com/765490
// Be sure to re-enable BrowserAccessibilityManagerTest.TestFatalError
// when done (or delete it if no longer needed).
base::debug::SetCrashKeyValue("ax_tree_error", tree_->error());
base::debug::SetCrashKeyValue("ax_tree_update", initial_tree.ToString());
base::debug::SetCrashKeyString(ax_tree_error, tree_->error());
base::debug::SetCrashKeyString(ax_tree_update, initial_tree.ToString());
LOG(FATAL) << tree_->error();
}
}
Expand Down
13 changes: 10 additions & 3 deletions content/browser/bad_message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "content/browser/bad_message.h"

#include "base/bind.h"
#include "base/debug/crash_logging.h"
#include "base/debug/dump_without_crashing.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
Expand All @@ -20,10 +19,12 @@ namespace bad_message {
namespace {

void LogBadMessage(BadMessageReason reason) {
static auto* bad_message_reason = base::debug::AllocateCrashKeyString(
"bad_message_reason", base::debug::CrashKeySize::Size32);

LOG(ERROR) << "Terminating renderer for bad IPC message, reason " << reason;
UMA_HISTOGRAM_SPARSE_SLOWLY("Stability.BadMessageTerminated.Content", reason);
base::debug::SetCrashKeyValue("bad_message_reason",
base::IntToString(reason));
base::debug::SetCrashKeyString(bad_message_reason, base::IntToString(reason));
}

void ReceivedBadMessageOnUIThread(int render_process_id,
Expand Down Expand Up @@ -66,5 +67,11 @@ void ReceivedBadMessage(BrowserMessageFilter* filter, BadMessageReason reason) {
filter->ShutdownForBadMessage();
}

base::debug::CrashKeyString* GetMojoErrorCrashKey() {
static auto* crash_key = base::debug::AllocateCrashKeyString(
"mojo-message-error", base::debug::CrashKeySize::Size256);
return crash_key;
}

} // namespace bad_message
} // namespace content
5 changes: 5 additions & 0 deletions content/browser/bad_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef CONTENT_BROWSER_BAD_MESSAGE_H_
#define CONTENT_BROWSER_BAD_MESSAGE_H_

#include "base/debug/crash_logging.h"
#include "content/common/content_export.h"

namespace content {
Expand Down Expand Up @@ -235,6 +236,10 @@ CONTENT_EXPORT void ReceivedBadMessage(int render_process_id,
// for the |reason|, and terminates the process for |filter|.
void ReceivedBadMessage(BrowserMessageFilter* filter, BadMessageReason reason);

// Returns a crash key named "mojo-message-error" for storing Mojo error
// messages.
base::debug::CrashKeyString* GetMojoErrorCrashKey();

} // namespace bad_message
} // namespace content

Expand Down
4 changes: 3 additions & 1 deletion content/browser/browser_child_process_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "components/tracing/common/tracing_switches.h"
#include "content/browser/bad_message.h"
#include "content/browser/histogram_controller.h"
#include "content/browser/loader/resource_message_filter.h"
#include "content/browser/service_manager/service_manager_context.h"
Expand Down Expand Up @@ -599,7 +600,8 @@ void BrowserChildProcessHostImpl::OnMojoError(
// Create a memory dump with the error message captured in a crash key value.
// This will make it easy to determine details about what interface call
// failed.
base::debug::ScopedCrashKey error_key_value("mojo-message-error", error);
base::debug::ScopedCrashKeyString scoped_error_key(
bad_message::GetMojoErrorCrashKey(), error);
base::debug::DumpWithoutCrashing();
process->child_process_->GetProcess().Terminate(
RESULT_CODE_KILLED_BAD_MESSAGE, false);
Expand Down
3 changes: 2 additions & 1 deletion content/browser/renderer_host/render_process_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4145,7 +4145,8 @@ void RenderProcessHostImpl::OnMojoError(int render_process_id,

// The ReceivedBadMessage call below will trigger a DumpWithoutCrashing.
// Capture the error message in a crash key value.
base::debug::ScopedCrashKey error_key_value("mojo-message-error", error);
base::debug::ScopedCrashKeyString error_key_value(
bad_message::GetMojoErrorCrashKey(), error);
bad_message::ReceivedBadMessage(render_process_id,
bad_message::RPH_MOJO_PROCESS_ERROR);
}
Expand Down
11 changes: 6 additions & 5 deletions content/browser/renderer_host/render_widget_host_view_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1856,11 +1856,12 @@ - (void)dealloc {

// Debug key to check if the current input context still holds onto the view.
NSTextInputContext* currentContext = [NSTextInputContext currentInputContext];
base::debug::ScopedCrashKey textInputContextCrashKey(
"text-input-context-client",
currentContext && [currentContext client] == self
? "text input still held on"
: "text input no longer held on");
auto* crashKey = base::debug::AllocateCrashKeyString(
"text-input-context-client", base::debug::CrashKeySize::Size32);
base::debug::ScopedCrashKeyString textInputContextCrashKey(
crashKey, currentContext && [currentContext client] == self
? "text input still held on"
: "text input no longer held on");

[super dealloc];
}
Expand Down
8 changes: 4 additions & 4 deletions content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ enum FontProxyError {
FONT_PROXY_ERROR_MAX_VALUE
};

const char kFontKeyName[] = "font_key_name";

void LogLoadFamilyResult(DirectWriteLoadFamilyResult result) {
UMA_HISTOGRAM_ENUMERATION("DirectWrite.Fonts.Proxy.LoadFamilyResult", result,
LOAD_FAMILY_MAX_VALUE);
Expand Down Expand Up @@ -488,8 +486,10 @@ bool DWriteFontFamilyProxy::LoadFamily() {

SCOPED_UMA_HISTOGRAM_TIMER("DirectWrite.Fonts.Proxy.LoadFamilyTime");

base::debug::ScopedCrashKey crash_key(kFontKeyName,
base::WideToUTF8(family_name_));
auto* font_key_name = base::debug::AllocateCrashKeyString(
"font_key_name", base::debug::CrashKeySize::Size32);
base::debug::ScopedCrashKeyString crash_key(font_key_name,
base::WideToUTF8(family_name_));

mswr::ComPtr<IDWriteFontCollection> collection;
if (!proxy_collection_->LoadFamily(family_index_, &collection)) {
Expand Down
4 changes: 3 additions & 1 deletion content/ppapi_plugin/ppapi_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ void PpapiThread::OnLoadPlugin(const base::FilePath& path,
const ppapi::PpapiPermissions& permissions) {
// In case of crashes, the crash dump doesn't indicate which plugin
// it came from.
base::debug::SetCrashKeyValue("ppapi_path", path.MaybeAsASCII());
static auto* ppapi_path_key = base::debug::AllocateCrashKeyString(
"ppapi_path", base::debug::CrashKeySize::Size64);
base::debug::SetCrashKeyString(ppapi_path_key, path.MaybeAsASCII());

SavePluginName(path);

Expand Down
7 changes: 5 additions & 2 deletions content/renderer/input/input_event_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,11 @@ void InputEventFilter::SendMessageOnIOThread(
return;
static size_t s_send_failure_count_ = 0;
s_send_failure_count_++;
base::debug::SetCrashKeyValue("input-event-filter-send-failure",
base::IntToString(s_send_failure_count_));

static auto* crash_key = base::debug::AllocateCrashKeyString(
"input-event-filter-send-failure", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(crash_key,
base::IntToString(s_send_failure_count_));
}

} // namespace content

0 comments on commit 1419427

Please sign in to comment.