mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 18:16:45 +02:00
documenting the magic numbers a bit better (or just giving them names)
This commit is contained in:
parent
7038cfdeb3
commit
9af8b6b452
1 changed files with 18 additions and 5 deletions
|
@ -49,6 +49,9 @@ using namespace crashpad;
|
||||||
static const std::string BACKTRACE_URL { CMAKE_BACKTRACE_URL };
|
static const std::string BACKTRACE_URL { CMAKE_BACKTRACE_URL };
|
||||||
static const std::string BACKTRACE_TOKEN { CMAKE_BACKTRACE_TOKEN };
|
static const std::string BACKTRACE_TOKEN { CMAKE_BACKTRACE_TOKEN };
|
||||||
|
|
||||||
|
static constexpr DWORD STATUS_MSVC_CPP_EXCEPTION = 0xE06D7363;
|
||||||
|
static constexpr ULONG_PTR MSVC_CPP_EXCEPTION_SIGNATURE = 0x19930520;
|
||||||
|
|
||||||
CrashpadClient* client { nullptr };
|
CrashpadClient* client { nullptr };
|
||||||
std::mutex annotationMutex;
|
std::mutex annotationMutex;
|
||||||
crashpad::SimpleStringDictionary* crashpadAnnotations { nullptr };
|
crashpad::SimpleStringDictionary* crashpadAnnotations { nullptr };
|
||||||
|
@ -76,7 +79,7 @@ LONG WINAPI vectoredExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo) {
|
||||||
client->DumpAndCrash(pExceptionInfo);
|
client->DumpAndCrash(pExceptionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pExceptionInfo->ExceptionRecord->ExceptionCode == 0xE06D7363) {
|
if (pExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_MSVC_CPP_EXCEPTION) {
|
||||||
fatalCxxException(pExceptionInfo);
|
fatalCxxException(pExceptionInfo);
|
||||||
client->DumpAndCrash(pExceptionInfo);
|
client->DumpAndCrash(pExceptionInfo);
|
||||||
}
|
}
|
||||||
|
@ -121,21 +124,27 @@ struct CatchableTypeArray_internal {
|
||||||
// mess at crashpad
|
// mess at crashpad
|
||||||
void fatalCxxException(PEXCEPTION_POINTERS pExceptionInfo) {
|
void fatalCxxException(PEXCEPTION_POINTERS pExceptionInfo) {
|
||||||
PEXCEPTION_RECORD ExceptionRecord = pExceptionInfo->ExceptionRecord;
|
PEXCEPTION_RECORD ExceptionRecord = pExceptionInfo->ExceptionRecord;
|
||||||
|
/*
|
||||||
|
Exception arguments for Microsoft C++ exceptions:
|
||||||
|
[0] signature - magic number
|
||||||
|
[1] void* - variable that is being thrown
|
||||||
|
[2] ThrowInfo* - description of the variable that was thrown
|
||||||
|
[3] HMODULE - (64-bit only) base address that all 32bit pointers are added to
|
||||||
|
*/
|
||||||
|
|
||||||
if(ExceptionRecord->NumberParameters != 4 || ExceptionRecord->ExceptionInformation[0] != 0x19930520) {
|
if (ExceptionRecord->NumberParameters != 4 || ExceptionRecord->ExceptionInformation[0] != MSVC_CPP_EXCEPTION_SIGNATURE) {
|
||||||
// doesn't match expected parameter counts or magic numbers
|
// doesn't match expected parameter counts or magic numbers
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ULONG_PTR signature = ExceptionRecord->ExceptionInformation[0];
|
// get the ThrowInfo struct from the exception arguments
|
||||||
void* pExceptionObject = reinterpret_cast<void*>(ExceptionRecord->ExceptionInformation[1]); // the object that generated the exception
|
|
||||||
ThrowInfo_internal* pThrowInfo = reinterpret_cast<ThrowInfo_internal*>(ExceptionRecord->ExceptionInformation[2]);
|
ThrowInfo_internal* pThrowInfo = reinterpret_cast<ThrowInfo_internal*>(ExceptionRecord->ExceptionInformation[2]);
|
||||||
ULONG_PTR moduleBase = ExceptionRecord->ExceptionInformation[3];
|
ULONG_PTR moduleBase = ExceptionRecord->ExceptionInformation[3];
|
||||||
if(moduleBase == 0 || pThrowInfo == NULL) {
|
if(moduleBase == 0 || pThrowInfo == NULL) {
|
||||||
return; // broken assumption
|
return; // broken assumption
|
||||||
}
|
}
|
||||||
|
|
||||||
// now we start breaking the pThrowInfo internal structure apart
|
// get the CatchableTypeArray* struct from ThrowInfo
|
||||||
if(pThrowInfo->pCatchableTypeArray == 0) {
|
if(pThrowInfo->pCatchableTypeArray == 0) {
|
||||||
return; // broken assumption
|
return; // broken assumption
|
||||||
}
|
}
|
||||||
|
@ -143,6 +152,8 @@ void fatalCxxException(PEXCEPTION_POINTERS pExceptionInfo) {
|
||||||
if(pCatchableTypeArray->nCatchableTypes == 0 || pCatchableTypeArray->arrayOfCatchableTypes[0] == 0) {
|
if(pCatchableTypeArray->nCatchableTypes == 0 || pCatchableTypeArray->arrayOfCatchableTypes[0] == 0) {
|
||||||
return; // broken assumption
|
return; // broken assumption
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get the CatchableType struct for the actual exception type from CatchableTypeArray
|
||||||
CatchableType_internal* pCatchableType = reinterpret_cast<CatchableType_internal*>(moduleBase + pCatchableTypeArray->arrayOfCatchableTypes[0]);
|
CatchableType_internal* pCatchableType = reinterpret_cast<CatchableType_internal*>(moduleBase + pCatchableTypeArray->arrayOfCatchableTypes[0]);
|
||||||
if(pCatchableType->pType == 0) {
|
if(pCatchableType->pType == 0) {
|
||||||
return; // broken assumption
|
return; // broken assumption
|
||||||
|
@ -153,6 +164,8 @@ void fatalCxxException(PEXCEPTION_POINTERS pExceptionInfo) {
|
||||||
annotationMutex.try_lock();
|
annotationMutex.try_lock();
|
||||||
crashpadAnnotations->SetKeyValue("thrownObject", type->name());
|
crashpadAnnotations->SetKeyValue("thrownObject", type->name());
|
||||||
|
|
||||||
|
// After annotating the name of the actual object type, go through the other entries in CatcahleTypeArray and itemize the list of possible
|
||||||
|
// catch() commands that could have caught this so we can find the list of its superclasses
|
||||||
QString compatibleObjects;
|
QString compatibleObjects;
|
||||||
for (int catchTypeIdx = 1; catchTypeIdx < pCatchableTypeArray->nCatchableTypes; catchTypeIdx++) {
|
for (int catchTypeIdx = 1; catchTypeIdx < pCatchableTypeArray->nCatchableTypes; catchTypeIdx++) {
|
||||||
CatchableType_internal* pCatchableSuperclassType = reinterpret_cast<CatchableType_internal*>(moduleBase + pCatchableTypeArray->arrayOfCatchableTypes[catchTypeIdx]);
|
CatchableType_internal* pCatchableSuperclassType = reinterpret_cast<CatchableType_internal*>(moduleBase + pCatchableTypeArray->arrayOfCatchableTypes[catchTypeIdx]);
|
||||||
|
|
Loading…
Reference in a new issue