AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
AStacktrace Class Reference

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

Detailed Description

Stacktrace consisting of a collection of stack function frames.

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).

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. More...
 
 AStacktrace (const AStacktrace &)=default
 
 AStacktrace (AStacktrace &&) noexcept=default
 
void resolveSymbolsIfNeeded () const noexcept
 Invokes function name resolution with function pointers. More...
 
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. More...
 

Member Function Documentation

◆ capture()

AStacktrace AStacktrace::capture ( unsigned  skipFrames = 0,
unsigned  maxFrames = 128 
)
staticnoexcept

Creates stacktrace of the current thread.

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

Invokes function name resolution with function pointers.

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

◆ stripBeforeFunctionCall()

aui::range< AStacktrace::iterator > AStacktrace::stripBeforeFunctionCall ( void *  pFunction,
int  maxAllowedOffsetInBytes = 50 
)

Tries to find the function pointer in stacktrace and strips stacktrace until function frame.

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.

#include <AUI/Platform/AStacktrace.h>


The documentation for this class was generated from the following files: