Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
BackTrace.h File Reference
#include "Stroika/Foundation/StroikaPreComp.h"
#include <limits>
#include "Stroika/Foundation/Characters/String.h"

Go to the source code of this file.

Namespaces

namespace  Stroika::Foundation
 

Functions

wstring Stroika::Foundation::Debug::BackTrace::Capture (const Options &options={})
 

Function Documentation

◆ Capture()

wstring Stroika::Foundation::Debug::BackTrace::Capture ( const Options &  options = {})

Return a string/printable version of the current stack backtrace (deepest part of the stack first). This is handy in debugging.

This function will fail gracefully and return an empty string if needed.

There are cases where one would want to limit the number of 'stack frames' returned - since this is just used for debugging...

The frames are EOL (line) delimited.

Note
- if you've distributed a copy of the program without symbols, you can use gdb to read back symbol names with: > gdb-multiarch Output/arm-linux-gnueabi/Debug/BLKQCL-Controller info symbol 0x770368 info symbol 0x1b974 ... etc for each symbol returned in []
to get symbols working on Linux (GNU linker), it may be necessary to link with -rdynamic This can be done with the Stroika configure flags: –extra-linker-args -rdynamic OR –apply-default-debug-flags
BackTrace () Uses no Stroika classes internally (like String, InlineBuffer) etc, since doing so could create deadlocks in the likely use cases where one would want to call this, from a low level place where you might have locks.

This DOES - however - however, call STL routines and C-library routines, like string::CTOR {}

Note
On Windows, this maybe implemented using Boost, and may use COM, initializing it with unfriendly values (like MultiThreading init).

You can construct a Execution::Platform::Windows::COMInitializer before any invocations to Capture() (stacktrace) - to avoid problems caused by this (only really affects COM-based applications).

Note
There was a proposal to add something like this to C++20 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0881r5.html) but it doesn't appear to have made the cat.

For now, typically delegate to https://www.boost.org/doc/libs/1_65_1/doc/html/stacktrace.html

Note
The first few frames are internal to the implementation of BackTrace() so not interesting

Definition at line 46 of file BackTrace.cpp.