// Copyright (c) 2012 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.
// A crash key is an annotation that is carried along with a crash report, to // provide additional debugging information beyond a stack trace. Crash keys // have a name and a string value. // // The preferred API is //components/crash/core/common:crash_key, however not // all clients can hold a direct dependency on that target. The API provided // in this file indirects the dependency. // // Example usage: // static CrashKeyString* crash_key = // AllocateCrashKeyString("name", CrashKeySize::Size32); // SetCrashKeyString(crash_key, "value"); // ClearCrashKeyString(crash_key);
// The maximum length for a crash key's value must be one of the following // pre-determined values. enumclass CrashKeySize {
Size32 = 32,
Size64 = 64,
Size256 = 256,
};
struct CrashKeyString;
// Allocates a new crash key with the specified |name| with storage for a // value up to length |size|. This will return null if the crash key system is // not initialized.
BASE_EXPORT CrashKeyString* AllocateCrashKeyString(constchar name[],
CrashKeySize size);
// Stores |value| into the specified |crash_key|. The |crash_key| may be null // if AllocateCrashKeyString() returned null. If |value| is longer than the // size with which the key was allocated, it will be truncated.
BASE_EXPORT void SetCrashKeyString(CrashKeyString* crash_key,
base::StringPiece value);
// Clears any value that was stored in |crash_key|. The |crash_key| may be // null.
BASE_EXPORT void ClearCrashKeyString(CrashKeyString* crash_key);
// A scoper that sets the specified key to value for the lifetime of the // object, and clears it on destruction. class BASE_EXPORT ScopedCrashKeyString { public:
ScopedCrashKeyString(CrashKeyString* crash_key, base::StringPiece value);
~ScopedCrashKeyString();
//////////////////////////////////////////////////////////////////////////////// // The following declarations are used to initialize the crash key system // in //base by providing implementations for the above functions.
// The virtual interface that provides the implementation for the crash key // API. This is implemented by a higher-layer component, and the instance is // set using the function below. class CrashKeyImplementation { public: virtual ~CrashKeyImplementation() = default;
// Initializes the crash key system in base by replacing the existing // implementation, if it exists, with |impl|. The |impl| is copied into base.
BASE_EXPORT void SetCrashKeyImplementation(
std::unique_ptr<CrashKeyImplementation> impl);
// The base structure for a crash key, storing the allocation metadata. struct CrashKeyString {
constexpr CrashKeyString(constchar name[], CrashKeySize size)
: name(name), size(size) {} constchar* const name; const CrashKeySize size;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.