@@ -78,12 +78,12 @@ xrDebug::DialogHandler xrDebug::OnDialog = nullptr;
7878string_path xrDebug::BugReportFile;
7979bool xrDebug::ErrorAfterDialog = false ;
8080
81- bool xrDebug::m_SymEngineInitialized = false ;
82- Lock xrDebug::m_DbgHelpLock ;
81+ bool xrDebug::symEngineInitialized = false ;
82+ Lock xrDebug::dbgHelpLock ;
8383
84- void xrDebug::SetBugReportFile (const char * fileName) { strcpy_s (BugReportFile, fileName); }
84+ void xrDebug::SetBugReportFile (const char * fileName) { strcpy_s (BugReportFile, fileName); }
8585
86- bool xrDebug::GetNextStackFrameString (LPSTACKFRAME stackFrame, PCONTEXT threadCtx, xr_string& frameStr)
86+ bool xrDebug::GetNextStackFrameString (LPSTACKFRAME stackFrame, PCONTEXT threadCtx, xr_string & frameStr)
8787{
8888 BOOL result = StackWalk (MACHINE_TYPE, GetCurrentProcess (), GetCurrentThread (), stackFrame, threadCtx, nullptr ,
8989 SymFunctionTableAccess, SymGetModuleBase, nullptr );
@@ -140,7 +140,7 @@ bool xrDebug::GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCt
140140 // / Source info
141141 // /
142142 DWORD dwLineOffset;
143- IMAGEHLP_LINE sourceInfo = { 0 };
143+ IMAGEHLP_LINE sourceInfo = {};
144144 sourceInfo.SizeOfStruct = sizeof (sourceInfo);
145145
146146 result = SymGetLineFromAddr (GetCurrentProcess (), stackFrame->AddrPC .Offset , &dwLineOffset, &sourceInfo);
@@ -164,36 +164,36 @@ bool xrDebug::GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCt
164164
165165bool xrDebug::InitializeSymbolEngine ()
166166{
167- if (!m_SymEngineInitialized )
167+ if (!symEngineInitialized )
168168 {
169169 DWORD dwOptions = SymGetOptions ();
170170 SymSetOptions (dwOptions | SYMOPT_DEFERRED_LOADS | SYMOPT_LOAD_LINES | SYMOPT_UNDNAME);
171171
172172 if (SymInitialize (GetCurrentProcess (), nullptr , TRUE ))
173173 {
174- m_SymEngineInitialized = true ;
174+ symEngineInitialized = true ;
175175 }
176176 }
177177
178- return m_SymEngineInitialized ;
178+ return symEngineInitialized ;
179179}
180180
181181void xrDebug::DeinitializeSymbolEngine (void )
182182{
183- if (m_SymEngineInitialized )
183+ if (symEngineInitialized )
184184 {
185185 SymCleanup (GetCurrentProcess ());
186186
187- m_SymEngineInitialized = false ;
187+ symEngineInitialized = false ;
188188 }
189189}
190190
191191xr_vector<xr_string> xrDebug::BuildStackTrace (PCONTEXT threadCtx, u16 maxFramesCount)
192192{
193- ScopeLock Lock (&m_DbgHelpLock );
193+ ScopeLock Lock (&dbgHelpLock );
194194
195195 SStringVec traceResult;
196- STACKFRAME stackFrame = { 0 };
196+ STACKFRAME stackFrame = {};
197197 xr_string frameStr;
198198
199199 if (!InitializeSymbolEngine ())
@@ -234,28 +234,28 @@ xr_vector<xr_string> xrDebug::BuildStackTrace(PCONTEXT threadCtx, u16 maxFramesC
234234
235235SStringVec xrDebug::BuildStackTrace (u16 maxFramesCount)
236236{
237- CONTEXT currentThreadCtx = { 0 };
237+ CONTEXT currentThreadCtx = {};
238238
239239 RtlCaptureContext (¤tThreadCtx); // / GetThreadContext cann't be used on the current thread
240240 currentThreadCtx.ContextFlags = CONTEXT_FULL;
241241
242242 return BuildStackTrace (¤tThreadCtx, maxFramesCount);
243243}
244244
245- void xrDebug::LogStackTrace (const char * header)
245+ void xrDebug::LogStackTrace (const char * header)
246246{
247247 SStringVec stackTrace = BuildStackTrace ();
248248 Msg (" %s" , header);
249- for (const auto & frame : stackTrace)
249+ for (const auto & frame : stackTrace)
250250 {
251251 Msg (" %s" , frame.c_str ());
252252 }
253253}
254254
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)
257257{
258- char * buffer = assertionInfo;
258+ char * buffer = assertionInfo;
259259 if (!expr)
260260 expr = " <no expression>" ;
261261 bool extendedDesc = desc && strchr (desc, ' \n ' );
@@ -317,7 +317,7 @@ void xrDebug::GatherInfo(char* assertionInfo, const ErrorLocation& loc, const ch
317317 os_clipboard::copy_to_clipboard (assertionInfo);
318318}
319319
320- void xrDebug::Fatal (const ErrorLocation& loc, const char * format, ...)
320+ void xrDebug::Fatal (const ErrorLocation & loc, const char * format, ...)
321321{
322322 string1024 desc;
323323 va_list args;
@@ -328,14 +328,14 @@ void xrDebug::Fatal(const ErrorLocation& loc, const char* format, ...)
328328 Fail (ignoreAlways, loc, nullptr , " fatal error" , desc);
329329}
330330
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)
333333{
334334 Fail (ignoreAlways, loc, expr, xrDebug::ErrorToString (hresult), arg1, arg2);
335335}
336336
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)
339339{
340340#ifdef PROFILE_CRITICAL_SECTIONS
341341 static Lock lock (MUTEX_PROFILE_ID (xrDebug::Backend));
@@ -393,13 +393,13 @@ void xrDebug::Fail(bool& ignoreAlways, const ErrorLocation& loc, const char* exp
393393 lock.Leave ();
394394}
395395
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)
398398{
399399 Fail (ignoreAlways, loc, expr, desc.c_str (), arg1, arg2);
400400}
401401
402- void xrDebug::DoExit (const std::string& message)
402+ void xrDebug::DoExit (const std::string & message)
403403{
404404 FlushLog ();
405405 MessageBox (NULL , message.c_str (), " Error" , MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
@@ -408,7 +408,7 @@ void xrDebug::DoExit(const std::string& message)
408408
409409LPCSTR xrDebug::ErrorToString (long code)
410410{
411- const char * result = nullptr ;
411+ const char * result = nullptr ;
412412 static string1024 descStorage;
413413 DXGetErrorDescription (code, descStorage, sizeof (descStorage));
414414 if (!result)
@@ -476,7 +476,7 @@ void WINAPI xrDebug::PreErrorHandler(INT_PTR)
476476 BT_SaveSnapshot (nullptr );
477477}
478478
479- void xrDebug::SetupExceptionHandler (const bool & dedicated)
479+ void xrDebug::SetupExceptionHandler (const bool & dedicated)
480480{
481481 // disable 'appname has stopped working' popup dialog
482482 UINT prevMode = SetErrorMode (SEM_NOGPFAULTERRORBOX);
@@ -516,7 +516,7 @@ void xrDebug::SetupExceptionHandler(const bool& dedicated)
516516#endif // USE_BUG_TRAP
517517
518518#ifdef USE_OWN_MINI_DUMP
519- void xrDebug::SaveMiniDump (EXCEPTION_POINTERS* exPtrs)
519+ void xrDebug::SaveMiniDump (EXCEPTION_POINTERS * exPtrs)
520520{
521521 string64 dateStr;
522522 timestamp (dateStr);
@@ -537,23 +537,23 @@ void xrDebug::SaveMiniDump(EXCEPTION_POINTERS* exPtrs)
537537}
538538#endif
539539
540- void xrDebug::FormatLastError (char * buffer, const size_t & bufferSize)
540+ void xrDebug::FormatLastError (char * buffer, const size_t & bufferSize)
541541{
542542 int lastErr = GetLastError ();
543543 if (lastErr == ERROR_SUCCESS)
544544 {
545545 *buffer = 0 ;
546546 return ;
547547 }
548- void * msg = nullptr ;
548+ void * msg = nullptr ;
549549 FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr , lastErr,
550550 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&msg, 0 , nullptr );
551551 // XXX nitrocaster: check buffer overflow
552552 sprintf (buffer, " [error][%8d]: %s" , lastErr, (char *)msg);
553553 LocalFree (msg);
554554}
555555
556- LONG WINAPI xrDebug::UnhandledFilter (EXCEPTION_POINTERS* exPtrs)
556+ LONG WINAPI xrDebug::UnhandledFilter (EXCEPTION_POINTERS * exPtrs)
557557{
558558 string256 errMsg;
559559 FormatLastError (errMsg, sizeof (errMsg));
@@ -628,14 +628,14 @@ void _terminate()
628628}
629629#endif // USE_BUG_TRAP
630630
631- static void handler_base (const char * reason)
631+ static void handler_base (const char * reason)
632632{
633633 bool ignoreAlways = false ;
634634 xrDebug::Fail (ignoreAlways, DEBUG_INFO, nullptr , reason, nullptr , nullptr );
635635}
636636
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)
639639{
640640 bool ignoreAlways = false ;
641641 string4096 mbExpression;
@@ -657,7 +657,7 @@ static void invalid_parameter_handler(
657657 line = __LINE__;
658658 xr_strcpy (mbFile, __FILE__);
659659 }
660- xrDebug::Fail (ignoreAlways, { mbFile, int (line), mbFunction }, mbExpression, " invalid parameter" );
660+ xrDebug::Fail (ignoreAlways, {mbFile, int (line), mbFunction}, mbExpression, " invalid parameter" );
661661}
662662
663663static void pure_call_handler () { handler_base (" pure virtual function call" ); }
@@ -692,7 +692,7 @@ void xrDebug::OnThreadSpawn()
692692#endif
693693}
694694
695- void xrDebug::Initialize (const bool & dedicated)
695+ void xrDebug::Initialize (const bool & dedicated)
696696{
697697 *BugReportFile = 0 ;
698698 OnThreadSpawn ();
0 commit comments