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 354
354
<ClInclude Include =" SubAlloc.hpp" />
355
355
<ClInclude Include =" Text\MbHelpers.h" />
356
356
<ClInclude Include =" Threading\Event.hpp" />
357
+ <ClInclude Include =" Threading\ScopeLock.h" />
357
358
<ClInclude Include =" Threading\ThreadPool.hpp" />
358
359
<ClInclude Include =" Threading\Lock.hpp" />
359
360
<ClInclude Include =" vector.h" />
Original file line number Diff line number Diff line change 668
668
<ClInclude Include =" xrMemory.h" >
669
669
<Filter >Memory</Filter >
670
670
</ClInclude >
671
+ <ClInclude Include =" Threading\ScopeLock.h" >
672
+ <Filter >Threading</Filter >
673
+ </ClInclude >
671
674
</ItemGroup >
672
675
<ItemGroup >
673
676
<ResourceCompile Include =" xrCore.rc" >
Original file line number Diff line number Diff line change 4
4
#include " xrDebug.h"
5
5
#include " os_clipboard.h"
6
6
#include " Debug/dxerr.h"
7
- #include " xrCore/Threading/Lock.hpp"
7
+ #include " Threading/ScopeLock.h"
8
+
8
9
#pragma warning(push)
9
10
#pragma warning(disable : 4091) // 'typedef ': ignored on left of '' when no variable is declared
10
11
#include " Debug/MiniDump.h"
@@ -76,7 +77,9 @@ xrDebug::CrashHandler xrDebug::OnCrash = nullptr;
76
77
xrDebug::DialogHandler xrDebug::OnDialog = nullptr ;
77
78
string_path xrDebug::BugReportFile;
78
79
bool xrDebug::ErrorAfterDialog = false ;
80
+
79
81
bool xrDebug::m_SymEngineInitialized = false ;
82
+ Lock xrDebug::m_DbgHelpLock;
80
83
81
84
void xrDebug::SetBugReportFile (const char * fileName) { strcpy_s (BugReportFile, fileName); }
82
85
@@ -187,6 +190,8 @@ void xrDebug::DeinitializeSymbolEngine(void)
187
190
188
191
xr_vector<xr_string> xrDebug::BuildStackTrace (PCONTEXT threadCtx, u16 maxFramesCount)
189
192
{
193
+ ScopeLock Lock (&m_DbgHelpLock);
194
+
190
195
SStringVec traceResult;
191
196
STACKFRAME stackFrame = { 0 };
192
197
xr_string frameStr;
Original file line number Diff line number Diff line change 2
2
#include " xrCore/_types.h"
3
3
#include " xrCommon/xr_string.h"
4
4
#include " xrCommon/xr_vector.h"
5
+ #include " Threading/Lock.hpp"
6
+
5
7
#include < string>
6
8
7
9
#pragma warning(push)
@@ -74,9 +76,6 @@ class XRCORE_API xrDebug
74
76
const char * arg1 = nullptr , const char * arg2 = nullptr );
75
77
static void DoExit (const std::string& message);
76
78
77
- // /
78
- // / Note: DbgHelp is singlethreaded, so you must synchronize calls to these functions
79
- // /
80
79
static void LogStackTrace (const char * header);
81
80
static xr_vector<xr_string> BuildStackTrace (u16 maxFramesCount = MaxFramesCountDefault);
82
81
private:
@@ -90,6 +89,7 @@ class XRCORE_API xrDebug
90
89
// / Next members relates to stack tracing
91
90
// /
92
91
static bool m_SymEngineInitialized;
92
+ static Lock m_DbgHelpLock;
93
93
94
94
static xr_vector<xr_string> BuildStackTrace (PCONTEXT threadCtx, u16 maxFramesCount);
95
95
static bool GetNextStackFrameString (LPSTACKFRAME stackFrame, PCONTEXT threadCtx, xr_string& frameStr);
You can’t perform that action at this time.
0 commit comments