[*] Win32: improve reporting of critical exceptions
This commit is contained in:
parent
752d67c0ff
commit
a7730ed8ee
@ -45,66 +45,72 @@ namespace Aurora::Debug
|
|||||||
{
|
{
|
||||||
AuString message;
|
AuString message;
|
||||||
|
|
||||||
if (handle != INVALID_HANDLE_VALUE)
|
if (throwInfo)
|
||||||
{
|
{
|
||||||
try
|
if (handle != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
const ThrowInfo *pthrowInfo = reinterpret_cast<const ThrowInfo *>(throwInfo);
|
try
|
||||||
auto attribs = pthrowInfo->attributes;
|
|
||||||
|
|
||||||
const auto catchableTypeArray = reinterpret_cast<const CatchableTypeArray *>(reinterpret_cast<AuUInt>(handle) + (AuUInt)(pthrowInfo->pCatchableTypeArray));
|
|
||||||
|
|
||||||
AuString suffix;
|
|
||||||
for (int i = 0; i < catchableTypeArray->nCatchableTypes; i++)
|
|
||||||
{
|
{
|
||||||
const auto type = reinterpret_cast<CatchableType *> (reinterpret_cast<AuUInt>(handle) + (AuUInt)(catchableTypeArray->arrayOfCatchableTypes[i]));
|
const ThrowInfo *pthrowInfo = reinterpret_cast<const ThrowInfo *>(throwInfo);
|
||||||
const auto descriptor = reinterpret_cast<std::type_info *> (reinterpret_cast<AuUInt>(handle) + (AuUInt)(type->pType));
|
auto attribs = pthrowInfo->attributes;
|
||||||
|
|
||||||
message += (i == 0 ? "" : AuString(", ")) + descriptor->name(); // __std_type_info_name
|
const auto catchableTypeArray = reinterpret_cast<const CatchableTypeArray *>(reinterpret_cast<AuUInt>(handle) + (AuUInt)(pthrowInfo->pCatchableTypeArray));
|
||||||
|
|
||||||
if (_strnicmp(descriptor->raw_name(), ".?AVException@", 15 - 1) == 0)
|
AuString suffix;
|
||||||
|
for (int i = 0; i < catchableTypeArray->nCatchableTypes; i++)
|
||||||
{
|
{
|
||||||
auto exception2 = reinterpret_cast<std::exception *>(exception);
|
const auto type = reinterpret_cast<CatchableType *> (reinterpret_cast<AuUInt>(handle) + (AuUInt)(catchableTypeArray->arrayOfCatchableTypes[i]));
|
||||||
auto wptr = exception2->what();
|
const auto descriptor = reinterpret_cast<std::type_info *> (reinterpret_cast<AuUInt>(handle) + (AuUInt)(type->pType));
|
||||||
if (wptr)
|
|
||||||
|
message += (i == 0 ? "" : AuString(", ")) + descriptor->name(); // __std_type_info_name
|
||||||
|
|
||||||
|
if (_strnicmp(descriptor->raw_name(), ".?AVException@", 15 - 1) == 0)
|
||||||
{
|
{
|
||||||
suffix = wptr;
|
auto exception2 = reinterpret_cast<std::exception *>(exception);
|
||||||
}
|
auto wptr = exception2->what();
|
||||||
}
|
if (wptr)
|
||||||
else if (_strnicmp(descriptor->raw_name(), ".PEAD", 5) == 0)
|
|
||||||
{
|
|
||||||
auto possibleStringPointer = reinterpret_cast<const char **>(exception);
|
|
||||||
if (IsReadable(possibleStringPointer))
|
|
||||||
{
|
|
||||||
auto string = *possibleStringPointer;
|
|
||||||
if (IsReadable(string) && (strnlen(string, 4096) < 1024))
|
|
||||||
{
|
{
|
||||||
suffix = string;
|
suffix = wptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (_strnicmp(descriptor->raw_name(), ".PEAD", 5) == 0)
|
||||||
|
{
|
||||||
|
auto possibleStringPointer = reinterpret_cast<const char **>(exception);
|
||||||
|
if (IsReadable(possibleStringPointer))
|
||||||
|
{
|
||||||
|
auto string = *possibleStringPointer;
|
||||||
|
if (IsReadable(string) && (strnlen(string, 4096) < 1024))
|
||||||
|
{
|
||||||
|
suffix = string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (_strnicmp(descriptor->raw_name(), kStringRawName.data(), kStringRawName.size()) == 0)
|
||||||
|
{
|
||||||
|
auto possibleStdStringPointer = reinterpret_cast<std::string *>(exception);
|
||||||
|
if (IsReadable(possibleStdStringPointer))
|
||||||
|
{
|
||||||
|
suffix = *possibleStdStringPointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_strnicmp(descriptor->raw_name(), kStringRawName.data(), kStringRawName.size()) == 0)
|
|
||||||
|
if (suffix.size())
|
||||||
{
|
{
|
||||||
auto possibleStdStringPointer = reinterpret_cast<std::string *>(exception);
|
message += AuString("\r\n ") + suffix;
|
||||||
if (IsReadable(possibleStdStringPointer))
|
|
||||||
{
|
|
||||||
suffix = *possibleStdStringPointer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (...)
|
||||||
if (suffix.size())
|
|
||||||
{
|
{
|
||||||
message += AuString("\r\n ") + suffix;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.find("invalid sto") != AuString::npos) return message;
|
if (message.find("invalid sto") != AuString::npos)
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -261,23 +261,21 @@ namespace Aurora::Debug
|
|||||||
|
|
||||||
doReportLocal = [&]()
|
doReportLocal = [&]()
|
||||||
{
|
{
|
||||||
if (pThrowInfo)
|
ReportSEH(handle, exception, pThrowInfo, handleNoCppObject, backtrace, [&](const AuString &str)
|
||||||
{
|
{
|
||||||
ReportSEH(handle, exception, pThrowInfo, handleNoCppObject, backtrace, [&](const AuString &str)
|
// Pre-submit callback -> its showtime
|
||||||
|
if ((isCritical || kShouldPrintErrors) && (minimal == 0))
|
||||||
{
|
{
|
||||||
// Pre-submit callback -> its showtime
|
if (gRuntimeConfig.debug.bPrintExceptionStackTracesOut)
|
||||||
if ((isCritical || kShouldPrintErrors) && (minimal == 0))
|
|
||||||
{
|
{
|
||||||
if (gRuntimeConfig.debug.bPrintExceptionStackTracesOut)
|
AuLogWarn("NT Exception: 0x{:x}, {}", ExceptionInfo->ExceptionRecord->ExceptionCode, str);
|
||||||
{
|
AuLogWarn("{}", StringifyStackTrace(backtrace));
|
||||||
AuLogWarn("NT Exception: 0x{:x}, {}", ExceptionInfo->ExceptionRecord->ExceptionCode, str);
|
|
||||||
AuLogWarn("{}", StringifyStackTrace(backtrace));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
};
|
};
|
||||||
doReportLocal();
|
|
||||||
|
ReportStackTrace(backtrace, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pThread = AuThreads::GetThread();
|
auto pThread = AuThreads::GetThread();
|
||||||
|
Loading…
Reference in New Issue
Block a user