Sane C++ Libraries
C++ Platform Abstraction Libraries
SC::Assert Struct Reference

Functions and macros to assert, exit() or abort() and capture backtraces. More...

#include <Assert.h>

Static Public Member Functions

static SC_COMPILER_FORCE_INLINE void unreachable ()
 
static void exit (int code)
 Exits current process. More...
 
static void print (const char *expression, const char *filename, const char *functionName, int lineNumber)
 Prints an assertion to standard output. More...
 
static void printAscii (const char *str)
 Prints an ASCII string to standard output. More...
 
static bool printBacktrace ()
 Prints backtrace (call stack) of the caller to standard output. More...
 
static bool printBacktrace (void **backtraceBuffer, size_t backtraceBufferSizeInBytes)
 Prints backtrace (call stack) previously captured with captureBacktrace() of the caller to standard output. More...
 
static size_t captureBacktrace (size_t framesToSkip, void **backtraceBuffer, size_t backtraceBufferSizeInBytes, uint32_t *hash)
 Captures backtrace of calling stack. More...
 

Detailed Description

Functions and macros to assert, exit() or abort() and capture backtraces.

Member Function Documentation

◆ captureBacktrace()

static size_t SC::Assert::captureBacktrace ( size_t  framesToSkip,
void **  backtraceBuffer,
size_t  backtraceBufferSizeInBytes,
uint32_t hash 
)
static

Captures backtrace of calling stack.

Parameters
framesToSkipNumber of call stack frames to skip
backtraceBufferA pre-allocated buffer to hold current backtrace
backtraceBufferSizeInBytesSize of the backtraceBuffer
hashHash of current stack trace
Returns
number of frames captured in backtraceBuffer

◆ exit()

static void SC::Assert::exit ( int  code)
static

Exits current process.

Parameters
codeReturn code for calling process

◆ print()

static void SC::Assert::print ( const char *  expression,
const char *  filename,
const char *  functionName,
int  lineNumber 
)
static

Prints an assertion to standard output.

Parameters
expressionThe failed assertion converted to string
filenameName of the file where the assertion failed
functionNameName of the function containing the assertion that failed
lineNumberLine number where the assertion is defined

◆ printAscii()

static void SC::Assert::printAscii ( const char *  str)
static

Prints an ASCII string to standard output.

Parameters
strPointer to ASCII string (no UTF8)

◆ printBacktrace() [1/2]

static bool SC::Assert::printBacktrace ( )
static

Prints backtrace (call stack) of the caller to standard output.

Returns
true if backtrace was correctly captured and print, false otherwise

◆ printBacktrace() [2/2]

static bool SC::Assert::printBacktrace ( void **  backtraceBuffer,
size_t  backtraceBufferSizeInBytes 
)
static

Prints backtrace (call stack) previously captured with captureBacktrace() of the caller to standard output.

Returns
true if backtrace was correctly captured and print, false otherwise

The documentation for this struct was generated from the following file: