13 #if defined(_WIN32) || defined(_WIN64)
15 #if defined(DBGHELP_SUPPORT)
18 #pragma warning(disable:4091)
31 class StackTraceManager::Impl
34 Impl() : _initialized(false) {}
42 #if defined(_WIN32) || defined(_WIN64)
43 #if defined(DBGHELP_SUPPORT)
45 SymSetOptions(SYMOPT_PUBLICS_ONLY);
48 HANDLE hProcess = GetCurrentProcess();
51 if (!InitializeSymbols(hProcess))
52 throwex SystemException(
"Cannot initialize symbol handler for the current process!");
65 #if defined(_WIN32) || defined(_WIN64)
66 #if defined(DBGHELP_SUPPORT)
68 HANDLE hProcess = GetCurrentProcess();
71 if (!SymCleanup(hProcess))
72 throwex SystemException(
"Cannot cleanup symbol handler for the current process!");
82 #if defined(_WIN32) || defined(_WIN64)
83 #if defined(DBGHELP_SUPPORT)
84 bool InitializeSymbols(HANDLE hProcess)
86 const int attempts = 10;
87 const int sleep = 100;
88 for (
int attempt = 0; attempt < attempts; ++attempt)
90 if (SymInitialize(hProcess,
nullptr, TRUE))
103 StackTraceManager::StackTraceManager()
106 [[maybe_unused]] ValidateAlignedStorage<
sizeof(Impl),
alignof(Impl), StorageSize, StorageAlign> _;
107 static_assert((StorageSize >=
sizeof(Impl)),
"StackTraceManager::StorageSize must be increased!");
108 static_assert(((StorageAlign %
alignof(Impl)) == 0),
"StackTraceManager::StorageAlign must be adjusted!");
111 new(&_storage)Impl();
117 reinterpret_cast<Impl*
>(&_storage)->~Impl();
static StackTraceManager & GetInstance()
Get singleton instance.
static void Initialize()
Initialize stack trace manager.
static void Cleanup()
Cleanup stack trace manager.
#define throwex
Throw extended exception macro.
C++ Common project definitions.
Stack trace manager definition.
Aligned storage validator definition.