mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
Call SymInitialize only once and SymCleanup at app exit
In order to refresh the modules, call SymRefreshModuleList regularly refs #845
This commit is contained in:
committed by
Mathew Sutcliffe
parent
dcbddf8e5e
commit
09963bf33a
@@ -15,6 +15,8 @@
|
||||
#include <QStringBuilder>
|
||||
#include <QMutexLocker>
|
||||
#include <array>
|
||||
#include <cstdlib>
|
||||
#include <mutex>
|
||||
|
||||
#if defined(Q_CC_MSVC)
|
||||
# include <windows.h>
|
||||
@@ -47,8 +49,15 @@ namespace BlackMisc
|
||||
static QMutex mutex;
|
||||
QMutexLocker lock(&mutex);
|
||||
|
||||
static std::once_flag flag;
|
||||
std::call_once(flag, []
|
||||
{
|
||||
SymInitialize(GetCurrentProcess(), nullptr, true);
|
||||
std::atexit([] { SymCleanup(GetCurrentProcess()); });
|
||||
});
|
||||
|
||||
auto process = GetCurrentProcess();
|
||||
SymInitialize(process, nullptr, true);
|
||||
SymRefreshModuleList(process);
|
||||
|
||||
std::array<void*, 100> stack;
|
||||
auto frames = CaptureStackBackTrace(1, static_cast<DWORD>(stack.size()), stack.data(), nullptr);
|
||||
|
||||
Reference in New Issue
Block a user