summaryrefslogtreecommitdiffstats
path: root/extensions/common/features/feature_util.h
diff options
context:
space:
mode:
authorkalman <kalman@chromium.org>2015-08-05 16:28:00 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-05 23:28:31 +0000
commitcf3b821f4e0020cf1d8dc42e4272f748b1b8d94c (patch)
treef32c428206a1bc8f31d8b37d809a6aa710a7ad6e /extensions/common/features/feature_util.h
parent0ab79f545b617223f39a82a2994f115a5af98ca8 (diff)
downloadchromium_src-cf3b821f4e0020cf1d8dc42e4272f748b1b8d94c.zip
chromium_src-cf3b821f4e0020cf1d8dc42e4272f748b1b8d94c.tar.gz
chromium_src-cf3b821f4e0020cf1d8dc42e4272f748b1b8d94c.tar.bz2
If an extension feature isn't found, write the feature name to the stack before crashing.
This will help debug crashes like the one in the bug, by looking at the minidump which contains a snapshot of the stack. BUG=461915 R=rockot@chromium.org Review URL: https://codereview.chromium.org/1240423003 Cr-Commit-Position: refs/heads/master@{#342006}
Diffstat (limited to 'extensions/common/features/feature_util.h')
-rw-r--r--extensions/common/features/feature_util.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/extensions/common/features/feature_util.h b/extensions/common/features/feature_util.h
new file mode 100644
index 0000000..b8d04fe
--- /dev/null
+++ b/extensions/common/features/feature_util.h
@@ -0,0 +1,30 @@
+// Copyright 2013 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 EXTENSIONS_COMMON_FEATURES_FEATURE_UTIL_H_
+#define EXTENSIONS_COMMON_FEATURES_FEATURE_UTIL_H_
+
+#include "base/debug/alias.h"
+#include "base/logging.h"
+#include "base/strings/string_util.h"
+
+// Writes |message| to the stack so that it shows up in the minidump, then
+// crashes the current process.
+//
+// The prefix "e::" is used so that the crash can be quickly located.
+//
+// This is provided in feature_util because for some reason features are prone
+// to mysterious crashes in named map lookups. For example see crbug.com/365192
+// and crbug.com/461915.
+#define CRASH_WITH_MINIDUMP(message) \
+ { \
+ std::string message_copy(message); \
+ char minidump[BUFSIZ]; \
+ base::debug::Alias(&minidump); \
+ base::snprintf(minidump, arraysize(minidump), "e::%s:%d:\"%s\"", __FILE__, \
+ __LINE__, message_copy.c_str()); \
+ LOG(FATAL) << message_copy; \
+ }
+
+#endif // EXTENSIONS_COMMON_FEATURES_FEATURE_UTIL_H_