MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / save_mini_dump

Function save_mini_dump

ogsr_engine/xrCore/xrDebugNew.cpp:290–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288#pragma comment(lib, "dbghelp.lib")
289
290static void save_mini_dump(_EXCEPTION_POINTERS* pExceptionInfo)
291{
292 __try
293 {
294 string_path szDumpPath;
295 string64 t_stemp;
296
297 timestamp(t_stemp);
298 strcpy_s(szDumpPath, Core.ApplicationName);
299 strcat_s(szDumpPath, "_");
300 strcat_s(szDumpPath, Core.UserName);
301 strcat_s(szDumpPath, "_");
302 strcat_s(szDumpPath, t_stemp);
303 strcat_s(szDumpPath, ".mdmp");
304
305 __try
306 {
307 if (FS.path_exist("$logs$"))
308 FS.update_path(szDumpPath, "$logs$", szDumpPath);
309 }
310 __except (EXCEPTION_EXECUTE_HANDLER)
311 {
312 string_path temp;
313 strcpy_s(temp, szDumpPath);
314 strcpy_s(szDumpPath, "logs/");
315 strcat_s(szDumpPath, temp);
316 }
317
318 // create the file
319 auto hFile = ::CreateFile(szDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
320 if (INVALID_HANDLE_VALUE == hFile)
321 {
322 // try to place into current directory
323 MoveMemory(szDumpPath, szDumpPath + 5, strlen(szDumpPath));
324 hFile = ::CreateFile(szDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
325 }
326 if (hFile != INVALID_HANDLE_VALUE)
327 {
328 _MINIDUMP_EXCEPTION_INFORMATION ExInfo;
329
330 ExInfo.ThreadId = ::GetCurrentThreadId();
331 ExInfo.ExceptionPointers = pExceptionInfo;
332 ExInfo.ClientPointers = NULL;
333
334 // write the dump
335 auto dump_flags = MINIDUMP_TYPE(MiniDumpNormal | MiniDumpFilterMemory | MiniDumpScanMemory);
336
337 BOOL bOK = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, dump_flags, &ExInfo, nullptr, nullptr);
338 if (bOK)
339 Msg("--Saved dump file to [%s]", szDumpPath);
340 else
341 Msg("!!Failed to save dump file to [%s] (error [%s])", szDumpPath, Debug.error2string(GetLastError()));
342
343 ::CloseHandle(hFile);
344 }
345 else
346 {
347 Msg("!!Failed to create dump file [%s] (error [%s])", szDumpPath, Debug.error2string(GetLastError()));

Callers 1

UnhandledFilterFunction · 0.85

Calls 7

timestampFunction · 0.85
MoveMemoryFunction · 0.85
MsgFunction · 0.85
LogFunction · 0.85
path_existMethod · 0.80
error2stringMethod · 0.80
update_pathMethod · 0.45

Tested by

no test coverage detected