ADTF
Loading...
Searching...
No Matches
cExceptionHandler

The cExceptionHandler class provides static methods for registration and unregistration of a exception handler for unhandled exceptions. More...

#include <exceptionhandler.h>

Classes

class  IStackResolveCallback
 Callback for resolved stack traces. More...
 

Public Types

typedef tVoid(* fnAdditionalAction) (const tChar *strBaseName, tBool bAskUser)
 Type for additional actions when an exception occurs.
 

Static Public Member Functions

static tBool RegisterExceptionHandler (const tChar *strApplicationName, const tChar *strSupportContact, tBool bDontAsk=tFalse)
 Registers the exception handler.
 
static fnAdditionalAction SetAdditionalAction (fnAdditionalAction pAction)
 Registers an additional handler that is called when a crash occurs.
 
static tBool UnregisterExceptionHandler ()
 Unregisters the exception handler;.
 
static tBool GetCallStack (cString &strCallStack, tInt nDepth=10)
 Returns the call stack.
 
static tCallStack GetCallStack (tInt nDepth=10, tVoid *pBuffer=nullptr)
 Retrieve the current call stack trace.
 
static tVoid FreeCallStack (tCallStack &sStack)
 Releases resources obtained through a GetCallStack call.
 
static tCallStack CopyCallStack (const tCallStack &sStack)
 Copies the call stack.
 
static tResult ResolveCallStack (IStackResolveCallback *pCallback, const tCallStack &sStack)
 This will resolve symbol information from a stack trace.
 

Detailed Description

The cExceptionHandler class provides static methods for registration and unregistration of a exception handler for unhandled exceptions.

Remarks
If you use this class on linux you need to link against libbfd, libiberty and libz! To do so use the cmake macro a_utils_use_exceptionhandler.
This API is only available if you use compiler switch A_UTILS_USE_EXCEPTIONHANDLER.

Definition at line 20 of file exceptionhandler.h.

Member Typedef Documentation

◆ fnAdditionalAction

typedef tVoid(* fnAdditionalAction) (const tChar *strBaseName, tBool bAskUser)

Type for additional actions when an exception occurs.

Definition at line 24 of file exceptionhandler.h.

Member Function Documentation

◆ CopyCallStack()

static tCallStack CopyCallStack ( const tCallStack & sStack)
static

Copies the call stack.

Parameters
[in]sStackThe stack to copy.
Returns
The copy of the stack.

◆ FreeCallStack()

static tVoid FreeCallStack ( tCallStack & sStack)
static

Releases resources obtained through a GetCallStack call.

Parameters
[in]sStackThe stack retrieved from GetCallStack.
Returns
tVoid

◆ GetCallStack() [1/2]

static tBool GetCallStack ( cString & strCallStack,
tInt nDepth = 10 )
static

Returns the call stack.

Parameters
strCallStack[out] Will contain the call stack.
nDepth[in] The depth of the call stack to return.
Returns
tTrue on success, otherwise tFalse.

◆ GetCallStack() [2/2]

static tCallStack GetCallStack ( tInt nDepth = 10,
tVoid * pBuffer = nullptr )
static

Retrieve the current call stack trace.

Parameters
[in]nDepthThe maximum amount of stack frames to capture.
[in]pBufferfor internal use only.
Returns
The current call stack trace.

◆ RegisterExceptionHandler()

static tBool RegisterExceptionHandler ( const tChar * strApplicationName,
const tChar * strSupportContact,
tBool bDontAsk = tFalse )
static

Registers the exception handler.

Parameters
strApplicationName[in] The name of the application.
strSupportContact[in] The support contact information (email).
bDontAsk[in] Whether or not the user can cancel the dump file creation (Windows only).
Returns
tTrue on success, otherwise tFalse.

References tFalse.

◆ ResolveCallStack()

static tResult ResolveCallStack ( IStackResolveCallback * pCallback,
const tCallStack & sStack )
static

This will resolve symbol information from a stack trace.

Parameters
[in]pCallbackThis will be called for each stack frame.
[in]sStackA stack trace retrieved via GetCallStack.
Returns
The result from the callback.

◆ SetAdditionalAction()

static fnAdditionalAction SetAdditionalAction ( fnAdditionalAction pAction)
static

Registers an additional handler that is called when a crash occurs.

Parameters
pActionPointer to the new additional handler.
Returns
Pointer to the old additional handler (nullptr most of the time).

◆ UnregisterExceptionHandler()

static tBool UnregisterExceptionHandler ( )
static

Unregisters the exception handler;.

Returns
tTrue on success, otherwise tFalse.