CrashReportProperty Class Reference

#include <crashreportproperty.h>

Detailed Description

A property that can be stored by the crash report if something crashes while the property is still part of the scope.

If you'd call the following method with makeCrash == true the crash report would contain the two properties "Entered Sample method" and "Going to crash: true". The property "Will not appear" won't be in the crash report because the scope of its code block has been left.

void Sample(Int xyz, Bool makeCrash)
{
CRASHREPORTPROPERTY("Entered Sample method");
if (xyz)
{
CRASHREPORTPROPERTY("Will not appear", xyz);
}
if (makeCrash)
{
CRASHREPORTPROPERTY("Going to crash", makeCrash);
int* badAddress = (int*) 32;
*badAddress = 42;
}
}
#define CRASHREPORTPROPERTY(...)
Definition: crashreportproperty.h:227
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:187
bool Bool
boolean type, possible values are only false/true, 8 bit
Definition: apibase.h:180

Public Member Functions

 CrashReportProperty (const Char *name, const Char *value=nullptr)
 
 CrashReportProperty (const Char *name, Bool value)
 
 CrashReportProperty (const Char *name, Char value)
 
 CrashReportProperty (const Char *name, Int16 value)
 
 CrashReportProperty (const Char *name, Int32 value)
 
 CrashReportProperty (const Char *name, Int64 value)
 
 CrashReportProperty (const Char *name, UChar value)
 
 CrashReportProperty (const Char *name, UInt16 value)
 
 CrashReportProperty (const Char *name, UInt32 value)
 
 CrashReportProperty (const Char *name, UInt64 value)
 
 CrashReportProperty (const Char *name, const Float32 &value)
 
 CrashReportProperty (const Char *name, const Float64 &value)
 
 CrashReportProperty (const Char *name, const String &value)
 
template<typename T >
 CrashReportProperty (const Char *name, const T &value)
 
 ~CrashReportProperty ()
 

Static Public Member Functions

static CrashReportPropertyArray * GetCrashReportProperties (void *osThread)
 

Private Member Functions

 MAXON_DISALLOW_COPY_AND_ASSIGN (CrashReportProperty)
 
void SetAllocationState (Bool state)
 
Bool IsAllocated () const
 
const Char * StoreValue (const Char *value)
 
const Char * StoreValue (Bool value)
 
const Char * StoreValue (UInt64 value, Int digits)
 

Private Attributes

Int32 _propertyIdx
 
char _buf [28]
 

Constructor & Destructor Documentation

◆ CrashReportProperty() [1/14]

CrashReportProperty ( const Char *  name,
const Char *  value = nullptr 
)
explicit

Constructs a property for the crash report if something crashes while this is still in scope. it when the object is no longer needed). If you try to start an already running thread this will fail and return an error.

Parameters
[in]nameProperty name or key.
[in]valuePointer to a null terminated C string that must be valid until the scope is left.

◆ CrashReportProperty() [2/14]

CrashReportProperty ( const Char *  name,
Bool  value 
)

◆ CrashReportProperty() [3/14]

CrashReportProperty ( const Char *  name,
Char  value 
)

◆ CrashReportProperty() [4/14]

CrashReportProperty ( const Char *  name,
Int16  value 
)

◆ CrashReportProperty() [5/14]

CrashReportProperty ( const Char *  name,
Int32  value 
)

◆ CrashReportProperty() [6/14]

CrashReportProperty ( const Char *  name,
Int64  value 
)

◆ CrashReportProperty() [7/14]

CrashReportProperty ( const Char *  name,
UChar  value 
)

◆ CrashReportProperty() [8/14]

CrashReportProperty ( const Char *  name,
UInt16  value 
)

◆ CrashReportProperty() [9/14]

CrashReportProperty ( const Char *  name,
UInt32  value 
)

◆ CrashReportProperty() [10/14]

CrashReportProperty ( const Char *  name,
UInt64  value 
)

◆ CrashReportProperty() [11/14]

CrashReportProperty ( const Char *  name,
const Float32 &  value 
)

◆ CrashReportProperty() [12/14]

CrashReportProperty ( const Char *  name,
const Float64 &  value 
)

◆ CrashReportProperty() [13/14]

CrashReportProperty ( const Char *  name,
const String &  value 
)

◆ CrashReportProperty() [14/14]

CrashReportProperty ( const Char *  name,
const T &  value 
)

◆ ~CrashReportProperty()

Destructs a property for the crash report when the scope is left. From the C++ standard: "On exit from a scope (however accomplished), objects with automatic storage duration (3.7.3) that have been constructed in that scope are destroyed in the reverse order of their construction."

Member Function Documentation

◆ MAXON_DISALLOW_COPY_AND_ASSIGN()

MAXON_DISALLOW_COPY_AND_ASSIGN ( CrashReportProperty  )
private

◆ GetCrashReportProperties()

static CrashReportPropertyArray* GetCrashReportProperties ( void *  osThread)
static

Returns a pointer to an array with crash properties (used by the crash report).

Parameters
[in]osThreadOS specific thread identifier.
Returns
Pointer to an array with crash properties.

◆ SetAllocationState()

void SetAllocationState ( Bool  state)
private

◆ IsAllocated()

Bool IsAllocated ( ) const
private

◆ StoreValue() [1/3]

const Char* StoreValue ( const Char *  value)
private

◆ StoreValue() [2/3]

const Char* StoreValue ( Bool  value)
private

◆ StoreValue() [3/3]

const Char* StoreValue ( UInt64  value,
Int  digits 
)
private

Member Data Documentation

◆ _propertyIdx

Int32 _propertyIdx
private

◆ _buf

char _buf[28]
private