File tree Expand file tree Collapse file tree 5 files changed +40
-4
lines changed Expand file tree Collapse file tree 5 files changed +40
-4
lines changed Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include " Common/Noncopyable.hpp"
4+ #include " Threading/Lock.hpp"
5+ #include " xrDebug.h"
6+
7+ class ScopeLock : Noncopyable
8+ {
9+ public:
10+ ScopeLock (Lock* SyncObject);
11+ ~ScopeLock ();
12+
13+ private:
14+ Lock * m_SyncObject;
15+ };
16+
17+ ScopeLock::ScopeLock (Lock* SyncObject): m_SyncObject(SyncObject)
18+ {
19+ VERIFY (m_SyncObject);
20+
21+ m_SyncObject->Enter ();
22+ }
23+
24+ ScopeLock::~ScopeLock ()
25+ {
26+ m_SyncObject->Leave ();
27+ }
Original file line number Diff line number Diff line change 354354 <ClInclude Include =" SubAlloc.hpp" />
355355 <ClInclude Include =" Text\MbHelpers.h" />
356356 <ClInclude Include =" Threading\Event.hpp" />
357+ <ClInclude Include =" Threading\ScopeLock.h" />
357358 <ClInclude Include =" Threading\ThreadPool.hpp" />
358359 <ClInclude Include =" Threading\Lock.hpp" />
359360 <ClInclude Include =" vector.h" />
Original file line number Diff line number Diff line change 668668 <ClInclude Include =" xrMemory.h" >
669669 <Filter >Memory</Filter >
670670 </ClInclude >
671+ <ClInclude Include =" Threading\ScopeLock.h" >
672+ <Filter >Threading</Filter >
673+ </ClInclude >
671674 </ItemGroup >
672675 <ItemGroup >
673676 <ResourceCompile Include =" xrCore.rc" >
Original file line number Diff line number Diff line change 44#include " xrDebug.h"
55#include " os_clipboard.h"
66#include " Debug/dxerr.h"
7- #include " xrCore/Threading/Lock.hpp"
7+ #include " Threading/ScopeLock.h"
8+
89#pragma warning(push)
910#pragma warning(disable : 4091) // 'typedef ': ignored on left of '' when no variable is declared
1011#include " Debug/MiniDump.h"
@@ -76,7 +77,9 @@ xrDebug::CrashHandler xrDebug::OnCrash = nullptr;
7677xrDebug::DialogHandler xrDebug::OnDialog = nullptr ;
7778string_path xrDebug::BugReportFile;
7879bool xrDebug::ErrorAfterDialog = false ;
80+
7981bool xrDebug::m_SymEngineInitialized = false ;
82+ Lock xrDebug::m_DbgHelpLock;
8083
8184void xrDebug::SetBugReportFile (const char * fileName) { strcpy_s (BugReportFile, fileName); }
8285
@@ -187,6 +190,8 @@ void xrDebug::DeinitializeSymbolEngine(void)
187190
188191xr_vector<xr_string> xrDebug::BuildStackTrace (PCONTEXT threadCtx, u16 maxFramesCount)
189192{
193+ ScopeLock Lock (&m_DbgHelpLock);
194+
190195 SStringVec traceResult;
191196 STACKFRAME stackFrame = { 0 };
192197 xr_string frameStr;
Original file line number Diff line number Diff line change 22#include " xrCore/_types.h"
33#include " xrCommon/xr_string.h"
44#include " xrCommon/xr_vector.h"
5+ #include " Threading/Lock.hpp"
6+
57#include < string>
68
79#pragma warning(push)
@@ -74,9 +76,6 @@ class XRCORE_API xrDebug
7476 const char * arg1 = nullptr , const char * arg2 = nullptr );
7577 static void DoExit (const std::string& message);
7678
77- // /
78- // / Note: DbgHelp is singlethreaded, so you must synchronize calls to these functions
79- // /
8079 static void LogStackTrace (const char * header);
8180 static xr_vector<xr_string> BuildStackTrace (u16 maxFramesCount = MaxFramesCountDefault);
8281private:
@@ -90,6 +89,7 @@ class XRCORE_API xrDebug
9089 // / Next members relates to stack tracing
9190 // /
9291 static bool m_SymEngineInitialized;
92+ static Lock m_DbgHelpLock;
9393
9494 static xr_vector<xr_string> BuildStackTrace (PCONTEXT threadCtx, u16 maxFramesCount);
9595 static bool GetNextStackFrameString (LPSTACKFRAME stackFrame, PCONTEXT threadCtx, xr_string& frameStr);
You can’t perform that action at this time.
0 commit comments