mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 11:25:33 +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 <QStringBuilder>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
#if defined(Q_CC_MSVC)
|
#if defined(Q_CC_MSVC)
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
@@ -47,8 +49,15 @@ namespace BlackMisc
|
|||||||
static QMutex mutex;
|
static QMutex mutex;
|
||||||
QMutexLocker lock(&mutex);
|
QMutexLocker lock(&mutex);
|
||||||
|
|
||||||
|
static std::once_flag flag;
|
||||||
|
std::call_once(flag, []
|
||||||
|
{
|
||||||
|
SymInitialize(GetCurrentProcess(), nullptr, true);
|
||||||
|
std::atexit([] { SymCleanup(GetCurrentProcess()); });
|
||||||
|
});
|
||||||
|
|
||||||
auto process = GetCurrentProcess();
|
auto process = GetCurrentProcess();
|
||||||
SymInitialize(process, nullptr, true);
|
SymRefreshModuleList(process);
|
||||||
|
|
||||||
std::array<void*, 100> stack;
|
std::array<void*, 100> stack;
|
||||||
auto frames = CaptureStackBackTrace(1, static_cast<DWORD>(stack.size()), stack.data(), nullptr);
|
auto frames = CaptureStackBackTrace(1, static_cast<DWORD>(stack.size()), stack.data(), nullptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user