@@ -78,12 +78,12 @@ xrDebug::DialogHandler xrDebug::OnDialog = nullptr;
78
78
string_path xrDebug::BugReportFile;
79
79
bool xrDebug::ErrorAfterDialog = false ;
80
80
81
- bool xrDebug::m_SymEngineInitialized = false ;
82
- Lock xrDebug::m_DbgHelpLock ;
81
+ bool xrDebug::symEngineInitialized = false ;
82
+ Lock xrDebug::dbgHelpLock ;
83
83
84
- void xrDebug::SetBugReportFile (const char * fileName) { strcpy_s (BugReportFile, fileName); }
84
+ void xrDebug::SetBugReportFile (const char * fileName) { strcpy_s (BugReportFile, fileName); }
85
85
86
- bool xrDebug::GetNextStackFrameString (LPSTACKFRAME stackFrame, PCONTEXT threadCtx, xr_string& frameStr)
86
+ bool xrDebug::GetNextStackFrameString (LPSTACKFRAME stackFrame, PCONTEXT threadCtx, xr_string & frameStr)
87
87
{
88
88
BOOL result = StackWalk (MACHINE_TYPE, GetCurrentProcess (), GetCurrentThread (), stackFrame, threadCtx, nullptr ,
89
89
SymFunctionTableAccess, SymGetModuleBase, nullptr );
@@ -140,7 +140,7 @@ bool xrDebug::GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCt
140
140
// / Source info
141
141
// /
142
142
DWORD dwLineOffset;
143
- IMAGEHLP_LINE sourceInfo = { 0 };
143
+ IMAGEHLP_LINE sourceInfo = {};
144
144
sourceInfo.SizeOfStruct = sizeof (sourceInfo);
145
145
146
146
result = SymGetLineFromAddr (GetCurrentProcess (), stackFrame->AddrPC .Offset , &dwLineOffset, &sourceInfo);
@@ -164,36 +164,36 @@ bool xrDebug::GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCt
164
164
165
165
bool xrDebug::InitializeSymbolEngine ()
166
166
{
167
- if (!m_SymEngineInitialized )
167
+ if (!symEngineInitialized )
168
168
{
169
169
DWORD dwOptions = SymGetOptions ();
170
170
SymSetOptions (dwOptions | SYMOPT_DEFERRED_LOADS | SYMOPT_LOAD_LINES | SYMOPT_UNDNAME);
171
171
172
172
if (SymInitialize (GetCurrentProcess (), nullptr , TRUE ))
173
173
{
174
- m_SymEngineInitialized = true ;
174
+ symEngineInitialized = true ;
175
175
}
176
176
}
177
177
178
- return m_SymEngineInitialized ;
178
+ return symEngineInitialized ;
179
179
}
180
180
181
181
void xrDebug::DeinitializeSymbolEngine (void )
182
182
{
183
- if (m_SymEngineInitialized )
183
+ if (symEngineInitialized )
184
184
{
185
185
SymCleanup (GetCurrentProcess ());
186
186
187
- m_SymEngineInitialized = false ;
187
+ symEngineInitialized = false ;
188
188
}
189
189
}
190
190
191
191
xr_vector<xr_string> xrDebug::BuildStackTrace (PCONTEXT threadCtx, u16 maxFramesCount)
192
192
{
193
- ScopeLock Lock (&m_DbgHelpLock );
193
+ ScopeLock Lock (&dbgHelpLock );
194
194
195
195
SStringVec traceResult;
196
- STACKFRAME stackFrame = { 0 };
196
+ STACKFRAME stackFrame = {};
197
197
xr_string frameStr;
198
198
199
199
if (!InitializeSymbolEngine ())
@@ -234,28 +234,28 @@ xr_vector<xr_string> xrDebug::BuildStackTrace(PCONTEXT threadCtx, u16 maxFramesC
234
234
235
235
SStringVec xrDebug::BuildStackTrace (u16 maxFramesCount)
236
236
{
237
- CONTEXT currentThreadCtx = { 0 };
237
+ CONTEXT currentThreadCtx = {};
238
238
239
239
RtlCaptureContext (¤tThreadCtx); // / GetThreadContext cann't be used on the current thread
240
240
currentThreadCtx.ContextFlags = CONTEXT_FULL;
241
241
242
242
return BuildStackTrace (¤tThreadCtx, maxFramesCount);
243
243
}
244
244
245
- void xrDebug::LogStackTrace (const char * header)
245
+ void xrDebug::LogStackTrace (const char * header)
246
246
{
247
247
SStringVec stackTrace = BuildStackTrace ();
248
248
Msg (" %s" , header);
249
- for (const auto & frame : stackTrace)
249
+ for (const auto & frame : stackTrace)
250
250
{
251
251
Msg (" %s" , frame.c_str ());
252
252
}
253
253
}
254
254
255
- void xrDebug::GatherInfo (char * assertionInfo, const ErrorLocation& loc, const char * expr, const char * desc,
256
- const char * arg1, const char * arg2)
255
+ void xrDebug::GatherInfo (char * assertionInfo, const ErrorLocation & loc, const char * expr, const char * desc,
256
+ const char * arg1, const char * arg2)
257
257
{
258
- char * buffer = assertionInfo;
258
+ char * buffer = assertionInfo;
259
259
if (!expr)
260
260
expr = " <no expression>" ;
261
261
bool extendedDesc = desc && strchr (desc, ' \n ' );
@@ -317,7 +317,7 @@ void xrDebug::GatherInfo(char* assertionInfo, const ErrorLocation& loc, const ch
317
317
os_clipboard::copy_to_clipboard (assertionInfo);
318
318
}
319
319
320
- void xrDebug::Fatal (const ErrorLocation& loc, const char * format, ...)
320
+ void xrDebug::Fatal (const ErrorLocation & loc, const char * format, ...)
321
321
{
322
322
string1024 desc;
323
323
va_list args;
@@ -328,14 +328,14 @@ void xrDebug::Fatal(const ErrorLocation& loc, const char* format, ...)
328
328
Fail (ignoreAlways, loc, nullptr , " fatal error" , desc);
329
329
}
330
330
331
- void xrDebug::Fail (
332
- bool & ignoreAlways, const ErrorLocation& loc, const char * expr, long hresult, const char * arg1, const char * arg2)
331
+ void xrDebug::Fail (bool &ignoreAlways, const ErrorLocation &loc, const char *expr, long hresult, const char *arg1,
332
+ const char * arg2)
333
333
{
334
334
Fail (ignoreAlways, loc, expr, xrDebug::ErrorToString (hresult), arg1, arg2);
335
335
}
336
336
337
- void xrDebug::Fail (bool & ignoreAlways, const ErrorLocation& loc, const char * expr, const char * desc, const char * arg1,
338
- const char * arg2)
337
+ void xrDebug::Fail (bool & ignoreAlways, const ErrorLocation & loc, const char * expr, const char * desc, const char * arg1,
338
+ const char * arg2)
339
339
{
340
340
#ifdef PROFILE_CRITICAL_SECTIONS
341
341
static Lock lock (MUTEX_PROFILE_ID (xrDebug::Backend));
@@ -393,13 +393,13 @@ void xrDebug::Fail(bool& ignoreAlways, const ErrorLocation& loc, const char* exp
393
393
lock.Leave ();
394
394
}
395
395
396
- void xrDebug::Fail (bool & ignoreAlways, const ErrorLocation& loc, const char * expr, const std::string& desc,
397
- const char * arg1, const char * arg2)
396
+ void xrDebug::Fail (bool & ignoreAlways, const ErrorLocation & loc, const char * expr, const std::string & desc,
397
+ const char * arg1, const char * arg2)
398
398
{
399
399
Fail (ignoreAlways, loc, expr, desc.c_str (), arg1, arg2);
400
400
}
401
401
402
- void xrDebug::DoExit (const std::string& message)
402
+ void xrDebug::DoExit (const std::string & message)
403
403
{
404
404
FlushLog ();
405
405
MessageBox (NULL , message.c_str (), " Error" , MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
@@ -408,7 +408,7 @@ void xrDebug::DoExit(const std::string& message)
408
408
409
409
LPCSTR xrDebug::ErrorToString (long code)
410
410
{
411
- const char * result = nullptr ;
411
+ const char * result = nullptr ;
412
412
static string1024 descStorage;
413
413
DXGetErrorDescription (code, descStorage, sizeof (descStorage));
414
414
if (!result)
@@ -476,7 +476,7 @@ void WINAPI xrDebug::PreErrorHandler(INT_PTR)
476
476
BT_SaveSnapshot (nullptr );
477
477
}
478
478
479
- void xrDebug::SetupExceptionHandler (const bool & dedicated)
479
+ void xrDebug::SetupExceptionHandler (const bool & dedicated)
480
480
{
481
481
// disable 'appname has stopped working' popup dialog
482
482
UINT prevMode = SetErrorMode (SEM_NOGPFAULTERRORBOX);
@@ -516,7 +516,7 @@ void xrDebug::SetupExceptionHandler(const bool& dedicated)
516
516
#endif // USE_BUG_TRAP
517
517
518
518
#ifdef USE_OWN_MINI_DUMP
519
- void xrDebug::SaveMiniDump (EXCEPTION_POINTERS* exPtrs)
519
+ void xrDebug::SaveMiniDump (EXCEPTION_POINTERS * exPtrs)
520
520
{
521
521
string64 dateStr;
522
522
timestamp (dateStr);
@@ -537,23 +537,23 @@ void xrDebug::SaveMiniDump(EXCEPTION_POINTERS* exPtrs)
537
537
}
538
538
#endif
539
539
540
- void xrDebug::FormatLastError (char * buffer, const size_t & bufferSize)
540
+ void xrDebug::FormatLastError (char * buffer, const size_t & bufferSize)
541
541
{
542
542
int lastErr = GetLastError ();
543
543
if (lastErr == ERROR_SUCCESS)
544
544
{
545
545
*buffer = 0 ;
546
546
return ;
547
547
}
548
- void * msg = nullptr ;
548
+ void * msg = nullptr ;
549
549
FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr , lastErr,
550
550
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&msg, 0 , nullptr );
551
551
// XXX nitrocaster: check buffer overflow
552
552
sprintf (buffer, " [error][%8d]: %s" , lastErr, (char *)msg);
553
553
LocalFree (msg);
554
554
}
555
555
556
- LONG WINAPI xrDebug::UnhandledFilter (EXCEPTION_POINTERS* exPtrs)
556
+ LONG WINAPI xrDebug::UnhandledFilter (EXCEPTION_POINTERS * exPtrs)
557
557
{
558
558
string256 errMsg;
559
559
FormatLastError (errMsg, sizeof (errMsg));
@@ -628,14 +628,14 @@ void _terminate()
628
628
}
629
629
#endif // USE_BUG_TRAP
630
630
631
- static void handler_base (const char * reason)
631
+ static void handler_base (const char * reason)
632
632
{
633
633
bool ignoreAlways = false ;
634
634
xrDebug::Fail (ignoreAlways, DEBUG_INFO, nullptr , reason, nullptr , nullptr );
635
635
}
636
636
637
- static void invalid_parameter_handler (
638
- const wchar_t * expression, const wchar_t * function, const wchar_t * file, unsigned int line, uintptr_t reserved)
637
+ static void invalid_parameter_handler (const wchar_t *expression, const wchar_t *function, const wchar_t *file,
638
+ unsigned int line, uintptr_t reserved)
639
639
{
640
640
bool ignoreAlways = false ;
641
641
string4096 mbExpression;
@@ -657,7 +657,7 @@ static void invalid_parameter_handler(
657
657
line = __LINE__;
658
658
xr_strcpy (mbFile, __FILE__);
659
659
}
660
- xrDebug::Fail (ignoreAlways, { mbFile, int (line), mbFunction }, mbExpression, " invalid parameter" );
660
+ xrDebug::Fail (ignoreAlways, {mbFile, int (line), mbFunction}, mbExpression, " invalid parameter" );
661
661
}
662
662
663
663
static void pure_call_handler () { handler_base (" pure virtual function call" ); }
@@ -692,7 +692,7 @@ void xrDebug::OnThreadSpawn()
692
692
#endif
693
693
}
694
694
695
- void xrDebug::Initialize (const bool & dedicated)
695
+ void xrDebug::Initialize (const bool & dedicated)
696
696
{
697
697
*BugReportFile = 0 ;
698
698
OnThreadSpawn ();
0 commit comments