Windows: Crash log: Add more exception details

This commit is contained in:
Jonathan G Rennison
2019-12-10 01:18:23 +00:00
parent 1029a03291
commit 0e82365938

View File

@@ -35,8 +35,10 @@
/* printf format specification for 32/64-bit addresses. */ /* printf format specification for 32/64-bit addresses. */
#ifdef _M_AMD64 #ifdef _M_AMD64
#define PRINTF_PTR "0x%016IX" #define PRINTF_PTR "0x%016IX"
#define PRINTF_LOC "%.16IX"
#else #else
#define PRINTF_PTR "0x%08X" #define PRINTF_PTR "0x%08X"
#define PRINTF_LOC "%.8IX"
#endif #endif
/** /**
@@ -108,21 +110,51 @@ public:
} }
static const char *GetAccessViolationTypeString(uint type)
{
switch (type) {
case 0:
return "read";
case 1:
return "write";
case 8:
return "user-mode DEP";
default:
return "???";
}
}
/* virtual */ char *CrashLogWindows::LogError(char *buffer, const char *last, const char *message) const /* virtual */ char *CrashLogWindows::LogError(char *buffer, const char *last, const char *message) const
{ {
return buffer + seprintf(buffer, last, buffer += seprintf(buffer, last, "Crash reason:\n");
"Crash reason:\n" for (auto record = ep->ExceptionRecord; record != nullptr; record = record->ExceptionRecord) {
" Exception: %.8X\n" buffer += seprintf(buffer, last,
#ifdef _M_AMD64 " Exception: %.8X\n"
" Location: %.16IX\n" " Location: " PRINTF_LOC "\n",
#else (int)record->ExceptionCode,
" Location: %.8X\n" (size_t)record->ExceptionAddress
#endif );
" Message: %s\n\n", if (record->ExceptionCode == 0xC0000005 && record->NumberParameters == 2) {
(int)ep->ExceptionRecord->ExceptionCode, buffer += seprintf(buffer, last,
(size_t)ep->ExceptionRecord->ExceptionAddress, " Fault type: %u (%s)\n"
message == nullptr ? "<none>" : message " Fault addr: " PRINTF_LOC "\n",
); (uint) record->ExceptionInformation[0],
GetAccessViolationTypeString(record->ExceptionInformation[0]),
record->ExceptionInformation[1]
);
} else {
for (uint i = 0; i < (uint) record->NumberParameters; i++) {
buffer += seprintf(buffer, last,
" Info %u: " PRINTF_LOC "\n",
i,
record->ExceptionInformation[i]
);
}
}
}
buffer += seprintf(buffer, last, " Message: %s\n\n",
message == nullptr ? "<none>" : message);
return buffer;
} }
struct DebugFileInfo { struct DebugFileInfo {