AUI Framework  master
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
AStacktrace Class Reference

Stacktrace consisting of a collection of stack function frames. More...

#include <AUI/Platform/AStacktrace.h>

Classes#

class  Entry
 Stacktrace entry. More...
 

Public Types#

using iterator = AVector<Entry>::iterator
 

Public Member Functions#

 AStacktrace (aui::range< iterator > range)
 
aui::range< iterator > stripBeforeFunctionCall (void *pFunction, int maxAllowedOffsetInBytes=50)
 Tries to find the function pointer in stacktrace and strips stacktrace until function frame.
 
 AStacktrace (const AStacktrace &)=default
 
 AStacktrace (AStacktrace &&) noexcept=default
 
void resolveSymbolsIfNeeded () const noexcept
 Invokes function name resolution with function pointers.
 
const AVector< Entry > & entries () const noexcept
 
auto begin () const noexcept
 
auto end () const noexcept
 
auto rbegin () const noexcept
 
auto rend () const noexcept
 

Static Public Member Functions#

static AStacktrace capture (unsigned skipFrames=0, unsigned maxFrames=128) noexcept
 Creates stacktrace of the current thread.
 

Detailed Description#

The first element of the collection represents the top of the stack, which is the last function invocation. Typically, this is the point at which this stacktrace was created (unless skipFrames is zero). The last element of the collection represents the bottom of the stack (typically entrypoint).

Member Function Documentation#

◆ capture()#

static AStacktrace AStacktrace::capture ( unsigned skipFrames = 0,
unsigned maxFrames = 128 )
staticnoexcept
Parameters
skipFramesnumber of frames to skip.
maxFramesmax number of frames.
Note
A call to AStacktrace::capture is always skipped in the stacktrace.
Returns

◆ resolveSymbolsIfNeeded()#

void AStacktrace::resolveSymbolsIfNeeded ( ) const
noexcept

Must be called before using AStacktrace::Entry::functionName() and similar functions.

◆ stripBeforeFunctionCall()#

aui::range< iterator > AStacktrace::stripBeforeFunctionCall ( void * pFunction,
int maxAllowedOffsetInBytes = 50 )
Parameters
pFunctionpointer to function.
maxAllowedOffsetInBytesmax offset error in bytes.
Returns
itself (modified)

If stripBeforeFunctionCall fails to find pFunction, it leaves AStacktrace unmodified and returns itself.

stripBeforeFunctionCall strips the end of stacktrace, excluding the passed function.

maxAllowedOffsetInBytes is intended to find stack frame, which is not in exact location of function pointer.