1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Fix for malformed (?) PDB issues

This commit is contained in:
Brian Fiete 2020-11-16 10:02:54 -08:00
parent 826a7e6fba
commit 3c131632b4
2 changed files with 27 additions and 20 deletions

View file

@ -503,6 +503,14 @@ DbgType* COFF::CvGetType(int typeId)
return type; return type;
} }
DbgType* COFF::CvGetTypeSafe(int typeId)
{
DbgType* type = CvGetType(typeId);
if (type != NULL)
return type;
return CvGetType(T_VOID);
}
DbgType* COFF::CvGetType(int typeId, CvCompileUnit* compileUnit) DbgType* COFF::CvGetType(int typeId, CvCompileUnit* compileUnit)
{ {
if ((typeId & 0x80000000) != 0) if ((typeId & 0x80000000) != 0)
@ -536,6 +544,10 @@ uint8* COFF::CvGetTagData(int tagIdx, bool ipi, int* outDataSize)
{ {
if (tagIdx == 0) if (tagIdx == 0)
return NULL; return NULL;
if ((ipi) && (tagIdx < mCvIPIMinTag))
return NULL;
if ((!ipi) && (tagIdx < mCvMinTag))
return NULL;
auto& reader = ipi ? mCvIPIReader : mCvTypeSectionReader; auto& reader = ipi ? mCvIPIReader : mCvTypeSectionReader;
int offset = ipi ? mCvIPITagStartMap[tagIdx - mCvIPIMinTag] : mCvTagStartMap[tagIdx - mCvMinTag]; int offset = ipi ? mCvIPITagStartMap[tagIdx - mCvIPIMinTag] : mCvTagStartMap[tagIdx - mCvMinTag];
@ -647,15 +659,12 @@ DbgSubprogram* COFF::CvParseMethod(DbgType* parentType, const char* methodName,
BP_ZONE("COFF::CvParseMethod"); BP_ZONE("COFF::CvParseMethod");
uint8* data = CvGetTagData(tagIdx, ipi); uint8* data = CvGetTagData(tagIdx, ipi);
if (data == NULL)
return NULL;
CvAutoReleaseTempData releaseTempData(this, data); CvAutoReleaseTempData releaseTempData(this, data);
bool fromTypeSection = methodName != NULL; bool fromTypeSection = methodName != NULL;
if ((methodName != NULL) && (strcmp(methodName, "GetLength") == 0))
{
NOP;
}
uint8* dataStart = data; uint8* dataStart = data;
int16 trLeafType = GET(int16); int16 trLeafType = GET(int16);
@ -672,11 +681,6 @@ DbgSubprogram* COFF::CvParseMethod(DbgType* parentType, const char* methodName,
auto parentType = CvGetType(funcData->parentType); auto parentType = CvGetType(funcData->parentType);
//subprogram = CvParseMethod(parentType, (const char*)funcData->name, funcData->type, false, subprogram); //subprogram = CvParseMethod(parentType, (const char*)funcData->name, funcData->type, false, subprogram);
if ((funcData->name != NULL) && (strcmp((const char*)funcData->name, "CalcNewSize") == 0))
{
NOP;
}
// We shouldn't pass parentType in there, because that would be the declType and not the actual primary type (ie: definition type) // We shouldn't pass parentType in there, because that would be the declType and not the actual primary type (ie: definition type)
subprogram = CvParseMethod(NULL, (const char*)funcData->name, funcData->type, false, subprogram); subprogram = CvParseMethod(NULL, (const char*)funcData->name, funcData->type, false, subprogram);
return subprogram; return subprogram;
@ -1630,7 +1634,7 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi)
lfPointer* pointerInfo = (lfPointer*)dataStart; lfPointer* pointerInfo = (lfPointer*)dataStart;
dbgType = CvCreateType(); dbgType = CvCreateType();
dbgType->mTypeParam = CvGetType(pointerInfo->utype); dbgType->mTypeParam = CvGetTypeSafe(pointerInfo->utype);
if (pointerInfo->attr.ptrmode == CV_PTR_MODE_RVREF) if (pointerInfo->attr.ptrmode == CV_PTR_MODE_RVREF)
dbgType->mTypeCode = DbgType_RValueReference; dbgType->mTypeCode = DbgType_RValueReference;
else if (pointerInfo->attr.ptrmode == CV_PTR_MODE_LVREF) else if (pointerInfo->attr.ptrmode == CV_PTR_MODE_LVREF)
@ -2183,7 +2187,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
if (strcmp(name, "this") == 0) if (strcmp(name, "this") == 0)
{ {
MakeThis(curSubprogram, localVar); MakeThis(curSubprogram, localVar);
BF_ASSERT(varType->mTypeCode == DbgType_Ptr); //BF_ASSERT(varType->mTypeCode == DbgType_Ptr);
curSubprogram->mParentType = varType->mTypeParam; curSubprogram->mParentType = varType->mTypeParam;
curSubprogram->mHasThis = true; curSubprogram->mHasThis = true;
} }
@ -2530,13 +2534,8 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
auto addr = GetSectionAddr(procSym->seg, procSym->off); auto addr = GetSectionAddr(procSym->seg, procSym->off);
DbgSubprogram* subprogram; DbgSubprogram* subprogram = NULL;
if (procSym->typind == 0) if (procSym->typind != 0)
{
BP_ALLOC_T(DbgSubprogram);
subprogram = mAlloc.Alloc<DbgSubprogram>();
}
else
{ {
bool ipi = false; bool ipi = false;
if ((!IsObjectFile()) && if ((!IsObjectFile()) &&
@ -2548,6 +2547,13 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
} }
subprogram = CvParseMethod(parentType, NULL, procSym->typind, ipi); subprogram = CvParseMethod(parentType, NULL, procSym->typind, ipi);
} }
if (subprogram == NULL)
{
BP_ALLOC_T(DbgSubprogram);
subprogram = mAlloc.Alloc<DbgSubprogram>();
}
subprogram->mTagIdx = (int)(dataEnd - sectionData); // Position for method data subprogram->mTagIdx = (int)(dataEnd - sectionData); // Position for method data
subprogram->mIsOptimized = isOptimized; subprogram->mIsOptimized = isOptimized;
subprogram->mCompileUnit = compileUnit; subprogram->mCompileUnit = compileUnit;

View file

@ -357,6 +357,7 @@ public:
int64 CvParseConstant(uint16 constVal, uint8*& data); int64 CvParseConstant(uint16 constVal, uint8*& data);
int64 CvParseConstant(uint8*& data); int64 CvParseConstant(uint8*& data);
DbgType* CvGetType(int typeId); DbgType* CvGetType(int typeId);
DbgType* CvGetTypeSafe(int typeId);
DbgType* CvGetType(int typeId, CvCompileUnit* compileUnit); DbgType* CvGetType(int typeId, CvCompileUnit* compileUnit);
int CvGetTagStart(int tagIdx, bool ipi); int CvGetTagStart(int tagIdx, bool ipi);
int CvGetTagSize(int tagIdx, bool ipi); int CvGetTagSize(int tagIdx, bool ipi);