Crashpad
|
Base class for an annotation, which records a name-value pair of arbitrary data when set. More...
#include "client/annotation.h"
Public Types | |
enum | Type : uint16_t |
The type of data stored in the annotation. More... | |
using | ValueSizeType = uint32_t |
The type used for SetSize(). | |
Public Member Functions | |
constexpr | Annotation (Type type, const char name[], void *const value_ptr) |
Constructs a new annotation. More... | |
void | SetSize (ValueSizeType size) |
Specifies the number of bytes in value_ptr_ to include when generating a crash report. More... | |
void | Clear () |
Marks the annotation as cleared, indicating the value_ptr_ should not be included in a crash report. More... | |
bool | is_set () const |
Tests whether the annotation has been set. | |
Type | type () const |
ValueSizeType | size () const |
const char * | name () const |
const void * | value () const |
Static Public Member Functions | |
constexpr static Type | UserDefinedType (uint16_t value) |
Creates a user-defined Annotation::Type. More... | |
Static Public Attributes | |
static constexpr size_t | kNameMaxLength = 64 |
The maximum length of an annotation’s name, in bytes. | |
static constexpr size_t | kValueMaxSize = 5 * 4096 |
The maximum size of an annotation’s value, in bytes. | |
Protected Member Functions | |
std::atomic< Annotation * > & | link_node () |
Friends | |
class | AnnotationList |
Base class for an annotation, which records a name-value pair of arbitrary data when set.
After an annotation is declared, its value_ptr_
will not be captured in a crash report until a call to SetSize() specifies how much data from the value should be recorded.
Annotations should be declared with static storage duration.
An example declaration and usage:
Annotation objects are not inherently thread-safe. To manipulate them from multiple threads, external synchronization must be used.
Annotation objects should never be destroyed. Once they are Set(), they are permanently referenced by a global object.
|
strong |
|
inlineconstexpr |
Constructs a new annotation.
Upon construction, the annotation will not be included in any crash reports until
0
.[in] | type | The data type of the value of the annotation. |
[in] | name | A NUL -terminated C-string name for the annotation. Names do not have to be unique, though not all crash processors may handle Annotations with the same name. Names should be constexpr data with static storage duration. |
[in] | value_ptr | A pointer to the value for the annotation. The pointer may not be changed once associated with an annotation, but the data may be mutated. |
void crashpad::Annotation::Clear | ( | ) |
Marks the annotation as cleared, indicating the value_ptr_ should not be included in a crash report.
This method does not mutate the data referenced by the annotation, it merely updates the annotation system's bookkeeping.
void crashpad::Annotation::SetSize | ( | ValueSizeType | size | ) |
Specifies the number of bytes in value_ptr_ to include when generating a crash report.
A size of 0
indicates that no value should be recorded and is the equivalent of calling
This method does not mutate the data referenced by the annotation, it merely updates the annotation system's bookkeeping.
Subclasses of this base class that provide additional Set methods to mutate the value of the annotation must call always call this method.
[in] | size | The number of bytes. |
|
inlinestaticconstexpr |
Creates a user-defined Annotation::Type.
This exists to remove the casting overhead of enum class
.
[in] | value | A value used to create a user-defined type. |