ADTF  3.18.2
cExceptionHandler

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

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. More...
 
static fnAdditionalAction SetAdditionalAction (fnAdditionalAction pAction)
 Registers an additional handler that is called when a crash occurs. More...
 
static tBool UnregisterExceptionHandler ()
 Unregisters the exception handler;. More...
 
static tBool GetCallStack (cString &strCallStack, tInt nDepth=10)
 Returns the call stack. More...
 
static tCallStack GetCallStack (tInt nDepth=10, tVoid *pBuffer=nullptr)
 Retrieve the current call stack trace. More...
 
static tVoid FreeCallStack (tCallStack &sStack)
 Releases resources obtained through a cExceptionHandler::GetCallStack call. More...
 
static tCallStack CopyCallStack (const tCallStack &sStack)
 Copies the call stack. More...
 
static tResult ResolveCallStack (IStackResolveCallback *pCallback, const tCallStack &sStack)
 This will resolve symbol information from a stack trace. More...
 

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 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 cExceptionHandler::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.

◆ 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 cExceptionHandler::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.