diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-12-29 22:04:28 +0000 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-12-29 22:04:28 +0000 |
commit | 2770beb6af1a3bcf4d303f9a10ebaaefd15f01ce (patch) | |
tree | 85f7fcd085323e33a15ec13813a1dfc8166eb29b /NorthstarDedicatedTest | |
parent | 6ba46a717f4e71910891c88fa515cec2762c7ddf (diff) | |
download | NorthstarLauncher-2770beb6af1a3bcf4d303f9a10ebaaefd15f01ce.tar.gz NorthstarLauncher-2770beb6af1a3bcf4d303f9a10ebaaefd15f01ce.zip |
add proper stack traces to crash handler
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r-- | NorthstarDedicatedTest/logging.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/NorthstarDedicatedTest/logging.cpp b/NorthstarDedicatedTest/logging.cpp index 09ae6961..7791299d 100644 --- a/NorthstarDedicatedTest/logging.cpp +++ b/NorthstarDedicatedTest/logging.cpp @@ -118,7 +118,22 @@ long __stdcall ExceptionFilter(EXCEPTION_POINTERS* exceptionInfo) spdlog::error("Northstar has crashed! a minidump has been written and exception info is available below:"); spdlog::error(exceptionCause.str()); - spdlog::error("Address: {} + 0x{0:x}", crashedModuleName, crashedModuleOffset); + spdlog::error("At: {} + {}", crashedModuleName, (void*)crashedModuleOffset); + + PVOID framesToCapture[62]; + int frames = RtlCaptureStackBackTrace(0, 62, framesToCapture, NULL); + for (int i = 0; i < frames; i++) + { + HMODULE backtraceModuleHandle; + GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, static_cast<LPCSTR>(framesToCapture[i]), &backtraceModuleHandle); + + char backtraceModuleFullName[MAX_PATH]; + GetModuleFileNameExA(GetCurrentProcess(), backtraceModuleHandle, backtraceModuleFullName, MAX_PATH); + char* backtraceModuleName = strrchr(backtraceModuleFullName, '\\') + 1; + + spdlog::error(" {} + {}", backtraceModuleName, (void*)framesToCapture[i]); + } + spdlog::error("RAX: 0x{0:x}", exceptionContext->Rax); spdlog::error("RBX: 0x{0:x}", exceptionContext->Rbx); spdlog::error("RCX: 0x{0:x}", exceptionContext->Rcx); |