Skip to content

Commit

Permalink
Update frame_msvc.ipp
Browse files Browse the repository at this point in the history
  • Loading branch information
apolukhin authored Feb 23, 2024
1 parent 12e07fc commit 27093f2
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions include/boost/stacktrace/detail/frame_msvc.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <windows.h>
#include "dbgeng.h"

#include <mutex>

#ifdef BOOST_MSVC
# pragma comment(lib, "ole32.lib")
# pragma comment(lib, "Dbgeng.lib")
Expand Down Expand Up @@ -138,14 +140,30 @@ class debugging_symbols: boost::noncopyable {
}

#ifndef BOOST_STACKTRACE_USE_WINDBG_CACHED
static std::mutex& get_mutex_inst() noexcept {
static std::mutex m;
return m;
}

static com_holder< ::IDebugSymbols>& get_static_debug_inst() noexcept {
// [class.mfct]: A static local variable or local type in a member function always refers to the same entity, whether
// or not the member function is inline.
static com_holder< ::IDebugSymbols> idebug;

if (!idebug.is_inited()) {
try_init_com(idebug);
}

return idebug;
}

std::lock_guard<std::mutex> guard_;
com_holder< ::IDebugSymbols> idebug_;
public:
debugging_symbols() noexcept
{
try_init_com(idebug_);
}

: guard_( get_mutex_inst() )
, idebug_( get_static_debug_inst() )
{}
#else

#ifdef BOOST_NO_CXX11_THREAD_LOCAL
Expand Down

0 comments on commit 27093f2

Please sign in to comment.