14#include <AUI/Common/AString.h> 
   15#include <AUI/Common/AVector.h> 
   28class API_AUI_CORE AStacktrace {
 
   34        friend class AStacktrace;
 
   42        explicit Entry(
void* ptr) : mPtr(ptr), mFunctionName(std::nullopt) {}
 
   65        void* ptr() const noexcept {
 
 
   70    using iterator = AVector<Entry>::iterator;
 
   72    AStacktrace(aui::range<iterator> range): mEntries(range.begin(), range.end()) {}
 
   88    AStacktrace(
const AStacktrace&) = 
default;
 
   89    AStacktrace(AStacktrace&&) noexcept = default;
 
  104    auto begin() const noexcept {
 
  105        return mEntries.begin();
 
  109    auto end() const noexcept {
 
  110        return mEntries.end();
 
  114    auto rbegin() const noexcept {
 
  115        return mEntries.rbegin();
 
  119    auto rend() const noexcept {
 
  120        return mEntries.rend();
 
  130    static AStacktrace 
capture(
unsigned skipFrames = 0, 
unsigned maxFrames = 128) noexcept;
 
  134    mutable 
bool mSymbolNamesResolved = false;
 
  136    explicit AStacktrace(
AVector<
Entry> entries) : mEntries(std::move(entries)) {}
 
 
  139inline std::ostream& operator<<(std::ostream& o, 
const AStacktrace& stacktrace) 
noexcept {
 
  140    stacktrace.resolveSymbolsIfNeeded();
 
  141    for (
const auto& entry : stacktrace) {
 
  142        o << 
" - at " << entry.ptr();
 
  143        if (
auto name = entry.functionName()) {
 
  148        if (
auto filename = entry.fileName()) {
 
  154        if (
auto line = entry.lineNumber()) {
 
  160        o << 
")" << std::endl;
 
Utility wrapper implementing the stack-allocated (fast) optional idiom.
Definition AOptional.h:33
Stacktrace entry.
Definition AStacktrace.h:33
const AOptional< AString > & fileName() const noexcept
Definition AStacktrace.h:54
const AOptional< AString > & functionName() const noexcept
Definition AStacktrace.h:47
AOptional< unsigned > lineNumber() const noexcept
Definition AStacktrace.h:61
Stacktrace consisting of a collection of stack function frames.
Definition AStacktrace.h:28
aui::range< iterator > stripBeforeFunctionCall(void *pFunction, int maxAllowedOffsetInBytes=50)
Tries to find the function pointer in stacktrace and strips stacktrace until function frame.
static AStacktrace capture(unsigned skipFrames=0, unsigned maxFrames=128) noexcept
Creates stacktrace of the current thread.
void resolveSymbolsIfNeeded() const noexcept
Invokes function name resolution with function pointers.
A std::vector with AUI extensions.
Definition AVector.h:39
AString name(T *v)
Runtime reflection based on typeid.
Definition AReflect.h:29
Definition iterators.h:50