diff --git a/IDEHelper/COFF.cpp b/IDEHelper/COFF.cpp index 065c9eb5..323de26e 100644 --- a/IDEHelper/COFF.cpp +++ b/IDEHelper/COFF.cpp @@ -109,7 +109,7 @@ static const char* GetNamespaceEnd(const char* name) if ((c == '<') || (c == ' ')) return NULL; if ((c == ':') && (checkPtr[1] == ':')) - lastDblColon = checkPtr; + lastDblColon = checkPtr; } return lastDblColon; } @@ -163,7 +163,7 @@ uint8* CvStreamReader::GetTempPtr(int offset, int size, bool mayRecurse, bool* m if (pageStart >= pageEnd) return mStreamPtrs.mVals[pageStart] + (offset & ((1< 0) { @@ -193,7 +193,7 @@ uint8* CvStreamReader::GetTempPtr(int offset, int size, bool mayRecurse, bool* m memcpy(destPtr, mStreamPtrs.mVals[copyPage] + pageOffset, copyBytes); destPtr += copyBytes; offset += copyBytes; - size -= copyBytes; + size -= copyBytes; } return dest; } @@ -203,15 +203,15 @@ uint8* CvStreamReader::GetPermanentPtr(int offset, int size, bool* madeCopy) int pageStart = offset >> mPageBits; int pageEnd = (offset + size - 1) >> mPageBits; - if (pageStart == pageEnd) - return mStreamPtrs.mVals[pageStart] + (offset & ((1 << mPageBits) - 1)); - - // Handle the relatively-rare case of spanning multiple pages + if (pageStart == pageEnd) + return mStreamPtrs.mVals[pageStart] + (offset & ((1 << mPageBits) - 1)); + + // Handle the relatively-rare case of spanning multiple pages BP_ALLOC("GetPermanentPtr", size); uint8* destData = mCOFF->mAlloc.AllocBytes(size, "GetPermanentPtr"); if (madeCopy != NULL) *madeCopy = true; - + uint8* destPtr = destData; while (size > 0) { @@ -231,13 +231,13 @@ uint8* CvStreamReader::GetPermanentPtr(int offset, int size, bool* madeCopy) COFF::COFF(DebugTarget* debugTarget) : DbgModule(debugTarget) { mParseKind = ParseKind_Full; - memset(mWantPDBGuid, 0, 16); - memset(mPDBGuid, 0, 16); + memset(mWantPDBGuid, 0, 16); + memset(mPDBGuid, 0, 16); mWantAge = -1; mDebugAge = -1; mFileAge = -1; mCvMinTag = -1; - mCvMaxTag = -1; + mCvMaxTag = -1; mCvIPIMinTag = -1; mCvIPIMaxTag = -1; mMasterCompileUnit = NULL; @@ -247,8 +247,8 @@ COFF::COFF(DebugTarget* debugTarget) : DbgModule(debugTarget) mCvPageSize = 0; mCvPageBits = 31; mCvDataStream = NULL; - mCvHeaderData = NULL; - mCvStrTableData = NULL; + mCvHeaderData = NULL; + mCvStrTableData = NULL; mCvPublicSymbolData = NULL; mCvGlobalSymbolData = NULL; mNewFPOData = NULL; @@ -261,10 +261,10 @@ COFF::COFF(DebugTarget* debugTarget) : DbgModule(debugTarget) mCvMappedViewOfFile = NULL; mCvMappedFileSize = 0; //mParsedProcRecs = false; - + mGlobalsTargetType = NULL; mPrevScanName = NULL; - mProcSymCount = 0; + mProcSymCount = 0; mCvSrcSrvStream = -1; mCvEmitStream = -1; mIsFastLink = false; @@ -272,8 +272,8 @@ COFF::COFF(DebugTarget* debugTarget) : DbgModule(debugTarget) mHotThunkDataLeft = 0; mTriedSymSrv = false; - mDbgSymRequest = NULL; - mWantsAutoLoadDebugInfo = false; + mDbgSymRequest = NULL; + mWantsAutoLoadDebugInfo = false; mPDBLoaded = false; mEmitSourceFile = NULL; } @@ -282,7 +282,7 @@ COFF::~COFF() { BF_ASSERT(mTempBufIdx == 0); ClosePDB(); - mDebugger->mDbgSymSrv.ReleaseRequest(mDbgSymRequest); + mDebugger->mDbgSymSrv.ReleaseRequest(mDbgSymRequest); } const char* COFF::CvCheckTargetMatch(const char* name, bool& wasBeef) @@ -359,7 +359,7 @@ const char* COFF::CvCheckTargetMatch(const char* name, bool& wasBeef) } int COFF::CvGetStringHash(const char* str) -{ +{ if (str == NULL) return 0; @@ -367,7 +367,7 @@ int COFF::CvGetStringHash(const char* str) const char* curHashPtr = str; while (*curHashPtr != 0) { - char c = *curHashPtr; + char c = *curHashPtr; curHash = ((curHash ^ *curHashPtr) << 5) - curHash; curHashPtr++; } @@ -395,8 +395,8 @@ void COFF::CvFixupName(char* name) } } - if (cPtrOut != NULL) - *(cPtrOut++) = '\0'; + if (cPtrOut != NULL) + *(cPtrOut++) = '\0'; } void COFF::InitCvTypes() @@ -418,18 +418,18 @@ void COFF::InitCvTypes() #else const int ptrMask = 0x0600; // T_64* #endif - mMasterCompileUnit = new DbgCompileUnit(this); - mMasterCompileUnit->mDbgModule = this; + mMasterCompileUnit = new DbgCompileUnit(this); + mMasterCompileUnit->mDbgModule = this; mMasterCompileUnit->mIsMaster = true; mCompileUnits.push_back(mMasterCompileUnit); - + CREATE_PRIMITIVE(T_NOTTRANS, DbgType_Void, "void", void*); mCvSystemTypes[T_NOTTRANS]->mSize = 0; mCvSystemTypes[T_NOTTRANS]->mAlign = 0; CREATE_PRIMITIVE(T_NOTYPE, DbgType_Void, "void", void*); mCvSystemTypes[T_NOTYPE]->mSize = 0; mCvSystemTypes[T_NOTYPE]->mAlign = 0; - CREATE_PRIMITIVE(T_VOID, DbgType_Void, "void", void*); + CREATE_PRIMITIVE(T_VOID, DbgType_Void, "void", void*); mCvSystemTypes[T_VOID]->mSize = 0; mCvSystemTypes[T_VOID]->mAlign = 0; mCvSystemTypes[T_PVOID] = ptrType; @@ -444,7 +444,7 @@ void COFF::InitCvTypes() ptrType->mTypeParam = dbgType; dbgType->mPtrType = ptrType; mCvSystemTypes[(int)T_VOID | 0x0600] = ptrType; -#endif +#endif #ifdef BF_DBG_32 CREATE_PRIMITIVE(T_HRESULT, DbgType_u32, "HRESULT", addr_target); @@ -502,7 +502,7 @@ addr_target COFF::GetSectionAddr(uint16 section, uint32 offset) } DbgType* COFF::CvGetType(int typeId) -{ +{ //TODO: How do we handle types that have the high bit set? if (typeId < 0) return NULL; @@ -510,7 +510,7 @@ DbgType* COFF::CvGetType(int typeId) /*if (typeId == 0) return NULL;*/ if (typeId < 0x1000) - { + { TYPE_ENUM_e typeEnum = (TYPE_ENUM_e)typeId; DbgType* type = mCvSystemTypes[typeId]; BF_ASSERT(type != NULL); @@ -521,7 +521,7 @@ DbgType* COFF::CvGetType(int typeId) if (type == NULL) type = CvParseType(typeId); - /*if ((!allowNull) || (type != NULL)) + /*if ((!allowNull) || (type != NULL)) { BF_ASSERT(type->mCompileUnit->mDbgModule == this); }*/ @@ -577,7 +577,7 @@ uint8* COFF::CvGetTagData(int tagIdx, bool ipi, int* outDataSize) auto& reader = ipi ? mCvIPIReader : mCvTypeSectionReader; int offset = ipi ? mCvIPITagStartMap[tagIdx - mCvIPIMinTag] : mCvTagStartMap[tagIdx - mCvMinTag]; - + uint8* data = reader.GetTempPtr(offset, 4); uint16 trLength = *(uint16*)data; data = reader.GetTempPtr(offset + 2, trLength, true); @@ -616,16 +616,16 @@ int64 COFF::CvParseConstant(uint16 constVal, uint8*& data) int64 COFF::CvParseConstant(uint8*& data) { - uint16 val = GET(uint16); - return CvParseConstant(val, data); + uint16 val = GET(uint16); + return CvParseConstant(val, data); } const char* COFF::CvParseString(uint8*& data) -{ +{ const char* strStart = (const char*)data; int strLen = strlen((const char*)data); if (strLen == 0) - return NULL; + return NULL; data += strLen + 1; return strStart; } @@ -647,7 +647,7 @@ const char* COFF::CvParseAndDupString(uint8*& data) } const char* COFF::CvDupString(const char* str, int strLen) -{ +{ BP_ALLOC("CvDupString", strLen + 1); char* dupStr = (char*)mAlloc.AllocBytes(strLen + 1, "CvParseAndDupString"); memcpy(dupStr, str, strLen); @@ -660,18 +660,18 @@ void COFF::CvParseArgList(DbgSubprogram* subprogram, int tagIdx, bool ipi) uint8* data = CvGetTagData(tagIdx, ipi); CvAutoReleaseTempData releaseTempData(this, data); - int16 trLeafType = GET(int16); + int16 trLeafType = GET(int16); BF_ASSERT(trLeafType == LF_ARGLIST); - int argCount = GET(int32); + int argCount = GET(int32); for (int argIdx = 0; argIdx < argCount; argIdx++) { CV_typ_t argTypeId = GET(CV_typ_t); DbgType* argType = CvGetType(argTypeId); BP_ALLOC_T(DbgVariable); - DbgVariable* arg = mAlloc.Alloc(); + DbgVariable* arg = mAlloc.Alloc(); arg->mType = argType; arg->mIsParam = true; subprogram->mParams.PushBack(arg); @@ -693,10 +693,10 @@ DbgSubprogram* COFF::CvParseMethod(DbgType* parentType, const char* methodName, uint8* dataStart = data; int16 trLeafType = GET(int16); - + if (trLeafType == LF_FUNC_ID) { - lfFuncId* funcData = (lfFuncId*)dataStart; + lfFuncId* funcData = (lfFuncId*)dataStart; subprogram = CvParseMethod(NULL, (const char*)funcData->name, funcData->type, false, subprogram); return subprogram; } @@ -704,7 +704,7 @@ DbgSubprogram* COFF::CvParseMethod(DbgType* parentType, const char* methodName, if (trLeafType == LF_MFUNC_ID) { lfMFuncId* funcData = (lfMFuncId*)dataStart; - auto parentType = CvGetType(funcData->parentType); + auto parentType = CvGetType(funcData->parentType); //subprogram = CvParseMethod(parentType, (const char*)funcData->name, funcData->type, false, subprogram); // We shouldn't pass parentType in there, because that would be the declType and not the actual primary type (ie: definition type) @@ -712,7 +712,7 @@ DbgSubprogram* COFF::CvParseMethod(DbgType* parentType, const char* methodName, return subprogram; } - //DbgSubprogram* subprogram = mAlloc.Alloc(); + //DbgSubprogram* subprogram = mAlloc.Alloc(); if (subprogram == NULL) { BP_ALLOC_T(DbgSubprogram); @@ -720,13 +720,13 @@ DbgSubprogram* COFF::CvParseMethod(DbgType* parentType, const char* methodName, } subprogram->mName = methodName; - + int argListId = 0; if (trLeafType == LF_MFUNCTION) { static int gMFuncIdx = 0; gMFuncIdx++; - + lfMFunc* funcData = (lfMFunc*)dataStart; argListId = funcData->arglist; subprogram->mReturnType = CvGetType(funcData->rvtype); @@ -737,9 +737,9 @@ DbgSubprogram* COFF::CvParseMethod(DbgType* parentType, const char* methodName, DbgType* thisType = CvGetType(funcData->thistype); if ((thisType != NULL) && (!thisType->IsVoid())) - { + { BP_ALLOC_T(DbgVariable); - DbgVariable* arg = mAlloc.Alloc(); + DbgVariable* arg = mAlloc.Alloc(); arg->mType = thisType; arg->mIsParam = true; arg->mTagIdx = gMFuncIdx; @@ -769,20 +769,20 @@ DbgSubprogram* COFF::CvParseMethod(DbgType* parentType, const char* methodName, else if (trLeafType == LF_MFUNC_ID) { // - + } else { - SoftFail(StrFormat("Unhandled func type at tagId %d ipi %d", tagIdx, ipi)); + SoftFail(StrFormat("Unhandled func type at tagId %d ipi %d", tagIdx, ipi)); } if ((parentType != NULL) && (!IsObjectFile())) - { + { subprogram->mCompileUnit = parentType->mCompileUnit; parentType->mMethodList.PushBack(subprogram); } - + mSubprograms.push_back(subprogram); CvParseArgList(subprogram, argListId, ipi); return subprogram; @@ -796,7 +796,7 @@ void COFF::CvParseMethodList(DbgType* parentType, const char* methodName, int ta uint8* dataEnd = data + dataSize; int16 trLeafType = GET(int16); - + BF_ASSERT(trLeafType == LF_METHODLIST); while (data < dataEnd) @@ -820,10 +820,10 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) offset += 2; data = reader.GetTempPtr(offset, trLength, true); CvAutoReleaseTempData releaseTempData(this, data); - - uint8* dataStart = data; + + uint8* dataStart = data; uint8* dataEnd = data + trLength; - int16 trLeafType = GET(int16); + int16 trLeafType = GET(int16); bool strMadeCopy; auto _ParseString = [&]() @@ -840,7 +840,7 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) return; switch (trLeafType) { - case LF_FIELDLIST: + case LF_FIELDLIST: { uint8* sectionStart = data; @@ -853,7 +853,7 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) case LF_VFUNCTAB: { lfVFuncTab& vfuncTab = *(lfVFuncTab*)leafDataStart; - + DbgType* vtableType = CvGetType(vfuncTab.type); BP_ALLOC_T(DbgVariable); @@ -865,15 +865,15 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) } break; case LF_BCLASS: - { - lfBClass& baseClassInfo = *(lfBClass*)leafDataStart; + { + lfBClass& baseClassInfo = *(lfBClass*)leafDataStart; BP_ALLOC_T(DbgBaseTypeEntry); DbgBaseTypeEntry* baseTypeEntry = mAlloc.Alloc(); data = (uint8*)&baseClassInfo.offset; baseTypeEntry->mThisOffset = (int)CvParseConstant(data); if (baseClassInfo.index != 0) - { + { baseTypeEntry->mBaseType = CvGetType(baseClassInfo.index); // if (parentType->mLanguage == DbgLanguage_Beef) @@ -881,12 +881,12 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) // if (!parentType->mBaseTypes.IsEmpty()) // parentType->mTypeParam = baseTypeEntry->mBaseType; // } - + parentType->mBaseTypes.PushBack(baseTypeEntry); - parentType->mAlign = std::max(parentType->mAlign, baseTypeEntry->mBaseType->GetAlign()); - + parentType->mAlign = std::max(parentType->mAlign, baseTypeEntry->mBaseType->GetAlign()); + if (!parentType->mSizeCalculated) - { + { if ((baseTypeEntry->mBaseType->GetByteCount() == 0) && (baseTypeEntry->mBaseType->IsBfObject())) { parentType->mExtType = DbgExtType_Interface; @@ -899,9 +899,9 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) break; case LF_VBCLASS: case LF_IVBCLASS: - { + { lfVBClass& baseClassInfo = *(lfVBClass*)leafDataStart; - + BP_ALLOC_T(DbgBaseTypeEntry); DbgBaseTypeEntry* baseTypeEntry = mAlloc.Alloc(); baseTypeEntry->mBaseType = CvGetType(baseClassInfo.index); @@ -916,14 +916,14 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) { CV_fldattr_t fieldAttr = GET(CV_fldattr_t); int64 fieldVal = CvParseConstant(data); - - const char* fieldName = _ParseString(); - + + const char* fieldName = _ParseString(); + BP_ALLOC_T(DbgVariable); DbgVariable* member = mAlloc.Alloc(); member->mCompileUnit = parentType->mCompileUnit; member->mConstValue = fieldVal; - member->mName = fieldName; + member->mName = fieldName; member->mIsStatic = true; member->mIsConst = true; member->mType = parentType->mTypeParam; @@ -950,16 +950,16 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) nestedType->mTypeParam = CvGetType(nestedTypeId); nestedType->mTypeCode = DbgType_TypeDef; nestedType->mName = typeName; - nestedType->mTypeName = typeName; + nestedType->mTypeName = typeName; nestedType->mParent = parentType; parentType->mSubTypeList.PushBack(nestedType); }*/ int16 pad = GET(int16); int32 nestedTypeId = GET(int32); - + const char* typeName = _ParseString(); - + DbgType* nestedType = CvCreateType(); nestedType->mTypeParam = CvGetType(nestedTypeId); nestedType->mTypeCode = DbgType_TypeDef; @@ -967,20 +967,20 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) { nestedType->mName = typeName; nestedType->mTypeName = typeName; - } + } nestedType->mParent = parentType; - parentType->mSubTypeList.PushBack(nestedType); + parentType->mSubTypeList.PushBack(nestedType); } break; case LF_ONEMETHOD: { CV_fldattr_t attr = GET(CV_fldattr_t); CV_typ_t methodTypeId = GET(CV_typ_t); - + int virtOffset = -1; if ((attr.mprop == CV_MTintro) || (attr.mprop == CV_MTpureintro)) virtOffset = GET(int32); - const char* methodName = _ParseString(); + const char* methodName = _ParseString(); DbgSubprogram* subProgram = CvParseMethod(parentType, methodName, methodTypeId, ipi); subProgram->mVirtual = (attr.mprop == CV_MTintro) || (attr.mprop == CV_MTpureintro) || (attr.mprop == CV_MTvirtual); subProgram->mVTableLoc = virtOffset; @@ -1006,19 +1006,19 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) for (int methodIdx = 0; methodIdx < count; methodIdx++) { - CV_fldattr_t attr = GET_FROM(listData, CV_fldattr_t); + CV_fldattr_t attr = GET_FROM(listData, CV_fldattr_t); int16 unused = GET_FROM(listData, int16); CV_typ_t methodTypeId = GET_FROM(listData, CV_typ_t); int virtOffset = -1; if ((attr.mprop == CV_MTintro) || (attr.mprop == CV_MTpureintro)) virtOffset = GET_FROM(listData, int32); - DbgSubprogram* subProgram = CvParseMethod(parentType, methodName, methodTypeId, ipi); + DbgSubprogram* subProgram = CvParseMethod(parentType, methodName, methodTypeId, ipi); subProgram->mVirtual = (attr.mprop == CV_MTintro) || (attr.mprop == CV_MTpureintro) || (attr.mprop == CV_MTvirtual); subProgram->mVTableLoc = virtOffset; } } - break; + break; case LF_MEMBER: case LF_STMEMBER: { @@ -1026,7 +1026,7 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) bool isConst = false; CV_fldattr_t attr = GET(CV_fldattr_t); CV_typ_t fieldTypeId = GET(CV_typ_t); - + if (parentType->mTagIdx == 29184) { NOP; @@ -1035,7 +1035,7 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) int memberOffset = -1; if (isStatic) { - //? + //? } else { @@ -1049,18 +1049,23 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) { parentType->mTypeParam = CvGetType(fieldTypeId); parentType->mTypeParam = GetPrimitiveType(parentType->mTypeParam->mTypeCode, DbgLanguage_Beef); - + parentType->mSize = parentType->mTypeParam->mSize; parentType->mAlign = parentType->mTypeParam->mAlign; if ((parentType->mBaseTypes.mHead != NULL) && (strcmp(parentType->mBaseTypes.mHead->mBaseType->mName, "System.Enum") == 0)) parentType->mTypeCode = DbgType_Enum; break; } + + if (strncmp(fieldName, "$using$", 7) == 0) + { + fieldName = NULL; + } } int64 constVal = 0; - if ((parentType->mLanguage == DbgLanguage_Beef) && (isStatic)) - { + if ((fieldName != NULL) && (parentType->mLanguage == DbgLanguage_Beef) && (isStatic)) + { for (char* cPtr = fieldName; true; cPtr++) { char c = *cPtr; @@ -1087,52 +1092,52 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) break; } } - } + } if ((isStatic) && (!isConst) && (IsObjectFile())) { // Already has statics filled in break; - } + } BP_ALLOC_T(DbgVariable); DbgVariable* member = mAlloc.Alloc(); - member->mIsStatic = isStatic; + member->mIsStatic = isStatic; DbgType* fieldType = CvGetType(fieldTypeId); // if (fieldType == NULL) -// { +// { // uint8* fieldTypeData = CvGetTagData(fieldTypeId, ipi); // CvAutoReleaseTempData releaseTempData(this, fieldTypeData); -// +// // // It's a section data ptr // int16 memberLeafType = *((int16*)fieldTypeData); // switch (memberLeafType) // { // case LF_BITFIELD: -// { +// { // lfBitfield& bitfield = *(lfBitfield*)fieldTypeData; // fieldType = CvGetType(bitfield.type); -// -// // Bit offset is expressed in MSB form +// +// // Bit offset is expressed in MSB form // member->mBitOffset = (fieldType->mSize * 8) - bitfield.position - bitfield.length; // member->mBitSize = bitfield.length; // } // break; // default: // BF_FATAL("Unhandled"); -// } -// } +// } +// } if (fieldType == NULL) fieldType = CvGetType(fieldTypeId); - + if ((fieldType->mTypeCode == DbgType_Enum) && (fieldType->GetByteCount() == 0)) fieldType = fieldType->GetPrimaryType(); // if (fieldType->mTypeCode == DbgType_Bitfield) // { -// auto bitfieldType = (DbgBitfieldType*)fieldType; +// auto bitfieldType = (DbgBitfieldType*)fieldType; // member->mBitOffset = bitfieldType->mPosition; // member->mBitSize = bitfieldType->mLength; // fieldType = fieldType->mTypeParam; @@ -1145,13 +1150,13 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) } else if (isStatic) { - // NOP + // NOP } else member->mMemberOffset = memberOffset; member->mType = fieldType; - member->mCompileUnit = parentType->mCompileUnit; - member->mName = fieldName; + member->mCompileUnit = parentType->mCompileUnit; + member->mName = fieldName; // Size should already be set, right? It gets set on 'dataSize' in the LF_STRUCT/LF_CLASS //parentType->mSize = std::max(memberOffset + fieldType->mSize, parentType->mSize); @@ -1161,7 +1166,7 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) parentType->mAlign = std::max(parentType->mAlign, fieldType->GetAlign()); if (!parentType->mSizeCalculated) - { + { parentType->mSize = std::max(memberOffset + fieldType->GetByteCount(), parentType->mSize); } } @@ -1175,7 +1180,7 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi) if (isStatic) parentType->mNeedsGlobalsPopulated = true; } - break; + break; case LF_INDEX: { int _pad = (int)GET(uint16); @@ -1257,7 +1262,7 @@ int COFF::CvConvRegNum(int regNum, int* outBits) case CV_AMD64_DIL: if (outBits != NULL) *outBits = 8; return X64Reg_RDI; case CV_REG_DI: if (outBits != NULL) *outBits = 16; return X64Reg_RDI; case CV_REG_EDI: if (outBits != NULL) *outBits = 32; return X64Reg_RDI; - + case CV_AMD64_R8B: *outBits = 8; return X64Reg_R8; case CV_AMD64_R8W: *outBits = 16; return X64Reg_R8; case CV_AMD64_R8D: *outBits = 32; return X64Reg_R8; @@ -1378,7 +1383,7 @@ int COFF::CvConvRegNum(int regNum, int* outBits) // case CV_REG_XMM5: return X86Reg_XMM05; // case CV_REG_XMM6: return X86Reg_XMM06; // case CV_REG_XMM7: return X86Reg_XMM07; -#endif +#endif } return 0; // Nope @@ -1394,7 +1399,7 @@ DbgType* COFF::CvCreateType() DbgType* dbgType = mAlloc.Alloc(); dbgType->mCompileUnit = mMasterCompileUnit; dbgType->mTypeIdx = (int)linkedModule->mTypes.size(); - linkedModule->mTypes.push_back(dbgType); + linkedModule->mTypes.push_back(dbgType); return dbgType; } @@ -1436,21 +1441,21 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) int underlyingType = GET(int32); int typeIndex = GET(int32); const char* name = _ParseString(); - + dbgType = CvCreateType(); dbgType->mCompileUnit = mMasterCompileUnit; dbgType->mName = name; dbgType->mTypeName = name; - //SplitName(dbgType->mName, dbgType->mTypeName, dbgType->mTemplateParams); + //SplitName(dbgType->mName, dbgType->mTypeName, dbgType->mTemplateParams); dbgType->mTypeCode = DbgType_Enum; - dbgType->mTypeParam = CvGetTypeSafe(underlyingType); + dbgType->mTypeParam = CvGetTypeSafe(underlyingType); dbgType->mIsIncomplete = true; if (dbgType->mTypeParam->GetByteCount() == 0) dbgType->mIsDeclaration = true; dbgType->mSize = dbgType->mTypeParam->mSize; - dbgType->mAlign = dbgType->mTypeParam->mAlign; + dbgType->mAlign = dbgType->mTypeParam->mAlign; /*if (dbgType->mTypeParam->GetByteCount() == 0) { @@ -1485,19 +1490,19 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) dbgType->mTypeCode = DbgType_Bitfield; //bitfieldType->mPosition = (dbgType->mTypeParam->mSize * 8) - bitfield.position - bitfield.length; bitfieldType->mPosition = bitfield.position; - bitfieldType->mLength = bitfield.length; + bitfieldType->mLength = bitfield.length; bitfieldType->mSize = dbgType->mTypeParam->mSize; bitfieldType->mAlign = dbgType->mTypeParam->mAlign; dbgType->mSizeCalculated = true; dbgType->mPriority = DbgTypePriority_Unique; } break; - + case LF_CLASS: - case LF_STRUCTURE: + case LF_STRUCTURE: case LF_CLASS_EX: case LF_STRUCTURE_EX: - { + { unsigned short count; // count of number of elements in class CV_prop_t property; // property attribute field (prop_t) CV_typ_t field; // type index of LF_FIELD descriptor list @@ -1507,14 +1512,14 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) int16 extra = 0; if ((trLeafType == 0x1608) || (trLeafType == 0x1609)) - { + { property = GET(CV_prop_t); extra = GET(int16); field = GET(CV_typ_t); derived = GET(CV_typ_t); vshape = GET(CV_typ_t); count = GET(unsigned short); - dataSize = (int)CvParseConstant(data); + dataSize = (int)CvParseConstant(data); } else { @@ -1532,7 +1537,7 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) // { // NOP; // } - + // if ((strstr(name, "`") != NULL) || (strstr(name, "::__l") != NULL)) // { // OutputDebugStrF("Local type: %s\n", name); @@ -1590,7 +1595,7 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) else dbgType->mTypeCode = DbgType_Struct; - + DbgType* baseType = NULL; if (derived != 0) @@ -1598,7 +1603,7 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) baseType = CvGetTypeSafe(derived); BP_ALLOC_T(DbgBaseTypeEntry); DbgBaseTypeEntry* baseTypeEntry = mAlloc.Alloc(); - baseTypeEntry->mBaseType = baseType; + baseTypeEntry->mBaseType = baseType; dbgType->mBaseTypes.PushBack(baseTypeEntry); } @@ -1606,10 +1611,10 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) { dbgType->mAlign = 1; dbgType->mIsPacked = true; - } + } if (!dbgType->mIsDeclaration) - { + { dbgType->mSizeCalculated = true; dbgType->mSize = dataSize; @@ -1619,26 +1624,26 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) // some BF_MAX calculations we perform on it dbgType->mSizeCalculated = false; dbgType->mSize = 0; - } + } } - - if (vshape != 0) + + if (vshape != 0) { CvGetTypeSafe(vshape); - dbgType->mHasVTable = true; + dbgType->mHasVTable = true; } dbgType->mIsIncomplete = true; -// if (classInfo.field != 0) -// dbgType->mDefinedMembersSize = CvGetTagSize(classInfo.field, ipi); - +// if (classInfo.field != 0) +// dbgType->mDefinedMembersSize = CvGetTagSize(classInfo.field, ipi); + //CvParseMembers(dbgType, classInfo.field, sectionData); } break; case LF_UNION: - { - lfUnion& classInfo = *(lfUnion*)dataStart; + { + lfUnion& classInfo = *(lfUnion*)dataStart; data = (uint8*)&classInfo.data; int dataSize = (int)CvParseConstant(data); const char* name = _ParseString(); @@ -1649,8 +1654,8 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) dbgType->mName = name; dbgType->mTypeName = name; //SplitName(dbgType->mName, dbgType->mTypeName, dbgType->mTemplateParams); - dbgType->mTypeCode = DbgType_Union; - dbgType->mSize = dataSize; + dbgType->mTypeCode = DbgType_Union; + dbgType->mSize = dataSize; dbgType->mAlign = 1; dbgType->mSizeCalculated = !dbgType->mIsDeclaration; @@ -1660,7 +1665,7 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) break; case LF_MODIFIER: - { + { lfModifier& modifier = *(lfModifier*)dataStart; DbgType* outerType = CvGetTypeSafe(modifier.type); dbgType = outerType; @@ -1668,7 +1673,7 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) if (modifier.attr.MOD_const) { DbgType* innerType = dbgType; - dbgType = CvCreateType(); + dbgType = CvCreateType(); dbgType->mTypeParam = innerType; dbgType->mTypeCode = DbgType_Const; dbgType->mLanguage = innerType->mLanguage; @@ -1690,14 +1695,14 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) dbgType->mTypeParam = innerType; dbgType->mTypeCode = DbgType_Unaligned; dbgType->mLanguage = innerType->mLanguage; - } + } } break; case LF_POINTER: { lfPointer* pointerInfo = (lfPointer*)dataStart; - dbgType = CvCreateType(); + dbgType = CvCreateType(); dbgType->mTypeParam = CvGetTypeSafe(pointerInfo->utype); if (pointerInfo->attr.ptrmode == CV_PTR_MODE_RVREF) dbgType->mTypeCode = DbgType_RValueReference; @@ -1709,27 +1714,27 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) if ((dbgType->mTypeParam != NULL) && (dbgType->mTypeParam->mPtrType == NULL)) dbgType->mTypeParam->mPtrType = dbgType; } - //dbgType->mSize = pointerInfo->attr.size; + //dbgType->mSize = pointerInfo->attr.size; dbgType->mSize = sizeof(addr_target); dbgType->mAlign = dbgType->mSize; dbgType->mSizeCalculated = true; dbgType->mLanguage = dbgType->mTypeParam->mLanguage; - + /*if (prop.isconst) { DbgType* innerType = dbgType; - dbgType = CvCreateType(); + dbgType = CvCreateType(); dbgType->mTypeParam = innerType; dbgType->mTypeCode = DbgType_Const; dbgType->mSize = innerType->mSize; }*/ - //TODO: Handle const, volatile, ref, restrict, etc + //TODO: Handle const, volatile, ref, restrict, etc } break; case LF_DIMARRAY: { - + } break; case LF_ARRAY: @@ -1740,7 +1745,7 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) dbgType = CvCreateType(); dbgType->mTypeParam = CvGetTypeSafe(array->elemtype); - dbgType->mTypeCode = DbgType_SizedArray; + dbgType->mTypeCode = DbgType_SizedArray; dbgType->mLanguage = dbgType->mTypeParam->mLanguage; data = (uint8*)&array->data; @@ -1770,14 +1775,14 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) uint8* argData = CvGetTagData(proc->arglist, ipi); CvAutoReleaseTempData releaseTempData(this, argData); - int16 argLeafType = GET_FROM(argData, int16); + int16 argLeafType = GET_FROM(argData, int16); BF_ASSERT(argLeafType == LF_ARGLIST); int argCount = GET_FROM(argData, int32); CV_typ_t* argTypes = (CV_typ_t*)argData; for (int paramIdx = 0; paramIdx < proc->parmcount; paramIdx++) { BP_ALLOC_T(DbgVariable); - DbgVariable* arg = mAlloc.Alloc(); + DbgVariable* arg = mAlloc.Alloc(); arg->mIsParam = true; arg->mType = CvGetTypeSafe(argTypes[paramIdx]); arg->mName = "$arg"; @@ -1801,14 +1806,14 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi) uint8* argData = CvGetTagData(proc->arglist, ipi); CvAutoReleaseTempData releaseTempData(this, argData); - int16 argLeafType = GET_FROM(argData, int16); + int16 argLeafType = GET_FROM(argData, int16); BF_ASSERT(argLeafType == LF_ARGLIST); int argCount = GET_FROM(argData, int32); CV_typ_t* argTypes = (CV_typ_t*)argData; for (int paramIdx = 0; paramIdx < proc->parmcount; paramIdx++) { BP_ALLOC_T(DbgVariable); - DbgVariable* arg = mAlloc.Alloc(); + DbgVariable* arg = mAlloc.Alloc(); arg->mIsParam = true; arg->mType = CvGetTypeSafe(argTypes[paramIdx]); arg->mName = "$arg"; @@ -1857,7 +1862,7 @@ void COFF::ParseTypeData(CvStreamReader& reader, int dataOffset) break; if (offset >= reader.mSize) break; - + //OutputDebugStrF("%X %X\n", tagIdx, (int)(data - sectionData)); BF_ASSERT(((offset) & 3) == 0); @@ -1865,8 +1870,8 @@ void COFF::ParseTypeData(CvStreamReader& reader, int dataOffset) //PTR_ALIGN(data, sectionData, 4); uint8* data = reader.GetTempPtr(offset, 4); - uint16 trLength = *(uint16*)data; - uint16 trLeafType = *(uint16*)(data + 2); + uint16 trLength = *(uint16*)data; + uint16 trLeafType = *(uint16*)(data + 2); // uint16 trLength = GET(uint16); // uint8* dataStart = data; @@ -1907,7 +1912,7 @@ void COFF::ParseTypeData(int sectionNum, CvStreamReader& reader, int& sectionSiz // sectionData = CvReadStream(sectionNum, §ionSize); // if (sectionData == NULL) // return; -// uint8* data = sectionData; +// uint8* data = sectionData; CvReadStream(sectionNum, reader); uint8* data = reader.GetTempPtr(0, 0); @@ -1948,7 +1953,7 @@ void COFF::ParseTypeData(int sectionNum, CvStreamReader& reader, int& sectionSiz //////// Validate Type indices int typeIndexCount = hashTypeIndexSize / 8; - // We expect a TypeIndexOffset for every 8k of data, plus the zero at the start + // We expect a TypeIndexOffset for every 8k of data, plus the zero at the start int expectedTypeIndices = (sectionSize - (int)(data - sectionData)) / 8192 + 1; // Assert it's in some acceptable range... @@ -2069,11 +2074,11 @@ void COFF::ParseTypeData() int hashAdjOffset = 0; int32 hashStream = -1; int32 hashAdjSize = 0; - int32 dataOffset = 0; - + int32 dataOffset = 0; + ParseTypeData(2, mCvTypeSectionReader, sectionSize, dataOffset, hashStream, hashAdjOffset, hashAdjSize, mCvMinTag, mCvMaxTag); //mCvTypeSectionData = sectionData; - + mCvTypeMap.Clear(); mCvTagStartMap.Clear(); mCvTypeMap.Resize(mCvMaxTag - mCvMinTag); @@ -2105,7 +2110,7 @@ void COFF::ParseTypeData() GET_INTO(int32, unk3); } - // Types listed in the adjustment table are always primary types, + // Types listed in the adjustment table are always primary types, // they should override any "old types" with the same name for (int adjIdx = 0; adjIdx < adjustCount; adjIdx++) { @@ -2113,12 +2118,12 @@ void COFF::ParseTypeData() GET_INTO(CV_typ_t, typeId); DbgType* dbgType = CvGetType(typeId); if (dbgType != NULL) - { + { dbgType->mPriority = DbgTypePriority_Primary_Explicit; } } - delete [] sectionData; + delete [] sectionData; } FixTypes(startingTypeIdx); @@ -2140,14 +2145,14 @@ void COFF::FixConstant(DbgVariable* constVar) void COFF::MapRanges(DbgVariable* variable, CV_LVAR_ADDR_RANGE* range, CV_LVAR_ADDR_GAP* gaps) { auto rangeStart = GetSectionAddr(range->isectStart, range->offStart); - + if (variable->mRangeStart == 0) { - variable->mRangeStart = rangeStart; + variable->mRangeStart = rangeStart; variable->mRangeLen = (rangeStart + range->cbRange) - variable->mRangeStart; } else - { + { addr_target maxEnd = BF_MAX(variable->mRangeStart + variable->mRangeLen, rangeStart + range->cbRange); variable->mRangeStart = BF_MIN(variable->mRangeStart, rangeStart); variable->mRangeLen = maxEnd - variable->mRangeStart; @@ -2177,7 +2182,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD CvCompileUnit* cvCompileUnit = (CvCompileUnit*)compileUnit; uint8* symDataStart = data; - DbgSubprogram* curSubprogram = NULL; + DbgSubprogram* curSubprogram = NULL; DbgVariable* curRegRelVariable = NULL; DbgVariable* curParam = NULL; DbgVariable* localVar = NULL; @@ -2202,10 +2207,10 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD { mVariable = NULL; mRangedStart = NULL; - mRangedLength = 0; + mRangedLength = 0; } }; - SizedArray<_DeferredVariableLocation, 16> deferredVariableLocations; + SizedArray<_DeferredVariableLocation, 16> deferredVariableLocations; int unrangedIdx = -1; auto _NextUnrangedLocalVar = [&](const char* name, DbgType* varType) @@ -2213,7 +2218,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD inLocalVarRanged = false; localVar = NULL; - + unrangedIdx++; while (unrangedIdx < deferredVariableLocations.size()) { @@ -2222,7 +2227,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD break; localVar = NULL; unrangedIdx++; - } + } bool isParam = false; if (localVar == NULL) @@ -2252,7 +2257,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD blockStack.back()->mVariables.PushBack(localVar); //return; } - + localVar->mName = name; if (isParam) localVar->mIsParam = true; @@ -2311,7 +2316,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD deferredVariableLocation.mRangedLength = -1; // Mark as 'handled' } } - + locationDataStart = NULL; locationDataEnd = NULL; locationDataCount = 0; @@ -2322,7 +2327,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD for (auto& deferredVariableLocation : deferredVariableLocations) { if (deferredVariableLocation.mRangedLength == -1) - continue; + continue; auto deferredVar = deferredVariableLocation.mVariable; if (deferredVar->mLocationData != NULL) { @@ -2338,12 +2343,12 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD }; bool inlineDebugDump = false; - + if (useSubprogram != NULL) { curSubprogram = useSubprogram; blockStack.push_back(&curSubprogram->mBlock); - + curParam = curSubprogram->mParams.mHead; curRegRelVariable = curParam; } @@ -2382,7 +2387,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD } break; } - + /*if (handled) { data = dataEnd; @@ -2401,7 +2406,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD DbgType* typeDefType = CvCreateType(); typeDefType->mTypeCode = DbgType_TypeDef; typeDefType->mTypeParam = CvGetTypeSafe(udtSym.typind); - typeDefType->mName = DbgDupString((const char*)udtSym.name, "DbgDupString.S_UDT"); + typeDefType->mName = DbgDupString((const char*)udtSym.name, "DbgDupString.S_UDT"); if (strncmp(typeDefType->mName, "_bf::", 5) == 0) { typeDefType->mLanguage = DbgLanguage_Beef; @@ -2417,7 +2422,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD case S_OBJNAME: { GET_INTO(int32, objSig); - const char* objName = CvParseAndDupString(data); + const char* objName = CvParseAndDupString(data); } break; case S_CONSTANT: @@ -2435,7 +2440,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD data = constSym.name + strlen((const char*)constSym.name) + 1; constVar->mConstValue = CvParseConstant(constSym.value, data); FixConstant(constVar); - + if (constVar->mName != NULL) blockStack.back()->mVariables.PushBack(constVar); } @@ -2454,7 +2459,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD unsigned short reserved : 10; // Reserved. Must be zero. }; GET_INTO(ExpFlags, flags); - const char* symName = CvParseAndDupString(data); + const char* symName = CvParseAndDupString(data); } break; case S_GDATA32: @@ -2464,8 +2469,8 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD { auto linkedModule = GetLinkedModule(); DATASYM32& dataSym = *(DATASYM32*)dataStart; - - char* name = (char*)dataSym.name; + + char* name = (char*)dataSym.name; char* targetName = NULL; DbgType* targetType = mMasterCompileUnit->mGlobalType; bool overrideBeef = false; @@ -2475,7 +2480,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD targetName = name; name = lastDblColon + 2; *lastDblColon = 0; - + if (strcmp(targetName, "_bf") == 0) { overrideBeef = true; @@ -2485,12 +2490,12 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD targetType = CvGetTypeOrNamespace(targetName); } } - + DbgType* dbgType = CvGetTypeSafe(dataSym.typind); BP_ALLOC_T(DbgVariable); DbgVariable* variable = mAlloc.Alloc(); - variable->mType = dbgType; + variable->mType = dbgType; variable->mLocationData = dataStart; variable->mLocationLen = 1; variable->mIsStatic = true; @@ -2510,25 +2515,25 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD auto newPtr = mAlloc.Alloc(); memcpy(newPtr, variable->mLocationData, sizeof(DATASYM32)); variable->mLocationData = (uint8*)newPtr; - } + } if (variable->mName != NULL) blockStack.back()->mVariables.PushBack(variable); break; } - //variable->mCompileUnit = m; + //variable->mCompileUnit = m; // Push front so we will find before the original static declaration (that has no memory associated with it) if (targetType != NULL) targetType->mMemberList.PushFront(variable); - + if ((variable->mIsExtern) && (variable->mLinkName != NULL)) - mStaticVariables.push_back(variable); - } - break; + mStaticVariables.push_back(variable); + } + break; case S_GTHREAD32: case S_LTHREAD32: { - if ((IsObjectFile()) || (curSubprogram != NULL)) + if ((IsObjectFile()) || (curSubprogram != NULL)) { auto linkedModule = GetLinkedModule(); THREADSYM32& dataSym = *(THREADSYM32*)dataStart; @@ -2563,7 +2568,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD variable->mLocationLen = 1; variable->mIsStatic = true; variable->mCompileUnit = mMasterCompileUnit; - variable->mName = name; + variable->mName = name; if (targetType == mMasterCompileUnit->mGlobalType) variable->mLinkName = name; variable->mIsExtern = symType == S_GTHREAD32; @@ -2578,19 +2583,19 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD auto newPtr = mAlloc.Alloc(); memcpy(newPtr, variable->mLocationData, sizeof(DATASYM32)); variable->mLocationData = (uint8*)newPtr; - } + } if (variable->mName != NULL) blockStack.back()->mVariables.PushBack(variable); break; } - //variable->mCompileUnit = m; + //variable->mCompileUnit = m; // Push front so we will find before the original static declaration (that has no memory associated with it) targetType->mMemberList.PushFront(variable); if ((variable->mIsExtern) && (variable->mLinkName != NULL)) mStaticVariables.push_back(variable); - } + } } break; case S_GPROC32: @@ -2600,24 +2605,24 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD { BF_ASSERT(curSubprogram == NULL); - PROCSYM32* procSym = (PROCSYM32*)dataStart; + PROCSYM32* procSym = (PROCSYM32*)dataStart; DbgType* parentType = NULL; auto addr = GetSectionAddr(procSym->seg, procSym->off); - + DbgSubprogram* subprogram = NULL; - if (procSym->typind != 0) - { + if (procSym->typind != 0) + { bool ipi = false; - if ((!IsObjectFile()) && + if ((!IsObjectFile()) && ((symType == S_GPROC32_ID) || (symType == S_LPROC32_ID))) { if (!mCvIPIReader.IsSetup()) CvParseIPI(); ipi = true; - } - subprogram = CvParseMethod(parentType, NULL, procSym->typind, ipi); + } + subprogram = CvParseMethod(parentType, NULL, procSym->typind, ipi); } if (subprogram == NULL) @@ -2628,9 +2633,9 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD subprogram->mTagIdx = (int)(dataEnd - sectionData); // Position for method data subprogram->mIsOptimized = isOptimized; - subprogram->mCompileUnit = compileUnit; + subprogram->mCompileUnit = compileUnit; char* name = DbgDupString((const char*)procSym->name, "DbgDupString.S_GPROC32"); - + if (procSym->flags.CV_PFLAG_OPTDBGINFO) { subprogram->mIsOptimized = true; @@ -2666,23 +2671,23 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD subprogram->mCheckedKind = BfCheckedKind_Unchecked; *cPtr = NULL; break; - } + } } } - + subprogram->mPrologueSize = procSym->DbgStart; subprogram->mBlock.mLowPC = addr; subprogram->mBlock.mHighPC = subprogram->mBlock.mLowPC + (int32)procSym->len; BF_ASSERT(procSym->len >= 0); MapSubprogram(subprogram); - + curSubprogram = subprogram; curParam = subprogram->mParams.mHead; curRegRelVariable = curParam; blockStack.push_back(&subprogram->mBlock); //OutputDebugStrF("Func: %s\n", subprogram->mName); - + if (hasColon) { subprogram->mName = name; @@ -2694,7 +2699,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD subprogram->mName = name; compileUnit->mGlobalType->mMethodList.PushBack(curSubprogram); } - + BF_ASSERT(unrangedIdx == -1); } break; @@ -2704,9 +2709,9 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD DbgType* parentType = NULL; - DbgSubprogram* subprogram; + DbgSubprogram* subprogram; BP_ALLOC_T(DbgSubprogram); - subprogram = mAlloc.Alloc(); + subprogram = mAlloc.Alloc(); subprogram->mCompileUnit = compileUnit; subprogram->mHasQualifiedName = true; subprogram->mName = DbgDupString((const char*)thunkSym.name, "DbgDupString.S_THUNK32"); @@ -2717,7 +2722,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD BF_ASSERT(thunkSym.len >= 0); MapSubprogram(subprogram); - + curSubprogram = subprogram; curParam = subprogram->mParams.mHead; blockStack.push_back(&subprogram->mBlock); @@ -2734,7 +2739,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD deferBlockDepth++; break; } - + BP_ALLOC_T(DbgBlock); DbgBlock* block = mAlloc.Alloc(); blockStack.back()->mSubBlocks.PushBack(block); @@ -2748,7 +2753,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD break; case S_FRAMEPROC: { - FRAMEPROCSYM* frameProc = (FRAMEPROCSYM*)dataStart; + FRAMEPROCSYM* frameProc = (FRAMEPROCSYM*)dataStart; if (curSubprogram != NULL) { // if ((curSubprogram->mName != NULL) && (strcmp(curSubprogram->mName, "_bf::IDETest::HotTester::TestFuncs") == 0)) @@ -2774,7 +2779,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD _NextUnrangedLocalVar(name, varType); localVar->mName = name; - localVar->mCompileUnit = compileUnit; + localVar->mCompileUnit = compileUnit; localVar->mType = varType; // This is location data now, not just a S_LOCAL opener //prevLocalVar = localVar; @@ -2785,14 +2790,14 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD { if (deferInternals) break; - REGSYM* regSym = (REGSYM*)dataStart; + REGSYM* regSym = (REGSYM*)dataStart; const char* name = DbgDupString((const char*)regSym->name); DbgType* varType = CvGetTypeSafe(regSym->typind); _NextUnrangedLocalVar(name, varType); localVar->mName = name; - localVar->mCompileUnit = compileUnit; + localVar->mCompileUnit = compileUnit; localVar->mType = varType; // This is location data now, not just a S_LOCAL opener //prevLocalVar = localVar; @@ -2805,12 +2810,12 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD break; REGREL32* regRel32 = (REGREL32*)dataStart; const char* name = DbgDupString((const char*)regRel32->name); - DbgType* varType = CvGetTypeSafe(regRel32->typind); + DbgType* varType = CvGetTypeSafe(regRel32->typind); _NextUnrangedLocalVar(name, varType); localVar->mName = name; - localVar->mCompileUnit = compileUnit; + localVar->mCompileUnit = compileUnit; if ((localVar->mType != NULL) && (!localVar->mType->IsPointer()) && (varType != NULL) && (varType->IsPointer())) localVar->mSigNoPointer = true; localVar->mType = varType; @@ -2819,7 +2824,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD newLocalVarHasLocData = true; } break; - case S_LOCAL: + case S_LOCAL: { if (deferInternals) break; @@ -2828,7 +2833,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD LOCALSYM& localSym = *(LOCALSYM*)dataStart; char* name = DbgDupString((const char*)localSym.name); - + bool isConst = false; int64 constVal = 0; if ((compileUnit->mLanguage == DbgLanguage_Beef) && (name != NULL) && (name[0] != '$')) @@ -2844,7 +2849,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD { cPtr[1] = '-'; isConst = true; - constVal = atoll(cPtr + 1); + constVal = atoll(cPtr + 1); *cPtr = 0; } else if ((cPtr[1] >= '0') && (cPtr[1] <= '9')) @@ -2853,22 +2858,22 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD constVal = atoll(cPtr + 1); *cPtr = 0; } - } + } } } - + if ((name != NULL) && (name[0] == '#')) { if (strcmp(name + 1, "StepOver") == 0) { curSubprogram->mIsStepFilteredDefault = true; - } + } localVar = NULL; break; - } + } - DbgType* varType = CvGetType(localSym.typind, cvCompileUnit); + DbgType* varType = CvGetType(localSym.typind, cvCompileUnit); if (varType == NULL) varType = CvGetType(T_VOID); @@ -2891,11 +2896,11 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD bool handledLocalVar = false; if (curParam != NULL) - { + { if ((name != NULL) && (name[0] == '$')) { int strLen = strlen(name); - + // Splat head const char* dollarPos = strchr(name + 1, '$'); const char* nameStr = name + 1; @@ -2919,7 +2924,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD { // Type was different, probably from a 'ref' being added when we are passing composites curParam->mName = name; - curParam = curParam->mNext; + curParam = curParam->mNext; } else { @@ -2932,13 +2937,13 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD if (!handledLocalVar) { BP_ALLOC_T(DbgVariable); - localVar = mAlloc.Alloc(); + localVar = mAlloc.Alloc(); if (name != NULL) blockStack.back()->mVariables.PushBack(localVar); } localVar->mName = name; - localVar->mCompileUnit = compileUnit; + localVar->mCompileUnit = compileUnit; localVar->mType = varType; localVar->mIsConst = isConst; localVar->mConstValue = constVal; @@ -2954,22 +2959,22 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD break; DEFRANGESYMREGISTER& defRangeReg = *(DEFRANGESYMREGISTER*)dataStart; if (localVar != NULL) - MapRanges(localVar, &defRangeReg.range, defRangeReg.gaps); + MapRanges(localVar, &defRangeReg.range, defRangeReg.gaps); } - break; + break; case S_DEFRANGE_FRAMEPOINTER_REL: { if (deferInternals) break; - DEFRANGESYMFRAMEPOINTERREL& defRangeFPRel = *(DEFRANGESYMFRAMEPOINTERREL*)dataStart; - MapRanges(localVar, &defRangeFPRel.range, defRangeFPRel.gaps); + DEFRANGESYMFRAMEPOINTERREL& defRangeFPRel = *(DEFRANGESYMFRAMEPOINTERREL*)dataStart; + MapRanges(localVar, &defRangeFPRel.range, defRangeFPRel.gaps); } break; case S_DEFRANGE_SUBFIELD_REGISTER: { if (deferInternals) break; - DEFRANGESYMSUBFIELDREGISTER& defRangeSubFieldReg = *(DEFRANGESYMSUBFIELDREGISTER*)dataStart; + DEFRANGESYMSUBFIELDREGISTER& defRangeSubFieldReg = *(DEFRANGESYMSUBFIELDREGISTER*)dataStart; } break; case S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE: @@ -2985,7 +2990,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD break; DEFRANGESYMREGISTERREL& defRangeRegRel = *(DEFRANGESYMREGISTERREL*)dataStart; if (localVar != NULL) - MapRanges(localVar, &defRangeRegRel.range, defRangeRegRel.gaps); + MapRanges(localVar, &defRangeRegRel.range, defRangeRegRel.gaps); } break; case S_ENDARG: @@ -2995,8 +3000,8 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD break; case S_END: case S_PROC_ID_END: - if (deferBlockDepth > 0) - --deferBlockDepth; + if (deferBlockDepth > 0) + --deferBlockDepth; else blockStack.pop_back(); BF_ASSERT(blockStack.size() > 0); @@ -3021,18 +3026,18 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD inlineDebugDump = false; curSubprogram = NULL; - curParam = NULL; - + curParam = NULL; + } break; case S_COMPILE2: { - COMPILESYM* compileSym = (COMPILESYM*)dataStart; + COMPILESYM* compileSym = (COMPILESYM*)dataStart; } break; case S_COMPILE3: { - COMPILESYM3* compileSym = (COMPILESYM3*)dataStart; + COMPILESYM3* compileSym = (COMPILESYM3*)dataStart; } break; case S_ENVBLOCK: @@ -3049,7 +3054,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD break; case S_BUILDINFO: { - CV_ItemId buildInfoId = GET(CV_ItemId); + CV_ItemId buildInfoId = GET(CV_ItemId); } break; case S_TRAMPOLINE: @@ -3060,48 +3065,48 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD break; case S_FRAMECOOKIE: { - FRAMECOOKIE& frameCookie = *(FRAMECOOKIE*)dataStart; + FRAMECOOKIE& frameCookie = *(FRAMECOOKIE*)dataStart; } break; case S_LABEL32: { - LABELSYM32& labelSym = *(LABELSYM32*)dataStart; + LABELSYM32& labelSym = *(LABELSYM32*)dataStart; } break; case S_CALLSITEINFO: { - CALLSITEINFO& callSiteInfo = *(CALLSITEINFO*)dataStart; + CALLSITEINFO& callSiteInfo = *(CALLSITEINFO*)dataStart; } break; case S_HEAPALLOCSITE: { - HEAPALLOCSITE& heapAllocSite = *(HEAPALLOCSITE*)dataStart; + HEAPALLOCSITE& heapAllocSite = *(HEAPALLOCSITE*)dataStart; } break; case S_FILESTATIC: { - FILESTATICSYM& fileStaticSym = *(FILESTATICSYM*)dataStart; + FILESTATICSYM& fileStaticSym = *(FILESTATICSYM*)dataStart; } break; case S_CALLEES: { - FUNCTIONLIST& calleeList = *(FUNCTIONLIST*)dataStart; + FUNCTIONLIST& calleeList = *(FUNCTIONLIST*)dataStart; } break; case S_CALLERS: { - FUNCTIONLIST& calleeList = *(FUNCTIONLIST*)dataStart; + FUNCTIONLIST& calleeList = *(FUNCTIONLIST*)dataStart; } break; case S_POGODATA: { - POGOINFO& pogoInfo = *(POGOINFO*)dataStart; + POGOINFO& pogoInfo = *(POGOINFO*)dataStart; } break; - + case S_INLINESITE: case S_INLINESITE2: - { + { if (useSubprogram != NULL) { deferInlineDepth++; @@ -3110,7 +3115,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD uint32 inlinee; uint8* binaryAnnotations; - + if (symType == S_INLINESITE) { INLINESITESYM& inlineSite = *(INLINESITESYM*)dataStart; @@ -3123,13 +3128,13 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD inlinee = inlineSite.inlinee; binaryAnnotations = (uint8*)&inlineSite.binaryAnnotations; } - + DbgSubprogram* inlineParent = curSubprogram; DbgSubprogram* subprogram = NULL; if (IsObjectFile()) { subprogram = CvParseMethod(NULL, NULL, inlinee, false); - subprogram->mCompileUnit = compileUnit; + subprogram->mCompileUnit = compileUnit; curSubprogram = subprogram; } else if ((inlinee & 0x80000000) != 0) @@ -3137,7 +3142,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD BP_ALLOC_T(DbgSubprogram); subprogram = mAlloc.Alloc(); // ?? subprogram->mCompileUnit = compileUnit; - + if (!mCvIPIReader.IsSetup()) CvParseIPI(); @@ -3148,7 +3153,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD BP_ALLOC_T(DbgSubprogram); subprogram = mAlloc.Alloc(); - subprogram->mCompileUnit = compileUnit; + subprogram->mCompileUnit = compileUnit; curSubprogram = subprogram; FixupInlinee(curSubprogram, inlinee); @@ -3176,7 +3181,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD String name = StrFormat("@%@", curSubprogram); curSubprogram->mName = DbgDupString(name.c_str());*/ - + String name = StrFormat("@%@", curSubprogram); curSubprogram->mName = DbgDupString(name.c_str()); @@ -3185,12 +3190,12 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD if (inlineDebugDump) { - int depth = curSubprogram->GetInlineDepth(); - BfLogCv("S_INLINESITE Ofs:%d Depth:%d Inlinee:%X Subprogram:%@ %s\n Parent:%@ %s\n", (dataStart - symDataStart), depth, inlinee, + int depth = curSubprogram->GetInlineDepth(); + BfLogCv("S_INLINESITE Ofs:%d Depth:%d Inlinee:%X Subprogram:%@ %s\n Parent:%@ %s\n", (dataStart - symDataStart), depth, inlinee, curSubprogram, curSubprogram->mName, curSubprogram->mInlineeInfo->mInlineParent, curSubprogram->mInlineeInfo->mInlineParent->mName); } - CvInlineInfo inlineInfo; + CvInlineInfo inlineInfo; inlineInfo.mNext = NULL; inlineInfo.mTail = NULL; inlineInfo.mInlinee = inlinee; @@ -3220,17 +3225,17 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD curSubprogram->mDeferredInternalsSize = endOffset - curSubprogram->mTagIdx; } - curSubprogram = curSubprogram->mInlineeInfo->mInlineParent; + curSubprogram = curSubprogram->mInlineeInfo->mInlineParent; blockStack.pop_back(); } } break; case S_SSEARCH: { - SEARCHSYM* searchSym = (SEARCHSYM*)dataStart; + SEARCHSYM* searchSym = (SEARCHSYM*)dataStart; } break; - case S_SEPCODE: + case S_SEPCODE: { BP_ALLOC_T(DbgSubprogram); curSubprogram = mAlloc.Alloc(); @@ -3258,11 +3263,11 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD break; case S_UNAMESPACE: break; - case /*S_FASTLINK*/0x1167: + case /*S_FASTLINK*/0x1167: break; - case /*S_INLINEES*/0x1168: + case /*S_INLINEES*/0x1168: break; - case 0x1176: + case 0x1176: break; case 0x1178: break; @@ -3278,7 +3283,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD bool hasNewLocalVar = (localVar != prevLocalVar) && (localVar != NULL); if (newLocalVarHasLocData) - { + { prevLocalVar = localVar; } @@ -3297,9 +3302,9 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD { if (prevLocalVar != NULL) { - /*if (localVar->mLocationData == NULL) + /*if (localVar->mLocationData == NULL) localVar->mLocationData = dataStart; - localVar->mLocationLen++;*/ + localVar->mLocationLen++;*/ if (locationDataStart == NULL) locationDataStart = dataStart; locationDataEnd = dataEnd; @@ -3322,7 +3327,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD // to the same memory location, which can happen during mixin injection. The result is that the mixin gets // some premature instructions attributed to it from the variable declaration. This fixes that. if ((aliasPos != NULL) && (aliasPos > localVar->mName)) - { + { String findName = String(aliasPos + 7); localVar->mName = CvDupString(localVar->mName + 1, aliasPos - localVar->mName - 1); @@ -3334,7 +3339,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD /*bool found = false; auto _CheckBlock = [&](DbgBlock* block) - { + { for (auto checkVar : block->mVariables) { if (checkVar->mName == NULL) @@ -3352,15 +3357,15 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD } return false; - + }; for (int blockIdx = (int)blockStack.size() - 1; blockIdx >= 0; blockIdx--) { - DbgBlock* block = blockStack[blockIdx]; - if (_CheckBlock(block)) - break; - } + DbgBlock* block = blockStack[blockIdx]; + if (_CheckBlock(block)) + break; + } if (!found) { @@ -3379,7 +3384,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD if ((checkAddr < block->mLowPC) || (checkAddr >= block->mHighPC)) return; - if (_CheckBlock(block)) + if (_CheckBlock(block)) return; for (auto block : block->mSubBlocks) @@ -3389,7 +3394,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD _RecurseBlock(&checkSubprogram->mBlock); } }*/ - } + } } if ((compileUnit->mLanguage != DbgLanguage_Beef) && (localVar->mName != NULL)) @@ -3409,10 +3414,10 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD { BF_ASSERT(locationDataCount == prevLocalVar->mLocationLen); }*/ - + data = dataEnd; - //PTR_ALIGN(data, sectionData, 4); + //PTR_ALIGN(data, sectionData, 4); } if (localVar != NULL) @@ -3460,8 +3465,8 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c { compileUnit->mModuleIdx = NULL; compileUnit->mName = mFilePath.c_str(); - } - + } + uint8* data = sectionData; uint8* dataEnd = NULL; @@ -3472,15 +3477,15 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c uint8* debugSubSectionsStart = data; if (moduleInfo != NULL) - { - taggedSize = moduleInfo->mLinesBytes; + { + taggedSize = moduleInfo->mLinesBytes; debugSubSectionsStart = data + moduleInfo->mSymbolBytes - sizeof(uint32); } else { taggedSize = sectionSize - sizeof(uint32); - } - + } + if (mStringTable.mStrTable == NULL) { data = debugSubSectionsStart; @@ -3496,7 +3501,7 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c { if (mStringTable.mStrTable == NULL) mStringTable.mStrTable = (const char*)data; - } + } data = dataEnd; } } @@ -3527,7 +3532,7 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c crossScopeImport.mScopeName = fileName; // - /*for (int checkIdx = 0; checkIdx < (int)mCvModuleInfo.size(); checkIdx++) + /*for (int checkIdx = 0; checkIdx < (int)mCvModuleInfo.size(); checkIdx++) { auto checkModuleInfo = mCvModuleInfo[checkIdx]; if ((checkModuleInfo != NULL) && (checkModuleInfo->mModuleName != NULL) && (stricmp(checkModuleInfo->mModuleName, fileName) == 0)) @@ -3568,7 +3573,7 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c else if (lineInfoType == DEBUG_S_FRAMEDATA) { uint8* dataPtr = data; - addr_target baseAddr = 0; + addr_target baseAddr = 0; int relAddr = GET_FROM(dataPtr, int32); ParseFrameDescriptors(dataPtr, dataEnd - dataPtr, GetLinkedModule()->mImageBase + relAddr); } @@ -3584,7 +3589,7 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c ParseCompileUnit_Symbols(compileUnit, sectionData, data, dataEnd, inlineDataVec, wantsDeferInternals, NULL); //ParseCompileUnit_Symbols(compileUnit, sectionData, data, dataEnd, inlineDataVec, false, NULL); data = dataEnd; - } + } // Scan debug subsections to find file checksum table, and to load symbol data for hotloads Dictionary checksumFileRefs; @@ -3610,7 +3615,7 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c else if (lineInfoType == DEBUG_S_SYMBOLS) { ParseCompileUnit_Symbols(compileUnit, sectionData, data, dataEnd, inlineDataVec, false, NULL); - } + } else if (lineInfoType == DEBUG_S_FILECHKSMS) { BF_ASSERT(checksumFileRefs.size() == 0); @@ -3620,7 +3625,7 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c int dataOfs = (int)(data - dataStart); GET_INTO(uint, fileTableOfs); - + const char* fileName = mStringTable.mStrTable + fileTableOfs; if ((fileName[0] == '\\') && (fileName[1] == '$')) @@ -3631,9 +3636,9 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c if (fileName[0] == '$') { srcFile = AddSrcFile(compileUnit, fileName); - } + } else if ((fileName[0] == '/') || (fileName[0] == '\\') || - ((fileName[0] != 0) && (fileName[1] == ':'))) + ((fileName[0] != 0) && (fileName[1] == ':'))) { srcFile = AddSrcFile(compileUnit, fileName); } @@ -3659,12 +3664,12 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c srcFile->mHashKind = DbgHashKind_SHA256; memcpy(srcFile->mHash, data, 32); } - + data += hashLen; checksumFileRefs.TryAdd(dataOfs, (int)compileUnit->mSrcFileRefs.size() - 1); PTR_ALIGN(data, sectionData, 4); } - } + } else { BF_ASSERT((lineInfoType >= DEBUG_S_SYMBOLS) && (lineInfoType <= DEBUG_S_COFF_SYMBOL_RVA)); @@ -3693,12 +3698,12 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c } } int inlineDataIdx = 0; - + DbgLineDataBuilder lineBuilder(this); // { - BP_ZONE("ParseCompileUnit_LineInfo"); + BP_ZONE("ParseCompileUnit_LineInfo"); //int totalLineCount = 0; //int targetLineCount = 0; @@ -3710,16 +3715,16 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c // bool mWantSummaryDump; // Array mInlinees; // Array mInlineLineData; -// +// // _InlinerData() // { // mWantSummaryDump = false; // } // }; -// +// // Dictionary deferredInlinerDatas; - // Line info + // Line info data = debugSubSectionsStart; dataEnd = data + taggedSize; while (data < dataEnd) @@ -3739,13 +3744,13 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c CV_DebugSLinesHeader_t& lineSec = GET(CV_DebugSLinesHeader_t); Array lineDataVec; - + addr_target contribStartAddr = GetSectionAddr(lineSec.segCon, lineSec.offCon); while (data < dataEnd) { lineDataVec.Clear(); - + CV_DebugSLinesFileBlockHeader_t& linesFileHeader = GET(CV_DebugSLinesFileBlockHeader_t); DbgSrcFileReference* srcFileRef = &compileUnit->mSrcFileRefs[checksumFileRefs[linesFileHeader.offFile]]; bool isBeef = srcFileRef->mSrcFile->IsBeef(); @@ -3761,7 +3766,7 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c CV_Line_t& srcLineData = GET(CV_Line_t); DbgLineData& lineData = lineDataVec[lineIdx]; - lineData.mRelAddress = (uint32)((contribStartAddr + srcLineData.offset) - mImageBase); + lineData.mRelAddress = (uint32)((contribStartAddr + srcLineData.offset) - mImageBase); if (srcLineData.linenumStart == 0xf00f00) // Never step into { @@ -3777,7 +3782,7 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c } else lineData.mLine = srcLineData.linenumStart - 1; - + // In Beef we always set the column, so a section without CV_LINES_HAVE_COLUMNS indicates a block of invalid // positions that we want to skip over if (isBeef) @@ -3798,16 +3803,16 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c DbgLineData* lastLineData = NULL; for (int lineIdx = 0; lineIdx < linesFileHeader.nLines; lineIdx++) { - DbgLineData& lineData = lineDataVec[lineIdx]; + DbgLineData& lineData = lineDataVec[lineIdx]; lastLineData = lineBuilder.Add(compileUnit, lineData, srcFileRef->mSrcFile, NULL); - } + } } } else if (lineInfoType == DEBUG_S_INLINEELINES) - { + { int linesType = GET(int); while (data < dataEnd) - { + { int inlinee = 0; int srcFileIdx = -1; int startLine; @@ -3819,7 +3824,7 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c srcFileIdx = checksumFileRefs[lineInfo.fileId]; startSrcFileRef = &compileUnit->mSrcFileRefs[srcFileIdx]; startLine = lineInfo.sourceLineNum; - inlinee = lineInfo.inlinee; + inlinee = lineInfo.inlinee; } else if (linesType == 1) { @@ -3834,12 +3839,12 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c } else BF_FATAL("Invalid DEBUG_S_INLINEELINES lines type"); - + CvInlineInfo* inlineData = NULL; inlineDataDict.TryGetValue(inlinee, &inlineData); - + while (inlineData != NULL) - { + { bool inlineDebugDump = inlineData->mDebugDump; if (inlineData->mInlinee == -1) @@ -3852,30 +3857,30 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c // Mark as done inlineData->mInlinee = -1; - int chunkNum = 0; - int curLine = startLine; - int curValidLine = curLine; + int chunkNum = 0; + int curLine = startLine; + int curValidLine = curLine; bool flushOnLineOffset = false; addr_target lastLineAddr = 0; - + DbgSrcFileReference* srcFileRef = startSrcFileRef; DbgSubprogram* curSubprogram = inlineData->mSubprogram; - + DbgSubprogram* inlineParent = inlineData->mSubprogram->GetRootInlineParent(); - + addr_target curAddr = inlineParent->mBlock.mLowPC; lastLineAddr = 0; if (inlineDebugDump) { //inlinerData->mWantSummaryDump = true; - BfLogCv("------------------------------------------------\nINLINE DATA:%X Idx:%d CurAddr:%@ Line:%d\n SubProgram:%@ %s\n File:%s\n", inlinee, inlineIdx, curAddr, curLine, + BfLogCv("------------------------------------------------\nINLINE DATA:%X Idx:%d CurAddr:%@ Line:%d\n SubProgram:%@ %s\n File:%s\n", inlinee, inlineIdx, curAddr, curLine, curSubprogram, curSubprogram->mName, srcFileRef->mSrcFile->mFilePath.c_str()); } uint8* annData = inlineData->mData; - uint8* annDataEnd = inlineData->mData + inlineData->mDataLen; + uint8* annDataEnd = inlineData->mData + inlineData->mDataLen; DbgLineData* curLineData = NULL; @@ -3887,16 +3892,16 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c return; } - DbgLineData lineData; - lineData.mLine = curValidLine - 1; + DbgLineData lineData; + lineData.mLine = curValidLine - 1; lineData.mRelAddress = (uint32)(curAddr - mImageBase); lineData.mColumn = 0; if (curLine <= 0) // Negative lines mean "invalid position" for inlining - lineData.mColumn = -1; + lineData.mColumn = -1; lineData.mContribSize = 0; - + if ((curSubprogram->mBlock.mLowPC == 0) && (curLineData != NULL)) - curSubprogram->mBlock.mLowPC = mImageBase + curLineData->mRelAddress; + curSubprogram->mBlock.mLowPC = mImageBase + curLineData->mRelAddress; if (inlineDebugDump) BfLogCv(" Adding Line:%d Addr:%@\n", lineData.mLine + 1, lineData.mRelAddress + mImageBase); @@ -3907,14 +3912,14 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c int codeIdx = 0; while (annData < annDataEnd) - { + { auto annVal = CodeViewInfo::CVUncompressData(annData); - + switch (annVal) { case CodeViewInfo::BA_OP_Invalid: // link time pdb contains PADDINGs break; - case CodeViewInfo::BA_OP_CodeOffset: // param : start offset + case CodeViewInfo::BA_OP_CodeOffset: // param : start offset { int32 offset = (int32)CodeViewInfo::CVUncompressData(annData); curAddr = inlineParent->mBlock.mLowPC + offset; @@ -3924,17 +3929,17 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c break; case CodeViewInfo::BA_OP_ChangeCodeOffsetBase: // param : nth separated code chunk (main code chunk == 0) { - chunkNum = (int32)CodeViewInfo::CVUncompressData(annData); + chunkNum = (int32)CodeViewInfo::CVUncompressData(annData); if (inlineDebugDump) - BfLogCv("xxxxxxxxx BA_OP_ChangeCodeOffsetBase(%d) CurAddr:%@ Line:%d\n", chunkNum, curAddr, curLine); + BfLogCv("xxxxxxxxx BA_OP_ChangeCodeOffsetBase(%d) CurAddr:%@ Line:%d\n", chunkNum, curAddr, curLine); } break; case CodeViewInfo::BA_OP_ChangeCodeOffset: // param : delta of offset { int32 offset = (int32)CodeViewInfo::CVUncompressData(annData); - - curAddr += offset; + + curAddr += offset; if (inlineDebugDump) BfLogCv(" BA_OP_ChangeCodeOffset(%d) CurAddr:%@ Line:%d\n", offset, curAddr, curLine); @@ -3946,7 +3951,7 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c } else _AddLine(); - + flushOnLineOffset = true; } break; @@ -3959,10 +3964,10 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c curLineData->mContribSize = newCodeLen; if (inlineDebugDump) - BfLogCv(" BA_OP_ChangeCodeLength(%d) Addr:%@ EndAddr:%@\n", newCodeLen, curLineData->mRelAddress + mImageBase, curLineData->mRelAddress + mImageBase + curLineData->mContribSize); + BfLogCv(" BA_OP_ChangeCodeLength(%d) Addr:%@ EndAddr:%@\n", newCodeLen, curLineData->mRelAddress + mImageBase, curLineData->mRelAddress + mImageBase + curLineData->mContribSize); } break; - case CodeViewInfo::BA_OP_ChangeFile: // param : fileId + case CodeViewInfo::BA_OP_ChangeFile: // param : fileId { uint32 newFileId = CodeViewInfo::CVUncompressData(annData); srcFileRef = &compileUnit->mSrcFileRefs[checksumFileRefs[newFileId]]; @@ -3976,7 +3981,7 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c int32 lineOfs = (int32)CodeViewInfo::DecodeSignedInt32(CodeViewInfo::CVUncompressData(annData)); curLine += lineOfs; if (curLine > 0) - curValidLine = curLine; + curValidLine = curLine; if (inlineDebugDump) BfLogCv(" BA_OP_ChangeLineOffset(%d) CurAddr:%@ Line:%d\n", lineOfs, curAddr, curLine); @@ -3992,7 +3997,7 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c BfLogCv(" BA_OP_ChangeLineEndDelta(%d) CurAddr:%@ Line:%d\n", numLines, curAddr, curLine); } break; - case CodeViewInfo::BA_OP_ChangeRangeKind: // param : either 1 (default, for statement) or 0 (for expression) + case CodeViewInfo::BA_OP_ChangeRangeKind: // param : either 1 (default, for statement) or 0 (for expression) { int32 readKind = (int32)CodeViewInfo::CVUncompressData(annData); if (inlineDebugDump) @@ -4021,11 +4026,11 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c int offsetData = (int32)CodeViewInfo::CVUncompressData(annData); int codeDelta = offsetData & 0xF; int sourceDelta = CodeViewInfo::DecodeSignedInt32(offsetData >> 4); - + curAddr += codeDelta; curLine += sourceDelta; if (curLine > 0) - curValidLine = curLine; + curValidLine = curLine; if (inlineDebugDump) BfLogCv(" BA_OP_ChangeCodeOffsetAndLineOffset(%d, %d) CurAddr:%@ Line:%d\n", codeDelta, sourceDelta, curAddr, curLine); @@ -4040,7 +4045,7 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c int codeOffset = (int32)CodeViewInfo::CVUncompressData(annData); curAddr += codeOffset; - + if (inlineDebugDump) BfLogCv(" BA_OP_ChangeCodeLengthAndCodeOffset(%d, %d) CurAddr:%@ Line:%d\n", codeLen, codeOffset, curAddr, curLine); @@ -4085,19 +4090,19 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c // { // auto inlinerParent = deferredInlinerDataKV.mKey; // auto deferredInlinerData = &deferredInlinerDataKV.mValue; -// +// // inlinerParent->mInlinerData = mAlloc.Alloc(); // inlinerParent->mInlinerData->mInlinees.CopyFrom(deferredInlinerData->mInlinees.mVals, deferredInlinerData->mInlinees.mSize, mAlloc); // inlinerParent->mInlinerData->mInlineLineData.CopyFrom(deferredInlinerData->mInlineLineData.mVals, deferredInlinerData->mInlineLineData.mSize, mAlloc); // //deferredInlinerData-> -// +// // if (deferredInlinerData->mWantSummaryDump) // { // BfLogCv("------------------------------\nSUMMARY FOR: %s\n", inlinerParent->mName); -// +// // for (auto& inlineLine : inlinerParent->mInlinerData->mInlineLineData) -// { -// BfLogCv("Addr:%@ EndAddr:%@ Line:%d Column:%d Inlinee:%d\n", inlineLine.mAddress, inlineLine.mAddress + inlineLine.mContribSize, +// { +// BfLogCv("Addr:%@ EndAddr:%@ Line:%d Column:%d Inlinee:%d\n", inlineLine.mAddress, inlineLine.mAddress + inlineLine.mContribSize, // inlineLine.mLine + 1, inlineLine.mColumn + 1, inlineLine.mInlineIdx); // } // } @@ -4107,7 +4112,7 @@ CvCompileUnit* COFF::ParseCompileUnit(CvModuleInfo* moduleInfo, CvCompileUnit* c lineBuilder.Commit(); - //OutputDebugStrF("Module loaded, AllocSize added: %d\n", (mAlloc.GetAllocSize() - allocSizeStart) / 1024); + //OutputDebugStrF("Module loaded, AllocSize added: %d\n", (mAlloc.GetAllocSize() - allocSizeStart) / 1024); return compileUnit; } @@ -4118,7 +4123,7 @@ CvCompileUnit* COFF::ParseCompileUnit(int compileUnitId) return moduleInfo->mCompileUnit; BP_ZONE("ParseCompileUnit"); - + ParseTypeData(); if (moduleInfo->mStream == -1) @@ -4151,7 +4156,7 @@ DbgType* COFF::CvGetTypeOrNamespace(char* name, DbgLanguage language) language = DbgLanguage_Beef; } else - { + { language = DbgLanguage_C; // Check for a primitive array type like 'double[]' @@ -4176,7 +4181,7 @@ DbgType* COFF::CvGetTypeOrNamespace(char* name, DbgLanguage language) return dbgType->mHotNewType; return dbgType; } - + // It's possible that we get a reference to a template name that isn't actually in our type database // These may indicate VS compiler bugs or anonymous namespaces bool isValidName = true; @@ -4189,12 +4194,12 @@ DbgType* COFF::CvGetTypeOrNamespace(char* name, DbgLanguage language) //OutputDebugStrF("CvGetTypeOrNamespace Creating: %s\n", name); char* lastDblColon = (char*)GetLastDoubleColon(name); - + DbgType* dbgType = CvCreateType(); DbgType* parentType = mMasterCompileUnit->mGlobalType; if (lastDblColon != NULL) - { + { *lastDblColon = 0; parentType = CvGetTypeOrNamespace(name, language); dbgType->mTypeName = DbgDupString(lastDblColon + 2, "DbgDupString.TypeOrNamespace0"); @@ -4204,9 +4209,9 @@ DbgType* COFF::CvGetTypeOrNamespace(char* name, DbgLanguage language) else { dbgType->mTypeName = DbgDupString(name, "DbgDupString.TypeOrNamespace2"); - dbgType->mName = dbgType->mTypeName; - } - + dbgType->mName = dbgType->mTypeName; + } + parentType->mSubTypeList.PushBack(dbgType); dbgType->mTypeCode = DbgType_Namespace; dbgType->mLanguage = language; @@ -4222,14 +4227,14 @@ void COFF::MapCompileUnitMethods(DbgCompileUnit* compileUnit) DbgSubprogram* prevDbgMethod = NULL; DbgSubprogram* dbgMethod = compileUnit->mOrphanMethods.mHead; while (dbgMethod != NULL) - { - auto nextDbgMethod = dbgMethod->mNext; + { + auto nextDbgMethod = dbgMethod->mNext; bool movedMethod = false; if (dbgMethod->mHasQualifiedName) { char* name = (char*)dbgMethod->mName; char* lastDblColon = (char*)GetLastDoubleColon(name); - + if (lastDblColon != NULL) { dbgMethod->mName = lastDblColon + 2; @@ -4244,7 +4249,7 @@ void COFF::MapCompileUnitMethods(DbgCompileUnit* compileUnit) { mHotPrimaryTypes.Add(parentType); } - + compileUnit->mOrphanMethods.Remove(dbgMethod, prevDbgMethod); parentType->mMethodList.PushBack(dbgMethod); dbgMethod->mParentType = parentType; @@ -4280,7 +4285,7 @@ void COFF::PopulateType(DbgType* dbgType) CvAutoReleaseTempData releaseTempData(this, data); uint8* dataStart = data; - uint16 trLeafType = GET(uint16); + uint16 trLeafType = GET(uint16); switch (trLeafType) { @@ -4291,7 +4296,7 @@ void COFF::PopulateType(DbgType* dbgType) } break; case LF_CLASS: - case LF_STRUCTURE: + case LF_STRUCTURE: { lfClass& classInfo = *(lfClass*)dataStart; CvParseMembers(dbgType, classInfo.field, false); @@ -4307,10 +4312,10 @@ void COFF::PopulateType(DbgType* dbgType) CvParseMembers(dbgType, field, false); } break; - + case LF_UNION: { - lfUnion& classInfo = *(lfUnion*)dataStart; + lfUnion& classInfo = *(lfUnion*)dataStart; CvParseMembers(dbgType, classInfo.field, false); } break; @@ -4320,7 +4325,7 @@ void COFF::PopulateType(DbgType* dbgType) } void COFF::PopulateTypeGlobals(DbgType* dbgType) -{ +{ //gDbgPerfManager->StartRecording(); { @@ -4345,13 +4350,13 @@ void COFF::PopulateSubprogram(DbgSubprogram* dbgSubprogram) BP_ZONE("COFF::PopulateSubprogram"); auto compileUnit = (CvCompileUnit*)dbgSubprogram->mCompileUnit; - CvModuleInfo* moduleInfo = mCvModuleInfo[compileUnit->mModuleIdx]; - + CvModuleInfo* moduleInfo = mCvModuleInfo[compileUnit->mModuleIdx]; + int sectionSize = 0; uint8* sectionData = CvReadStreamSegment(moduleInfo->mStream, dbgSubprogram->mTagIdx, dbgSubprogram->mDeferredInternalsSize); CvInlineInfoVec inlineDataVec; ParseCompileUnit_Symbols(compileUnit, NULL, sectionData, sectionData + dbgSubprogram->mDeferredInternalsSize, inlineDataVec, false, dbgSubprogram); - delete sectionData; + delete sectionData; dbgSubprogram->mDeferredInternalsSize = 0; } @@ -4362,7 +4367,7 @@ void COFF::FixSubprogramName(DbgSubprogram* dbgSubprogram) for (const char* cPtr = name; *cPtr != 0; cPtr++) { - char c = *cPtr; + char c = *cPtr; if (c == '$') { bool isChecked = strcmp(cPtr, "$CHK") == 0; @@ -4372,7 +4377,7 @@ void COFF::FixSubprogramName(DbgSubprogram* dbgSubprogram) dbgSubprogram->mCheckedKind = isChecked ? BfCheckedKind_Checked : BfCheckedKind_Unchecked; dbgSubprogram->mName = CvDupString(name, cPtr - name); return; - } + } } } } @@ -4436,7 +4441,7 @@ void COFF::FixupInlinee(DbgSubprogram* dbgSubprogram, uint32 ipiTag) case LF_MFUNC_ID: { lfMFuncId* funcData = (lfMFuncId*)dataStart; - CvParseMethod(NULL, NULL, funcData->type, false, dbgSubprogram); + CvParseMethod(NULL, NULL, funcData->type, false, dbgSubprogram); dbgSubprogram->mName = (const char*)funcData->name; if (dbgSubprogram->mName != NULL) @@ -4480,7 +4485,7 @@ int COFF::MapImport(CvCompileUnit* compileUnit, int id) { String name = moduleInfo->mModuleName; name = ToUpper(name); - + CvModuleInfoNameEntry entry; entry.mModuleInfo = moduleInfo; mModuleNameSet.Add(entry); @@ -4549,7 +4554,7 @@ int COFF::MapImport(CvCompileUnit* compileUnit, int id) { return exportId; } - } + } } } } @@ -4561,7 +4566,7 @@ void COFF::FixupInlinee(DbgSubprogram* dbgSubprogram) { BF_ASSERT(dbgSubprogram->mInlineeInfo != NULL); BF_ASSERT((dbgSubprogram->mInlineeInfo->mInlineeId & 0x80000000) != 0); - + int scopeIdx = (dbgSubprogram->mInlineeInfo->mInlineeId & 0x7FFF0000) >> 20; int itemId = (dbgSubprogram->mInlineeInfo->mInlineeId & 0x0000FFFF); @@ -4613,7 +4618,7 @@ void COFF::FixupInlinee(DbgSubprogram* dbgSubprogram) } void COFF::PopulateStaticVariableMap() -{ +{ if (mPopulatedStaticVariables) return; @@ -4623,7 +4628,7 @@ void COFF::PopulateStaticVariableMap() { PopulateTypeGlobals(mMasterCompileUnit->mGlobalType); for (auto variable : mMasterCompileUnit->mGlobalType->mMemberList) - { + { if ((variable->mIsExtern) && (variable->mLinkName != NULL)) mStaticVariables.push_back(variable); } @@ -4637,25 +4642,25 @@ void COFF::ScanCompileUnit(int compileUnitId) BP_ZONE("COFF::ScanCompileUnit"); CvModuleInfo* moduleInfo = mCvModuleInfo[compileUnitId]; - + if (moduleInfo->mStream < 0) return; BF_ASSERT(moduleInfo->mSymbolBytes % 4 == 0); - uint8* sectionData = CvReadStreamSegment(moduleInfo->mStream, moduleInfo->mSymbolBytes, moduleInfo->mLinesBytes); + uint8* sectionData = CvReadStreamSegment(moduleInfo->mStream, moduleInfo->mSymbolBytes, moduleInfo->mLinesBytes); uint8* data = sectionData; - uint8* dataEnd = sectionData + moduleInfo->mLinesBytes; + uint8* dataEnd = sectionData + moduleInfo->mLinesBytes; while (data < dataEnd) - { + { GET_INTO(int32, lineInfoType); - GET_INTO(int32, lineInfoLength); + GET_INTO(int32, lineInfoLength); uint8* dataEnd = data + lineInfoLength; if (lineInfoType == DEBUG_S_FILECHKSMS) - { + { while (data < dataEnd) - { + { GET_INTO(uint, fileTableOfs); DbgSrcFile* srcFile; @@ -4689,10 +4694,10 @@ void COFF::ScanCompileUnit(int compileUnitId) PTR_ALIGN(data, sectionData, 4); } - + break; // Stop once we handle the file checksums } - + data = dataEnd; } @@ -4711,7 +4716,7 @@ void COFF::FixTypes(int startingIdx) for (int typeIdx = startingIdx; typeIdx < (int)linkedModule->mTypes.size(); typeIdx++) { DbgType* dbgType = linkedModule->mTypes[typeIdx]; - + DbgType* prevNamespaceType = NULL; if (dbgType->mName == NULL) { @@ -4761,17 +4766,17 @@ void COFF::FixTypes(int startingIdx) } // This never happens anymore - nested types are always handled as "internal typedefs" - //TODO: Check the 'isnested' flag on the leaf instead of counting on parent to be specified? + //TODO: Check the 'isnested' flag on the leaf instead of counting on parent to be specified? bool hadParent = dbgType->mParent != NULL; int chevronDepth = 0; - if ((dbgType->mTypeCode == DbgType_Class) || (dbgType->mTypeCode == DbgType_Struct) || (dbgType->mTypeCode == DbgType_Union) || + if ((dbgType->mTypeCode == DbgType_Class) || (dbgType->mTypeCode == DbgType_Struct) || (dbgType->mTypeCode == DbgType_Union) || (dbgType->mTypeCode == DbgType_Enum) || (dbgType->mTypeCode == DbgType_TypeDef)) - { + { int startIdx = -1; const char* name = dbgType->mTypeName; - + for (int i = 0; true; i++) { char c = name[i]; @@ -4779,15 +4784,15 @@ void COFF::FixTypes(int startingIdx) chevronDepth++; else if (c == '>') chevronDepth--; - + if ((chevronDepth == 0) && ((c == ':') || (c == '.'))) { if ((!hadParent) && (i - startIdx > 1)) - { + { //String wholeNamespace = String(name, name + i); wholeNamespace.clear(); wholeNamespace.Insert(0, name, i); - + auto entry = linkedModule->mTypeMap.Find(wholeNamespace.c_str(), dbgType->mLanguage); if (entry == NULL) { @@ -4817,7 +4822,7 @@ void COFF::FixTypes(int startingIdx) } else if ((c == 0) /*|| (c == '<')*/ || (c == '(')) break; - } + } if (prevNamespaceType != NULL) { @@ -4878,7 +4883,7 @@ uint8* COFF::CvReadStream(int streamIdx, int* outSize) *outSize = streamSize; if (streamSize <= 0) return NULL; - int streamPageCount = (streamSize + mCvPageSize - 1) / mCvPageSize; + int streamPageCount = (streamSize + mCvPageSize - 1) / mCvPageSize; uint8* sectionData = new uint8[streamSize]; bool deferDeleteSectionData = false; @@ -4900,7 +4905,7 @@ uint8* COFF::CvReadStreamSegment(int streamIdx, int offset, int size) //int streamSize = mCvStreamSizes[streamIdx]; //int streamPageCount = (streamSize + mCvPageSize - 1) / mCvPageSize; - + uint8* sectionData = new uint8[size]; //delete [] sectionData; @@ -4911,7 +4916,7 @@ uint8* COFF::CvReadStreamSegment(int streamIdx, int offset, int size) int curOffset = offset; int sizeLeft = size; - int streamPtrIdx = mCvStreamPtrStartIdxs[streamIdx]; + int streamPtrIdx = mCvStreamPtrStartIdxs[streamIdx]; streamPtrIdx += offset / mCvPageSize; curOffset = offset - (offset / mCvPageSize) * mCvPageSize; @@ -4931,9 +4936,9 @@ uint8* COFF::CvReadStreamSegment(int streamIdx, int offset, int size) } void COFF::ReleaseTempBuf(uint8* buf) -{ +{ if ((mTempBufIdx > 0) && (mTempBufs.mVals[mTempBufIdx - 1].mVals == buf)) - mTempBufIdx--; + mTempBufIdx--; } bool COFF::CvParseHeader(uint8 wantGuid[16], int32 wantAge) @@ -4941,13 +4946,13 @@ bool COFF::CvParseHeader(uint8 wantGuid[16], int32 wantAge) int streamSize = 0; uint8* data = CvReadStream(1, &streamSize); mCvHeaderData = data; - + int32 pdbVersion = GET(int32); int32 timestamp = GET(int32); - int32 pdbAge = GET(int32); + int32 pdbAge = GET(int32); for (int i = 0; i < 16; i++) mPDBGuid[i] = GET(int8); - + if ((wantAge != -1) && (/*(pdbAge != wantAge) ||*/ (memcmp(mPDBGuid, wantGuid, 16) != 0))) { @@ -4962,11 +4967,11 @@ bool COFF::CvParseHeader(uint8 wantGuid[16], int32 wantAge) msg += StrFormat(" PDB GUID : "); for (int i = 0; i < 16; i++) - msg += StrFormat("%02X", (uint8)mPDBGuid[i]); + msg += StrFormat("%02X", (uint8)mPDBGuid[i]); Fail(msg); } return false; - } + } if (mParseKind == ParseKind_Header) return true; @@ -5011,8 +5016,8 @@ bool COFF::CvParseHeader(uint8 wantGuid[16], int32 wantAge) bool COFF::CvParseDBI(int wantAge) { BP_ZONE("CvParseDBI"); - - uint8* data = CvReadStream(3); + + uint8* data = CvReadStream(3); if (data == NULL) return false; @@ -5065,7 +5070,7 @@ bool COFF::CvParseDBI(int wantAge) else if (machine == 0x014C) mIs64Bit = false; else // Unknown machine - return false; + return false; uint8* headerEnd = data; @@ -5163,7 +5168,7 @@ bool COFF::CvParseDBI(int wantAge) contribEntry->mDbgModule = this; contribEntry->mCompileUnitId = contrib.mModule; mDebugTarget->mContribMap.Insert(contribEntry); - } + } } } @@ -5183,7 +5188,7 @@ bool COFF::CvParseDBI(int wantAge) GET_INTO(int32, unknownData2); // Value added to the address offset when calculating the RVA. GET_INTO(uint32, rva_offset); - GET_INTO(uint32, section_length); + GET_INTO(uint32, section_length); } // Dbi File info @@ -5193,12 +5198,12 @@ bool COFF::CvParseDBI(int wantAge) int fileInfoNumSourceFiles = 0; - uint16* modIndices = (uint16*)data; + uint16* modIndices = (uint16*)data; data += fileInfoNumModules * sizeof(uint16); uint16* modFileCounts = (uint16*)data; data += fileInfoNumModules * sizeof(uint16); - for (int moduleIdx = 0; moduleIdx < fileInfoNumModules; moduleIdx++) + for (int moduleIdx = 0; moduleIdx < fileInfoNumModules; moduleIdx++) fileInfoNumSourceFiles += modFileCounts[moduleIdx]; int32* fileNameOffsets = (int32*)data; @@ -5215,14 +5220,14 @@ bool COFF::CvParseDBI(int wantAge) for (int fileIdx = 0; fileIdx < modFileCounts[moduleIdx]; fileIdx++) { - char* fileName = namePtr + *fileNameOffsets; + char* fileName = namePtr + *fileNameOffsets; curFileOfs++; fileNameOffsets++; - } + } //int blockStart = fileBlockTable[i]; //int blockLength = fileBlockTable[fileInfoNumModules + i]; - //int offset = offsetTable[blockStart]; through blockLength... + //int offset = offsetTable[blockStart]; through blockLength... } // File name table @@ -5230,7 +5235,7 @@ bool COFF::CvParseDBI(int wantAge) while (data < dataEnd) { int offset = (int)(data - dataStart); - const char* fileName = DataGetString(data); + const char* fileName = DataGetString(data); //DbgSrcFile* srcFile = AddSrcFile(mMasterCompileUnit, fileName); //fileTable.insert(std::make_pair(offset, srcFile)); }*/ @@ -5253,8 +5258,8 @@ bool COFF::CvParseDBI(int wantAge) for (int entryIdx = 0; entryIdx < strTabEntryCount; entryIdx++) { GET_INTO(int32, strOffset); - const char* str = (const char*)strTabData + strOffset; - } + const char* str = (const char*)strTabData + strOffset; + } return true; } @@ -5266,7 +5271,7 @@ void COFF::ParseSectionHeader(int sectionIdx) int sectionSize = 0; uint8* sectionData = CvReadStream(sectionIdx, §ionSize); uint8* data = sectionData; - + uint8* dataEnd = data + sectionSize; while (data < dataEnd) { @@ -5292,24 +5297,24 @@ void COFF::CvParseIPI() int hashAdjOffset = 0; int32 hashStream = -1; int32 hashAdjSize = 0; - int32 dataOffset = 0; + int32 dataOffset = 0; ParseTypeData(4, mCvIPIReader, sectionSize, dataOffset, hashStream, hashAdjOffset, hashAdjSize, mCvIPIMinTag, mCvIPIMaxTag); //mCvIPIData = sectionData; - + int recordCount = mCvIPIMaxTag - mCvIPIMinTag; mCvIPITagStartMap.Resize(recordCount + 1); //uint8* data = sectionData + dataOffset; int offset = dataOffset; for (int idx = 0; idx < recordCount; idx++) - { + { //BF_ASSERT(((offset) & 3) == 0); - uint8* data = mCvIPIReader.GetTempPtr(offset, 4); + uint8* data = mCvIPIReader.GetTempPtr(offset, 4); uint16 trLength = GET(uint16); int offsetStart = offset; offset += 2; data = mCvIPIReader.GetTempPtr(offset, trLength); - uint8* dataStart = data; + uint8* dataStart = data; uint16 trLeafType = GET(uint16); //uint8* dataEnd = dataStart + trLength; offset += trLength; @@ -5322,18 +5327,18 @@ void COFF::CvParseIPI() { case LF_FUNC_ID: { - lfFuncId* funcData = (lfFuncId*)dataStart; + lfFuncId* funcData = (lfFuncId*)dataStart; //subprogram->mName = (const char*)funcData->name; bool doScope = true; /*if (strcmp(curSubprogram->mName, "DispatchToMethod") == 0) { - doScope = true; + doScope = true; }*/ if ((funcData->scopeId != 0) && (doScope)) - { + { uint8* data = CvGetTagData(funcData->scopeId, true); CvAutoReleaseTempData releaseTempData(this, data); @@ -5365,24 +5370,24 @@ void COFF::CvParseIPI() } break; - } + } mCvIPITagStartMap[idx] = offsetStart; } - + mCvIPITagStartMap[recordCount] = offset; } const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_target& outAddr) { const char* retName = NULL; - + int offsetStart = offset; - uint8* data = mCvSymbolRecordReader.GetTempPtr(offset, 4); + uint8* data = mCvSymbolRecordReader.GetTempPtr(offset, 4); uint16 symLen = *(uint16*)data; bool madeCopy = false; data = mCvSymbolRecordReader.GetTempPtr(offset, symLen + 2, false, &madeCopy); - uint8* dataStart = data; + uint8* dataStart = data; uint16 symType = *(uint16*)(data + 2); BF_ASSERT(symLen % 4 == 2); @@ -5399,23 +5404,23 @@ const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_ #ifdef _DEBUG ParseTypeData(); - auto type = CvGetType(udt.typind); -#endif + auto type = CvGetType(udt.typind); +#endif retName = name; } break; case S_PUB32: { PUBSYM32& pubSym = *(PUBSYM32*)dataStart; - + if (symStreamType != CvSymStreamType_Symbols) - break; + break; BP_ALLOC_T(DbgSymbol); DbgSymbol* dbgSymbol = mAlloc.Alloc(); const char* name = (const char*)mCvSymbolRecordReader.GetPermanentPtr(offsetStart + offsetof(PUBSYM32, name), symLen - offsetof(PUBSYM32, name) + 2); // pubSym.name; - //OutputDebugStrF("Sym: %s\n", name); + //OutputDebugStrF("Sym: %s\n", name); #ifdef BF_DBG_32 if ((name != NULL) && (name[0] == '_')) name++; @@ -5424,7 +5429,7 @@ const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_ dbgSymbol->mName = name; dbgSymbol->mAddress = GetSectionAddr(pubSym.seg, pubSym.off); dbgSymbol->mDbgModule = this; - + if ((dbgSymbol->mAddress >= mImageBase) && (dbgSymbol->mAddress < mImageBase + mImageSize)) { if ((dbgSymbol->mAddress & 0xFFFF'0000'0000'0000) == 0) @@ -5442,7 +5447,7 @@ const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_ break; case S_CONSTANT: { - CONSTSYM& constSym = *(CONSTSYM*)dataStart; + CONSTSYM& constSym = *(CONSTSYM*)dataStart; } break; case S_GDATA32: @@ -5455,41 +5460,41 @@ const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_ { mTLSIndexAddr = GetSectionAddr(dataSym.seg, dataSym.off); } - + char* name = (char*)dataSym.name; retName = name; - + if (symStreamType == CvSymStreamType_Globals_Scan) { scanName = (char*)dataSym.name; - break; + break; } - + bool wasBeef = false; const char* memberName = CvCheckTargetMatch(name, wasBeef); if (memberName == NULL) break; - + DbgType* dbgType = CvGetType(dataSym.typind); BP_ALLOC_T(DbgVariable); DbgVariable* variable = mAlloc.Alloc(); - variable->mType = dbgType; + variable->mType = dbgType; variable->mLocationData = permDataPtr; variable->mLocationLen = 1; variable->mIsStatic = true; variable->mCompileUnit = mMasterCompileUnit; - variable->mName = memberName; + variable->mName = memberName; variable->mLinkName = name; if (strcmp((const char*)dataSym.name, "__ImageBase") == 0) variable->mLinkName = NULL; // Avoid adding to map variable->mIsExtern = symType == S_GDATA32; - variable->mCompileUnit = mGlobalsTargetType->mCompileUnit; + variable->mCompileUnit = mGlobalsTargetType->mCompileUnit; // Push front so we will find before the original static declaration (that has no memory associated with it) - mGlobalsTargetType->mMemberList.PushFront(variable); + mGlobalsTargetType->mMemberList.PushFront(variable); if (IsObjectFile()) { @@ -5503,7 +5508,7 @@ const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_ { uint8* permDataPtr = madeCopy ? mCvSymbolRecordReader.GetPermanentPtr(offsetStart, symLen + 2) : dataStart; THREADSYM32& threadSym = *(THREADSYM32*)permDataPtr; - + if (symStreamType == CvSymStreamType_Globals_Scan) { scanName = (char*)threadSym.name; @@ -5522,7 +5527,7 @@ const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_ BP_ALLOC_T(DbgVariable); DbgVariable* variable = mAlloc.Alloc(); - variable->mType = dbgType; + variable->mType = dbgType; variable->mLocationData = permDataPtr; variable->mLocationLen = 1; variable->mIsStatic = true; @@ -5543,20 +5548,20 @@ const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_ char* name = (char*)refSym.name; retName = name; - + if (symStreamType == CvSymStreamType_Globals_Scan) { scanName = (char*)refSym.name; break; - } + } + + int moduleId = refSym.imod - 1; - int moduleId = refSym.imod - 1; - bool wasBeef = false; char* memberName = (char*)CvCheckTargetMatch(name, wasBeef); - if (memberName == NULL) + if (memberName == NULL) break; - + bool wantsCopy = madeCopy; bool isIllegal = false; @@ -5572,23 +5577,23 @@ const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_ memberName[cPtr - prevName] = 0; wantsCopy = false; break; - } + } else isIllegal = true; } if ((c == '<') || (c == '`')) isIllegal = true; - } + } if (!isIllegal) - { + { BP_ALLOC_T(DbgMethodNameEntry); auto methodNameEntry = mAlloc.Alloc(); methodNameEntry->mCompileUnitId = moduleId; methodNameEntry->mName = wantsCopy ? DbgDupString(memberName) : memberName; mGlobalsTargetType->mMethodNameList.PushBack(methodNameEntry); - } + } } break; default: @@ -5597,30 +5602,30 @@ const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_ } if (scanName != NULL) - { + { //TODO: Remove //String origName = name; //CvFixupName(name); char* lastDblColon = (char*)GetNamespaceEnd(scanName); if (lastDblColon != NULL) - { + { if (mPrevScanName != NULL) { int namespaceLen = lastDblColon - scanName; if (strncmp(scanName, mPrevScanName, namespaceLen + 2) == 0) // +2 includes the ending '::' { // We've already inserted this namespace - return retName; + return retName; } } StringT<256> tempName; - tempName = String(scanName, lastDblColon - scanName); + tempName = String(scanName, lastDblColon - scanName); DbgType* dbgType = CvGetTypeOrNamespace((char*)tempName.c_str()); -// *lastDblColon = '\0'; +// *lastDblColon = '\0'; // DbgType* dbgType = CvGetTypeOrNamespace(scanName); // *lastDblColon = ':'; @@ -5656,13 +5661,13 @@ const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_ methodNameEntry->mCompileUnitId = moduleId; methodNameEntry->mName = methodName; dbgParent->mMethodNameList.PushBack(methodNameEntry); - }*/ + }*/ } else { mMasterCompileUnit->mGlobalType->mNeedsGlobalsPopulated = true; } - } + } return retName; } @@ -5682,7 +5687,7 @@ uint8* COFF::HandleSymStreamEntries(CvSymStreamType symStreamType, uint8* data, uint8* dataEnd = data + sizeHr; uint8* refDataHead = data; int entryIdxMax = sizeHr / 8; - + data = dataEnd; dataEnd = data + sizeBuckets ; @@ -5703,7 +5708,7 @@ uint8* COFF::HandleSymStreamEntries(CvSymStreamType symStreamType, uint8* data, return dataEnd; // No hash std::multimap checkAddrMap; - + int bitCount = 0; for (int blockIdx = 0; blockIdx < 0x81; blockIdx++) { @@ -5729,7 +5734,7 @@ uint8* COFF::HandleSymStreamEntries(CvSymStreamType symStreamType, uint8* data, continue; addr_target addr = 0; - const char* symName = CvParseSymbol(symDataPtr - 1, symStreamType, addr); + const char* symName = CvParseSymbol(symDataPtr - 1, symStreamType, addr); #ifdef _DEBUG if ((verify) && (addrMap != NULL)) { @@ -5757,15 +5762,15 @@ uint8* COFF::HandleSymStreamEntries(CvSymStreamType symStreamType, uint8* data, data = addrMap; for (int entryIdx = 0; entryIdx < numRecordsRead; entryIdx++) { - int verifyIdx = GET(int32); + int verifyIdx = GET(int32); int actualIdx = itr->second; if (actualIdx != verifyIdx) { OutputDebugStrF("Mismatch #%X %X %X %08X\n", entryIdx, verifyIdx, actualIdx, itr->first); } ++itr; - } - } + } + } #endif BF_ASSERT(numRecordsRead == entryIdxMax); @@ -5777,8 +5782,8 @@ uint8* COFF::HandleSymStreamEntries(CvSymStreamType symStreamType, uint8* data, void COFF::ParseSymbolStream(CvSymStreamType symStreamType) { - if (mCvSymbolRecordStream == 0) - return; + if (mCvSymbolRecordStream == 0) + return; BP_ZONE("COFF::ParseSymbolStream"); @@ -5801,14 +5806,14 @@ void COFF::ParseSymbolStream(CvSymStreamType symStreamType) uint8* data; if (mCvPublicSymbolData == NULL) mCvPublicSymbolData = CvReadStream(mCvPublicSymbolInfoStream, &streamSize); // psgsi - data = mCvPublicSymbolData; - uint8* sectionData = data; + data = mCvPublicSymbolData; + uint8* sectionData = data; GET_INTO(int32, symHashSize); - GET_INTO(int32, addrMapSize); + GET_INTO(int32, addrMapSize); GET_INTO(int32, thunkCount); GET_INTO(int32, thunkSize); - GET_INTO(int32, thunkTableStream); + GET_INTO(int32, thunkTableStream); GET_INTO(int32, thunkTableOfs); GET_INTO(int32, thunkSectCount); @@ -5818,24 +5823,24 @@ void COFF::ParseSymbolStream(CvSymStreamType symStreamType) /*int addrMapEntryCount = addrMapSize / 4; for (int addrIdx = 0; addrIdx < addrMapEntryCount; addrIdx++) { - GET_INTO(int32, addrVal); + GET_INTO(int32, addrVal); } for (int thunkIdx = 0; thunkIdx < thunkCount; thunkIdx++) { - GET_INTO(int32, thunkVal); + GET_INTO(int32, thunkVal); } for (int sectionIdx = 0; sectionIdx < thunkSectCount; sectionIdx++) { GET_INTO(int32, ofs); - GET_INTO(int32, sectNum); + GET_INTO(int32, sectNum); }*/ - } + } } void COFF::Fail(const StringImpl& error) -{ +{ DbgModule::Fail(StrFormat("%s in %s", error.c_str(), mPDBPath.c_str())); } @@ -5856,14 +5861,14 @@ void COFF::ParseGlobalsData() if (mParsedGlobalsData) return; ParseTypeData(); - mParsedGlobalsData = true; + mParsedGlobalsData = true; //gDbgPerfManager->StartRecording(); int startTypeIdx = (int)mTypes.size(); ParseSymbolStream(CvSymStreamType_Globals_Scan); - + //gDbgPerfManager->StopRecording(true); //int addedTypes = (int)mTypes.size() - startTypeIdx; @@ -5892,19 +5897,19 @@ bool COFF::ParseCv(DataStream& pdbFS, uint8* rootDirData, int pageSize, uint8 wa InitCvTypes(); - int startingTypeIdx = mTypes.size(); + int startingTypeIdx = mTypes.size(); uint8* data = rootDirData; bool failed = false; int numStreams = GET(int32); - if (numStreams == 0) + if (numStreams == 0) return true; mCvStreamSizes.Resize(numStreams); mCvStreamPtrStartIdxs.Resize(numStreams); - int streamPages = 0; + int streamPages = 0; for (int i = 0; i < (int)mCvStreamSizes.size(); i++) mCvStreamSizes[i] = GET(int32); for (int streamIdx = 0; streamIdx < numStreams; streamIdx++) @@ -5915,14 +5920,14 @@ bool COFF::ParseCv(DataStream& pdbFS, uint8* rootDirData, int pageSize, uint8 wa } mCvStreamPtrs.Resize(streamPages); for (int i = 0; i < (int)mCvStreamPtrs.size(); i++) - mCvStreamPtrs[i] = GET(int32); + mCvStreamPtrs[i] = GET(int32); ////////////////////////////////////////////////////////////////////////// if (!CvParseHeader(wantGuid, wantAge)) return false; - + if (!CvParseDBI(wantAge)) return false; @@ -5940,19 +5945,19 @@ bool COFF::ParseCv(DataStream& pdbFS, uint8* rootDirData, int pageSize, uint8 wa } for (int compileUnitId = 0; compileUnitId < (int)mCvModuleInfo.size(); compileUnitId++) - { + { ScanCompileUnit(compileUnitId); } ////////////////////////////////////////////////////////////////////////// - + return true; } void COFF::ReportMemory(MemReporter* memReporter) { DbgModule::ReportMemory(memReporter); - + memReporter->AddVec("mCvTypeMap", mCvTypeMap); memReporter->AddVec("mCvTagStartMap", mCvTagStartMap); memReporter->AddVec("mCvIPITagStartMap", mCvIPITagStartMap); @@ -5963,14 +5968,14 @@ void COFF::ReportMemory(MemReporter* memReporter) memReporter->AddVec(mCVSrcFileRefCache); if (mCvHeaderData != NULL) - memReporter->Add("mCvHeaderData", mCvStreamSizes[1]); - for (auto& entry : mCvTypeSectionData) + memReporter->Add("mCvHeaderData", mCvStreamSizes[1]); + for (auto& entry : mCvTypeSectionData) { if (entry.mSize != -1) memReporter->Add("mCvTypeSectionData", entry.mSize); else memReporter->Add("mCvTypeSectionData", mCvStreamSizes[2]); - } + } if (mCvStrTableData != NULL) memReporter->Add("mCvStrTableData", mCvStreamSizes[mStringTable.mStream]); if (mCvPublicSymbolData != NULL) @@ -5990,7 +5995,7 @@ bool COFF::TryLoadPDB(const String& pdbPath, uint8 wantGuid[16], int32 wantAge) mCvMappedFile = CreateFileA(pdbPath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL); if (mCvMappedFile == INVALID_HANDLE_VALUE) - { + { return false; } @@ -6023,22 +6028,22 @@ bool COFF::TryLoadPDB(const String& pdbPath, uint8 wantGuid[16], int32 wantAge) Fail("PDB signature error"); return false; } - + BfLogDbg("Loading PDB %s\n", pdbPath.c_str()); BP_ZONE_F("LoadCv %s", pdbPath.c_str()); - + int pageSize = mCvDataStream->ReadInt32(); int fpmPageNum = mCvDataStream->ReadInt32(); int totalPageCount = mCvDataStream->ReadInt32(); int rootDirSize = mCvDataStream->ReadInt32(); int unknown = mCvDataStream->ReadInt32(); - + int rootDirPtrs[NUM_ROOT_DIRS]; mCvDataStream->ReadT(rootDirPtrs); - + bool failed = false; - + mCvPageSize = pageSize; for (int i = 0; i < 31; i++) { @@ -6077,16 +6082,16 @@ bool COFF::TryLoadPDB(const String& pdbPath, uint8 wantGuid[16], int32 wantAge) } } - int startingTypeIdx = mTypes.size(); + int startingTypeIdx = mTypes.size(); if (!ParseCv(*mCvDataStream, &rootDirData[0], pageSize, wantGuid, wantAge)) { //mDebugger->OutputMessage("Failed to parse PDB\n"); - return false; + return false; } - + if (mCvDataStream->mFailed) return false; - + //OutputDebugStrF("COFF::TryLoadPDB %s\n", pdbPath.c_str()); if (!isVerifyOnly) mDebugger->ModuleChanged(this); @@ -6101,7 +6106,7 @@ void COFF::ClosePDB() delete mCvDataStream; mCvDataStream = NULL; delete mCvHeaderData; - mCvHeaderData = NULL; + mCvHeaderData = NULL; delete mCvStrTableData; mCvStrTableData = NULL; for (auto& entry : mCvTypeSectionData) @@ -6128,7 +6133,7 @@ void COFF::ClosePDB() for (auto kv : mHotLibMap) delete kv.mValue; - mHotLibMap.Clear(); + mHotLibMap.Clear(); mHotLibSymMap.Clear(); delete mEmitSourceFile; @@ -6136,7 +6141,7 @@ void COFF::ClosePDB() } bool COFF::LoadPDB(const String& pdbPath, uint8 wantGuid[16], int32 wantAge) -{ +{ if (mDebugTarget->mTargetBinary == this) { // If we don't have to load the debug symbols from a remote source or the cache @@ -6149,20 +6154,20 @@ bool COFF::LoadPDB(const String& pdbPath, uint8 wantGuid[16], int32 wantAge) memcpy(mWantPDBGuid, wantGuid, 16); mWantAge = wantAge; - mDbgSymRequest = mDebugger->mDbgSymSrv.CreateRequest(mFilePath, pdbPath, wantGuid, wantAge); + mDbgSymRequest = mDebugger->mDbgSymSrv.CreateRequest(mFilePath, pdbPath, wantGuid, wantAge); mDbgSymRequest->SearchLocal(); if (!mDbgSymRequest->mFinalPDBPath.IsEmpty()) - { + { TryLoadPDB(mDbgSymRequest->mFinalPDBPath, wantGuid, wantAge); mDebugger->mDbgSymSrv.ReleaseRequest(mDbgSymRequest); mDbgSymRequest = NULL; } else mMayBeOld = true; - + String fileName = GetFileName(mFilePath); - mWantsAutoLoadDebugInfo = !mDebugTarget->mWasLocallyBuilt; + mWantsAutoLoadDebugInfo = !mDebugTarget->mWasLocallyBuilt; if ((fileName.Equals("KERNEL32.DLL", String::CompareKind_OrdinalIgnoreCase)) || (fileName.Equals("KERNELBASE.DLL", String::CompareKind_OrdinalIgnoreCase)) || @@ -6193,7 +6198,7 @@ bool COFF::LoadPDB(const String& pdbPath, uint8 wantGuid[16], int32 wantAge) //char exePath[MAX_PATH]; //GetModuleFileNameA(NULL, exePath, sizeof(exePath)); - + /*String checkPath = ::GetFileDir(mFilePath); checkPath += "/"; checkPath += GetFileName(pdbPath); @@ -6215,12 +6220,12 @@ bool COFF::CheckSection(const char* name, uint8* sectionData, int sectionSize) DbgSectionData entry; entry.mData = sectionData; entry.mSize = sectionSize; - mCvTypeSectionData.Add(entry); + mCvTypeSectionData.Add(entry); return true; } if (strcmp(name, ".debug$S") == 0) - { + { DbgSectionData entry; entry.mData = sectionData; entry.mSize = sectionSize; @@ -6236,19 +6241,19 @@ void COFF::ProcessDebugInfo() BP_ZONE("COFF::ProcessDebugInfo"); if ((!mCvTypeSectionData.IsEmpty()) && (!mCvCompileUnitData.IsEmpty())) - { + { auto linkedModule = (COFF*)GetLinkedModule(); int startingTypeIdx = (int)linkedModule->mTypes.size(); InitCvTypes(); - + for (auto entry : mCvTypeSectionData) { uint8* data = entry.mData; GET_INTO(uint32, infoType); BF_ASSERT(infoType == CV_SIGNATURE_C13); - CvInitStreamRaw(mCvTypeSectionReader, entry.mData + 4, entry.mSize - 4); + CvInitStreamRaw(mCvTypeSectionReader, entry.mData + 4, entry.mSize - 4); ParseTypeData(mCvTypeSectionReader, 0); } @@ -6258,7 +6263,7 @@ void COFF::ProcessDebugInfo() CvCompileUnit* compileUnit = NULL; for (auto entry : mCvCompileUnitData) { - compileUnit = ParseCompileUnit(NULL, compileUnit, entry.mData, entry.mSize); + compileUnit = ParseCompileUnit(NULL, compileUnit, entry.mData, entry.mSize); } compileUnit->mLanguage = DbgLanguage_Beef; mMasterCompileUnit->mLanguage = DbgLanguage_Beef; @@ -6268,9 +6273,9 @@ void COFF::ProcessDebugInfo() } void COFF::FinishHotSwap() -{ +{ DbgModule::FinishHotSwap(); - mTypeMap.Clear(); + mTypeMap.Clear(); } intptr COFF::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, int locDataLen, WdStackFrame* stackFrame, DbgAddrType* outAddrType, DbgEvalLocFlags flags) @@ -6288,11 +6293,11 @@ intptr COFF::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, addr_target pc = 0; if (stackFrame != NULL) { - // Use 'GetSourcePC', which will offset the RSP when we're not at the top position of the call stack, since RSP will be the + // Use 'GetSourcePC', which will offset the RSP when we're not at the top position of the call stack, since RSP will be the // return address in those cases pc = stackFrame->GetSourcePC(); } - + int inlineDepth = 0; uint8* data = (uint8*)locData; for (int locIdx = 0; locIdx < locDataLen; locIdx++) @@ -6301,7 +6306,7 @@ intptr COFF::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, GET_INTO(uint16, symLen); uint8* dataEnd = data + symLen; GET_INTO(uint16, symType); - + CV_LVAR_ADDR_RANGE* rangeInfo = NULL; CV_LVAR_ADDR_GAP* gapsInfo = NULL; addr_target result = 0; @@ -6322,7 +6327,7 @@ intptr COFF::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, case S_GDATA32: case S_LDATA32: { - DATASYM32& dataSym = *(DATASYM32*)dataStart; + DATASYM32& dataSym = *(DATASYM32*)dataStart; *outAddrType = DbgAddrType_Target; return GetSectionAddr(dataSym.seg, dataSym.off); } @@ -6344,10 +6349,10 @@ intptr COFF::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, case S_GTHREAD32: { THREADSYM32& threadSym = *(THREADSYM32*)dataStart; - + int tlsIndex = mDebugger->ReadMemory(mTLSIndexAddr); addr_target tlsEntry = mDebugger->GetTLSOffset(tlsIndex); - + *outAddrType = DbgAddrType_Target; return threadSym.off + tlsEntry; } @@ -6364,7 +6369,7 @@ intptr COFF::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, { REGREL32* regRel32 = (REGREL32*)dataStart; *outAddrType = DbgAddrType_Target; - int regNum = CvConvRegNum(regRel32->reg); + int regNum = CvConvRegNum(regRel32->reg); return stackFrame->mRegisters.mIntRegsArray[regNum] + regRel32->off; } break; @@ -6380,36 +6385,36 @@ intptr COFF::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, case S_DEFRANGE_FRAMEPOINTER_REL: { DEFRANGESYMFRAMEPOINTERREL& defRangeFPRel = *(DEFRANGESYMFRAMEPOINTERREL*)dataStart; - + DbgSubprogram::LocalBaseRegKind baseReg = ((flags & DbgEvalLocFlag_IsParam) != 0) ? dwSubprogram->mParamBaseReg : dwSubprogram->mLocalBaseReg; *outAddrType = DbgAddrType_Target; -#ifdef BF_DBG_64 +#ifdef BF_DBG_64 if (baseReg == DbgSubprogram::LocalBaseRegKind_RSP) result = stackFrame->mRegisters.mIntRegsArray[X64Reg_RSP] + defRangeFPRel.offFramePointer; else if (baseReg == DbgSubprogram::LocalBaseRegKind_R13) result = stackFrame->mRegisters.mIntRegsArray[X64Reg_R13] + defRangeFPRel.offFramePointer; else result = stackFrame->mRegisters.mIntRegsArray[X64Reg_RBP] + defRangeFPRel.offFramePointer; -#else +#else if (baseReg == DbgSubprogram::LocalBaseRegKind_VFRAME) - result = stackFrame->mRegisters.mIntRegsArray[X86Reg_ESP] + dwSubprogram->mFrameBaseLen + defRangeFPRel.offFramePointer; + result = stackFrame->mRegisters.mIntRegsArray[X86Reg_ESP] + dwSubprogram->mFrameBaseLen + defRangeFPRel.offFramePointer; else if (baseReg == DbgSubprogram::LocalBaseRegKind_EBX) result = stackFrame->mRegisters.mIntRegsArray[X86Reg_EBX] + defRangeFPRel.offFramePointer; else result = stackFrame->mRegisters.mIntRegsArray[X86Reg_EBP] + defRangeFPRel.offFramePointer; -#endif - +#endif + rangeInfo = &defRangeFPRel.range; gapsInfo = &defRangeFPRel.gaps[0]; } break; case S_DEFRANGE_SUBFIELD_REGISTER: { - DEFRANGESYMSUBFIELDREGISTER& defRangeSubfieldReg = *(DEFRANGESYMSUBFIELDREGISTER*)dataStart; - + DEFRANGESYMSUBFIELDREGISTER& defRangeSubfieldReg = *(DEFRANGESYMSUBFIELDREGISTER*)dataStart; + *outAddrType = DbgAddrType_Target; - int regNum = CvConvRegNum(defRangeSubfieldReg.reg); + int regNum = CvConvRegNum(defRangeSubfieldReg.reg); result = stackFrame->mRegisters.mIntRegsArray[regNum] + defRangeSubfieldReg.offParent; rangeInfo = &defRangeSubfieldReg.range; @@ -6424,7 +6429,7 @@ intptr COFF::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, int regNum = X64Reg_RSP; #else int regNum = X86Reg_ESP; -#endif +#endif *outAddrType = DbgAddrType_Target; result = stackFrame->mRegisters.mIntRegsArray[regNum] + defFPRel.offFramePointer; return result; @@ -6449,7 +6454,7 @@ intptr COFF::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, { inlineDepth++; } - break; + break; case S_FILESTATIC: { FILESTATICSYM& fileStaticSym = *(FILESTATICSYM*)dataStart; @@ -6462,9 +6467,9 @@ intptr COFF::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, } if (rangeInfo != NULL) - { - auto rangeStart = GetSectionAddr(rangeInfo->isectStart, rangeInfo->offStart); - + { + auto rangeStart = GetSectionAddr(rangeInfo->isectStart, rangeInfo->offStart); + if ((pc >= rangeStart) && (pc < rangeStart + rangeInfo->cbRange)) { bool inRange = true; @@ -6473,7 +6478,7 @@ intptr COFF::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, if ((pc >= rangeStart + gapsInfo->gapStartOffset) && (pc < rangeStart + gapsInfo->gapStartOffset + gapsInfo->cbRange)) { inRange = false; - break; + break; } gapsInfo++; } @@ -6502,7 +6507,7 @@ String COFF::GetOldSourceCommand(const StringImpl& path) { if (mCvSrcSrvStream == -1) return ""; - + int outSize; uint8* data = CvReadStream(mCvSrcSrvStream, &outSize); String cmdBlock = String((char*)data, outSize); @@ -6519,7 +6524,7 @@ String COFF::GetOldSourceCommand(const StringImpl& path) _SectType_SourceFiles }; _SectType sectType = _SectType_None; - + // { AutoCrit autoCrit(gDebugManager->mCritSect); @@ -6535,7 +6540,7 @@ String COFF::GetOldSourceCommand(const StringImpl& path) int endIdx = str.IndexOf('%', i + 1); if (endIdx != -1) { - String varName = ToUpper(str.Substring(i + 1, endIdx - i - 1)); + String varName = ToUpper(str.Substring(i + 1, endIdx - i - 1)); if (((endIdx < str.length() - 1) && (str[endIdx + 1] == '(')) && ((varName == "FNVAR") || (varName == "FNBKSL") || (varName == "FNFILE"))) { @@ -6552,7 +6557,7 @@ String COFF::GetOldSourceCommand(const StringImpl& path) else { if (varName == "FNBKSL") - { + { paramStr.Replace("/", "\\"); } else if (varName == "FNFILE") @@ -6636,7 +6641,7 @@ String COFF::GetOldSourceCommand(const StringImpl& path) int starPos = line.IndexOf('*', curStrPos); if (starPos == -1) starPos = line.length(); - + //var = line.Substring(curStrPos, starPos - curStrPos); var.Clear(); var.Insert(0, line.c_str() + curStrPos, starPos - curStrPos); @@ -6647,7 +6652,7 @@ String COFF::GetOldSourceCommand(const StringImpl& path) if (!matches) break; } - + defs[StrFormat("VAR%d", curStrIdx + 1)] = var; curStrIdx++; @@ -6664,7 +6669,7 @@ String COFF::GetOldSourceCommand(const StringImpl& path) _Expand(target); _Expand(cmd); _Expand(env); - + String retVal; if ((cmd.IsEmpty()) && (target.StartsWith("HTTP", StringImpl::CompareKind_OrdinalIgnoreCase))) { @@ -6678,7 +6683,7 @@ String COFF::GetOldSourceCommand(const StringImpl& path) localFile.Append("SymbolCache\\src\\"); localFile.Append(StringView(target, dotPos + 3)); localFile.Replace("/", "\\"); - } + } retVal = localFile; retVal += "\n"; @@ -6694,11 +6699,11 @@ String COFF::GetOldSourceCommand(const StringImpl& path) retVal += "\n"; retVal += env; } - + return retVal; } break; - } + } } linePos = crPos + 1; @@ -6711,7 +6716,7 @@ bool COFF::GetEmitSource(const StringImpl& filePath, String& outText) { if (!filePath.StartsWith("$Emit")) return false; - + if (mEmitSourceFile == NULL) { mEmitSourceFile = new ZipFile(); @@ -6724,10 +6729,10 @@ bool COFF::GetEmitSource(const StringImpl& filePath, String& outText) { if (mCvEmitStream == -1) return ""; - + int outSize; uint8* data = CvReadStream(mCvEmitStream, &outSize); - + FileStream fileStream; fileStream.Open(zipPath, "wb"); fileStream.Write(data, outSize); @@ -6746,7 +6751,7 @@ bool COFF::GetEmitSource(const StringImpl& filePath, String& outText) { int dollarPos = usePath.IndexOf('$', 1); usePath.Remove(0, dollarPos + 1); - } + } usePath = EncodeFileName(usePath); usePath.Append(".bf"); @@ -6846,20 +6851,20 @@ bool COFF::RequestImage() return false; auto miniDumpDebugger = (MiniDumpDebugger*)mDebugger; - + if (mOrigImageData != NULL) return false; if (GetCurrentThreadId() == mDebugger->mDebuggerThreadId) - { + { auto prevRunState = mDebugger->mRunState; mDebugger->mRunState = RunState_SearchingSymSrv; mDebugger->mDebugManager->mOutMessages.push_back(StrFormat("symsrv Searching for image '%s'", mFilePath.c_str())); - + auto dbgSymRequest = mDebugger->mDbgSymSrv.CreateRequest(); mDebugger->mActiveSymSrvRequest = dbgSymRequest; BF_ASSERT(mDebugger->mDebugManager->mCritSect.mLockCount == 1); - mDebugger->mDebugManager->mCritSect.Unlock(); + mDebugger->mDebugManager->mCritSect.Unlock(); // We unlock to allow the IDE to continue updating while we search String imagePath = dbgSymRequest->SearchForImage(mFilePath, mTimeStamp, mImageSize); mDebugger->mDebugManager->mCritSect.Lock(); @@ -6867,8 +6872,8 @@ bool COFF::RequestImage() mDebugger->mActiveSymSrvRequest = NULL; mDebugger->mRunState = prevRunState; - - return LoadModuleImage(imagePath); + + return LoadModuleImage(imagePath); } else { @@ -6885,28 +6890,28 @@ bool COFF::RequestDebugInfo(bool allowRemote) if (mDbgSymRequest->mInProcess) return false; - + bool hasDebugInfo = false; mDbgSymRequest->SearchCache(); if (mDbgSymRequest->mFinalPDBPath.IsEmpty()) - { + { if (!allowRemote) return false; if (GetCurrentThreadId() == mDebugger->mDebuggerThreadId) - { + { auto prevRunState = mDebugger->mRunState; mDebugger->mRunState = RunState_SearchingSymSrv; - + mDbgSymRequest->mInProcess = true; mDebugger->mActiveSymSrvRequest = mDbgSymRequest; BF_ASSERT(mDebugger->mDebugManager->mCritSect.mLockCount == 1); - mDebugger->mDebugManager->mCritSect.Unlock(); + mDebugger->mDebugManager->mCritSect.Unlock(); mDbgSymRequest->SearchSymSrv(); mDebugger->mDebugManager->mCritSect.Lock(); mDebugger->mActiveSymSrvRequest = NULL; mDbgSymRequest->mInProcess = false; - + mDebugger->mRunState = prevRunState; } else @@ -6958,7 +6963,7 @@ addr_target COFF::LocateSymbol(const StringImpl& name) String libName = moduleInfo->mObjectName; if (!libName.EndsWith(".lib", StringImpl::CompareKind_OrdinalIgnoreCase)) continue; - + CvLibInfo** libInfoPtr; if (!mHotLibMap.TryAdd(libName, NULL, &libInfoPtr)) continue; @@ -6966,7 +6971,7 @@ addr_target COFF::LocateSymbol(const StringImpl& name) CvLibInfo* libInfo = new CvLibInfo(); *libInfoPtr = libInfo; - if (!libInfo->mLibFile.Init(libName, false)) + if (!libInfo->mLibFile.Init(libName, false)) continue; for (auto kv : libInfo->mLibFile.mOldEntries) @@ -7001,14 +7006,14 @@ addr_target COFF::LocateSymbol(const StringImpl& name) // We already tried to load this return 0; } - + auto fileExt = GetFileExtension(libEntry->mName); if (String::Equals(fileExt, ".dll", StringImpl::CompareKind_OrdinalIgnoreCase)) { for (auto dbgModule : mDebugTarget->mDbgModules) { if (String::Equals(libEntry->mName, dbgModule->mDisplayName)) - { + { dbgModule->ParseSymbolData(); auto entry = dbgModule->mSymbolNameMap.Find(name.c_str()); if (entry == NULL) @@ -7042,7 +7047,7 @@ addr_target COFF::LocateSymbol(const StringImpl& name) { uint8 mOpCode0; uint8 mOpCode1; - int32 mRIPRel; + int32 mRIPRel; uint64 mTarget; }; #pragma pack(pop) @@ -7074,9 +7079,9 @@ addr_target COFF::LocateSymbol(const StringImpl& name) // #ifdef _DEBUG // FILE* fpTest = fopen("c:\\temp\\locateSym.obj", "wb"); -// +// // uint8* data = new uint8[libEntry->mLength]; -// +// // fseek(libEntry->mLibFile->mOldFileStream.mFP, libEntry->mOldDataPos + sizeof(BeLibMemberHeader), SEEK_SET); // fread(data, 1, libEntry->mLength, libEntry->mLibFile->mOldFileStream.mFP); // fwrite(data, 1, libEntry->mLength, fpTest); @@ -7107,7 +7112,7 @@ addr_target COFF::LocateSymbol(const StringImpl& name) Fail(StrFormat("Debugger failed to read binary '%s' in '%s'", libEntry->mName.c_str(), libEntry->mLibFile->mFilePath.c_str())); delete dbgModule; return 0; - } + } mDebugger->mDebugTarget->AddDbgModule(dbgModule); auto symbolEntry = mSymbolNameMap.Find(name.c_str()); @@ -7252,10 +7257,10 @@ NS_BF_DBG_BEGIN // COFF coff(debugTarget); // coff.mCvTypeSectionData = (uint8*)tdata; // coff.mCvTypeSectionDataSize = tdataSize; -// +// // coff.mCvCompileUnitData = (uint8*)cuData; // coff.mCvCompileUnitDataSize = cuDataSize; -// +// // coff.ProcessDebugInfo(); // } // delete debugTarget; @@ -7264,7 +7269,7 @@ NS_BF_DBG_BEGIN void TestPDB(const StringImpl& fileName, WinDebugger* debugger) { DebugTarget* debugTarget = new DebugTarget(NULL); - COFF coff(debugTarget); + COFF coff(debugTarget); coff.mDebugger = debugger; uint8 wantGuid[16]; coff.TryLoadPDB(fileName, wantGuid, -1); diff --git a/IDEHelper/Compiler/BfIRBuilder.cpp b/IDEHelper/Compiler/BfIRBuilder.cpp index 82fb6564..6b7e5cd1 100644 --- a/IDEHelper/Compiler/BfIRBuilder.cpp +++ b/IDEHelper/Compiler/BfIRBuilder.cpp @@ -3334,6 +3334,13 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type) constDIType, flags, useIntConstant ? intConstant : BfIRValue()); diFieldTypes.push_back(memberType); + if (fieldDef->mUsingProtection != BfProtection_Hidden) + { + auto memberType = DbgCreateStaticMemberType(diForwardDecl, "$using$" + fieldName, fileDIScope, 0, + constDIType, flags, useIntConstant ? intConstant : BfIRValue()); + diFieldTypes.push_back(memberType); + } + if (staticValue) { String qualifiedName = DbgGetStaticFieldName(fieldInstance); @@ -3384,6 +3391,13 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type) resolvedFieldDIType, flags, BfIRValue()); diFieldTypes.push_back(memberType); + if (fieldDef->mUsingProtection != BfProtection_Hidden) + { + auto memberType = DbgCreateStaticMemberType(diForwardDecl, "$using$" + fieldDef->mName, fileDIScope, 0, + resolvedFieldDIType, flags, BfIRValue()); + diFieldTypes.push_back(memberType); + } + StringT<128> staticVarName; BfMangler::Mangle(staticVarName, mModule->mCompiler->GetMangleKind(), fieldInstance); if (!staticVarName.StartsWith('#')) @@ -3416,6 +3430,14 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type) fieldInstance->mDataSize * 8, resolvedFieldType->mAlign * 8, fieldInstance->mDataOffset * 8, flags, resolvedFieldDIType); diFieldTypes.push_back(memberType); + + if (fieldDef->mUsingProtection != BfProtection_Hidden) + { + auto memberType = DbgCreateMemberType(diForwardDecl, "$using$" + fieldName, fileDIScope, lineNum, + fieldInstance->mDataSize * 8, resolvedFieldType->mAlign * 8, fieldInstance->mDataOffset * 8, + flags, resolvedFieldDIType); + diFieldTypes.push_back(memberType); + } } } } diff --git a/IDEHelper/Compiler/BfIRCodeGen.cpp b/IDEHelper/Compiler/BfIRCodeGen.cpp index 26d1a419..9b08751e 100644 --- a/IDEHelper/Compiler/BfIRCodeGen.cpp +++ b/IDEHelper/Compiler/BfIRCodeGen.cpp @@ -4488,7 +4488,11 @@ void BfIRCodeGen::HandleNextCmd() os << "\n"; os.flush();*/ - auto member = mDIBuilder->createMemberType((llvm::DIScope*)scope, name.c_str(), (llvm::DIFile*)file, lineNumber, sizeInBits, (uint32)alignInBits, offsetInBits, diFlags, (llvm::DIType*)type); + const char* namePtr = name.c_str(); + if (name.IsEmpty()) + namePtr = NULL; + + auto member = mDIBuilder->createMemberType((llvm::DIScope*)scope, namePtr, (llvm::DIFile*)file, lineNumber, sizeInBits, (uint32)alignInBits, offsetInBits, diFlags, (llvm::DIType*)type); SetResult(curId, member); //OutputDebugStrF("BfIRCmd_DbgCreateMemberType = %p\n", member); } diff --git a/IDEHelper/DbgExprEvaluator.cpp b/IDEHelper/DbgExprEvaluator.cpp index 2b2a78d3..d36a34d3 100644 --- a/IDEHelper/DbgExprEvaluator.cpp +++ b/IDEHelper/DbgExprEvaluator.cpp @@ -21,7 +21,7 @@ using namespace llvm; DwMethodMatcher::DwMethodMatcher(BfAstNode* targetSrc, DbgExprEvaluator* exprEvaluator, const StringImpl& methodName, SizedArrayImpl& arguments, BfSizedArray* methodGenericArguments) : mArguments(arguments) -{ +{ mTargetSrc = targetSrc; mExprEvaluator = exprEvaluator; mMethodName = methodName; @@ -29,12 +29,12 @@ DwMethodMatcher::DwMethodMatcher(BfAstNode* targetSrc, DbgExprEvaluator* exprEva mBestMethodDef = NULL; mBackupMethodDef = NULL; mBestMethodTypeInstance = NULL; - mExplicitInterfaceCheck = NULL; - mHadExplicitGenericArguments = false; + mExplicitInterfaceCheck = NULL; + mHadExplicitGenericArguments = false; mTargetIsConst = false; if (methodGenericArguments != NULL) - { + { for (auto genericArg : *methodGenericArguments) { if (genericArg == NULL) @@ -46,7 +46,7 @@ DwMethodMatcher::DwMethodMatcher(BfAstNode* targetSrc, DbgExprEvaluator* exprEva //mBestMethodGenericArgumentSrcs.push_back(genericArg); } mHadExplicitGenericArguments = true; - } + } } /*bool DwMethodMatcher::InferGenericArgument(DbgType* argType, DbgType* wantType) @@ -60,15 +60,15 @@ DwMethodMatcher::DwMethodMatcher(BfAstNode* targetSrc, DbgExprEvaluator* exprEva if (wantGenericParam->mGenericParamKind == BfGenericParamKind_Method) { auto prevGenericMethodArg = mCheckMethodGenericArguments[wantGenericParam->mGenericParamIdx]; - if (prevGenericMethodArg == NULL) + if (prevGenericMethodArg == NULL) { mCheckMethodGenericArguments[wantGenericParam->mGenericParamIdx] = argType; return true; - } + } // Prev is already best if (mModule->CanCast(DbgTypedValue(NULL, argType), prevGenericMethodArg)) - return true; + return true; // New best? if (mModule->CanCast(DbgTypedValue(NULL, prevGenericMethodArg), argType)) @@ -115,18 +115,18 @@ DwMethodMatcher::DwMethodMatcher(BfAstNode* targetSrc, DbgExprEvaluator* exprEva if (!argType->IsPointer()) return true; auto wantPointerType = (BfPointerType*) wantType; - auto argPointerType = (BfPointerType*) argType; + auto argPointerType = (BfPointerType*) argType; InferGenericArgument(argPointerType->mElementType, wantPointerType->mElementType); return true; } - - return true; + + return true; }*/ void DwMethodMatcher::CompareMethods(DbgSubprogram* prevMethodInstance, DwTypeVector* prevGenericArgumentsSubstitute, - DbgSubprogram* newMethodInstance, DwTypeVector* genericArgumentsSubstitute, + DbgSubprogram* newMethodInstance, DwTypeVector* genericArgumentsSubstitute, bool* outNewIsBetter, bool* outNewIsWorse, bool allowSpecializeFail) -{ +{ int numUsedParams = 0; int prevNumUsedParams = 0; bool usedExtendedForm = false; @@ -135,16 +135,16 @@ void DwMethodMatcher::CompareMethods(DbgSubprogram* prevMethodInstance, DwTypeVe bool isBetter = false; bool isWorse = false; int argIdx = 0; - + DbgSubprogram* prevMethodDef = prevMethodInstance; DbgSubprogram* newMethodDef = newMethodInstance; #define SET_BETTER_OR_WORSE(lhs, rhs) \ if ((lhs) && !(rhs)) isBetter = true; \ if (!(lhs) && (rhs)) isWorse = true; - + int newArgOffset = newMethodInstance->mHasThis ? 1 : 0; - int prevArgOffset = prevMethodInstance->mHasThis ? 1 : 0; + int prevArgOffset = prevMethodInstance->mHasThis ? 1 : 0; DbgVariable* param = newMethodInstance->mParams.mHead; if (newMethodInstance->mHasThis) @@ -267,7 +267,7 @@ void DwMethodMatcher::CompareMethods(DbgSubprogram* prevMethodInstance, DwTypeVe DbgType* paramType = param->mType; DbgType* prevParamType = prevParam->mType; - //TODO: + //TODO: //isBetter |= mModule->IsTypeMoreSpecific(paramType, prevParamType); //isWorse |= mModule->IsTypeMoreSpecific(prevParamType, paramType); @@ -293,13 +293,13 @@ void DwMethodMatcher::CompareMethods(DbgSubprogram* prevMethodInstance, DwTypeVe if ((newMethodInstance->mHasThis) && (prevMethodInstance->mHasThis)) { SET_BETTER_OR_WORSE( - newMethodInstance->mParams.mHead->mType->IsConst() == mTargetIsConst, + newMethodInstance->mParams.mHead->mType->IsConst() == mTargetIsConst, prevMethodInstance->mParams.mHead->mType->IsConst() == mTargetIsConst); } } *outNewIsBetter = isBetter; - *outNewIsWorse = isWorse; + *outNewIsWorse = isWorse; } bool DwMethodMatcher::CheckMethod(DbgType* typeInstance, DbgSubprogram* checkMethod) @@ -308,7 +308,7 @@ bool DwMethodMatcher::CheckMethod(DbgType* typeInstance, DbgSubprogram* checkMet checkMethod->PopulateSubprogram(); - // Never consider overrides - they only get found at original method declaration + // Never consider overrides - they only get found at original method declaration /*if ((checkMethod->mVirtual) && (checkMethod->mVTableLoc == -1)) return true;*/ @@ -319,24 +319,24 @@ bool DwMethodMatcher::CheckMethod(DbgType* typeInstance, DbgSubprogram* checkMet if ((autoComplete != NULL) && (autoComplete->mIsCapturingMethodMatchInfo)) { DwAutoComplete::MethodMatchEntry methodMatchEntry; - methodMatchEntry.mDwSubprogram = methodInstance; - autoComplete->mMethodMatchInfo->mInstanceList.push_back(methodMatchEntry); + methodMatchEntry.mDwSubprogram = methodInstance; + autoComplete->mMethodMatchInfo->mInstanceList.push_back(methodMatchEntry); } /*if ((mHadExplicitGenericArguments) && (checkMethod->mGenericParams.size() != mBestMethodGenericArguments.size())) goto NoMatch;*/ - + for (auto& checkGenericArgRef : mCheckMethodGenericArguments) checkGenericArgRef = NULL; - /*mCheckMethodGenericArguments.resize(checkMethod->mGenericParams.size()); + /*mCheckMethodGenericArguments.resize(checkMethod->mGenericParams.size()); for (auto& genericArgRef : mCheckMethodGenericArguments) genericArgRef = NULL;*/ - + int argIdx = 0; - int paramIdx = 0; + int paramIdx = 0; DbgType* paramsElementType = NULL; - + //bool needInferGenericParams = (checkMethod->mGenericParams.size() != 0) && (!mHadExplicitGenericArguments); DwTypeVector* genericArgumentsSubstitute = NULL; @@ -358,21 +358,21 @@ bool DwMethodMatcher::CheckMethod(DbgType* typeInstance, DbgSubprogram* checkMet goto NoMatch; } } - + for (int checkArgIdx = 0; checkArgIdx < (int) checkMethod->mGenericParams.size(); checkArgIdx++) if (mCheckMethodGenericArguments[checkArgIdx] == NULL) goto NoMatch; }*/ // Iterate through params - + int paramOffset = checkMethod->mHasThis ? 1 : 0; while (true) - { + { // Too many arguments if (paramIdx >= checkMethod->mParams.Size() - paramOffset) - { + { break; } @@ -395,7 +395,7 @@ bool DwMethodMatcher::CheckMethod(DbgType* typeInstance, DbgSubprogram* checkMet paramIdx++; break; } - + BF_ASSERT(paramsArrayType->IsArray()); auto arrayType = (BfArrayType*)paramsArrayType; paramsElementType = arrayType->mTypeGenericArguments[0]; @@ -429,10 +429,10 @@ bool DwMethodMatcher::CheckMethod(DbgType* typeInstance, DbgSubprogram* checkMet if (!mArguments[argIdx]) goto NoMatch; - + if (!mExprEvaluator->CanCast(mArguments[argIdx], wantType)) goto NoMatch; - + paramIdx++; argIdx++; @@ -444,12 +444,12 @@ bool DwMethodMatcher::CheckMethod(DbgType* typeInstance, DbgSubprogram* checkMet bool isBetter = false; bool isWorse = false; int methodIdx = (int)methodMatchInfo->mInstanceList.size() - 1; - + if (methodMatchInfo->mBestIdx < (int)methodMatchInfo->mInstanceList.size()) - { + { auto prevMethodMatchEntry = &methodMatchInfo->mInstanceList[methodMatchInfo->mBestIdx]; if (checkMethod->mParams.Size() < (int)mArguments.size()) - { + { isWorse = true; } else if (prevMethodMatchEntry->mDwSubprogram->mParams.Size() < (int) mArguments.size()) @@ -464,7 +464,7 @@ bool DwMethodMatcher::CheckMethod(DbgType* typeInstance, DbgSubprogram* checkMet methodInstance, genericArgumentsSubstitute, &isBetter, &isWorse, true); } } - + if ((argIdx > methodMatchInfo->mMostParamsMatched) || ((argIdx == methodMatchInfo->mMostParamsMatched) && (isBetter)) || ((argIdx == methodMatchInfo->mMostParamsMatched) && (methodIdx == methodMatchInfo->mPrevBestIdx) && (!isWorse))) @@ -479,7 +479,7 @@ bool DwMethodMatcher::CheckMethod(DbgType* typeInstance, DbgSubprogram* checkMet //TODO: Does this ever get hit? // Not enough arguments? if (argIdx < (int)mArguments.size()) - { + { goto NoMatch; } @@ -503,11 +503,11 @@ bool DwMethodMatcher::CheckMethod(DbgType* typeInstance, DbgSubprogram* checkMet methodInstance->ToString().c_str()), mTargetSrc); } } - + if (!isBetter) goto Done; } - + if ((autoComplete != NULL) && (autoComplete->mIsCapturingMethodMatchInfo)) { auto methodMatchInfo = autoComplete->mMethodMatchInfo; @@ -525,10 +525,10 @@ bool DwMethodMatcher::CheckMethod(DbgType* typeInstance, DbgSubprogram* checkMet NoMatch: if (!hadMatch) - { + { if (mBestMethodDef != NULL) return true; - + //TODO: /*if ((mHadExplicitGenericArguments) && (mBestMethodGenericArguments.size() != checkMethod->mGenericParams.size())) return true;*/ @@ -536,25 +536,25 @@ NoMatch: // At least prefer a backup method that we have an address for if ((mBackupMethodDef != NULL) && (mBackupMethodDef->mBlock.mLowPC != 0)) return true; - + mBackupMethodDef = checkMethod; // Lie temporarily to store at least one candidate (but mBestMethodDef is still NULL) hadMatch = true; } - + if (hadMatch) { mBestMethodTypeInstance = typeInstance; if (!mHadExplicitGenericArguments) - { - mBestMethodGenericArguments = mCheckMethodGenericArguments; - } + { + mBestMethodGenericArguments = mCheckMethodGenericArguments; + } } Done: if ((autoComplete != NULL) && (autoComplete->mIsCapturingMethodMatchInfo) && (genericArgumentsSubstitute != NULL)) { - auto methodMatchInfo = autoComplete->mMethodMatchInfo; + auto methodMatchInfo = autoComplete->mMethodMatchInfo; methodMatchInfo->mInstanceList[methodMatchInfo->mInstanceList.size() - 1].mDwGenericArguments = *genericArgumentsSubstitute; } @@ -573,7 +573,7 @@ bool DwMethodMatcher::CheckType(DbgType* typeInstance, bool isFailurePass) bool allowPrivate = true; bool allowProtected = true; - auto curType = typeInstance; + auto curType = typeInstance; bool wantCtor = false; @@ -581,7 +581,7 @@ bool DwMethodMatcher::CheckType(DbgType* typeInstance, bool isFailurePass) auto altItr = typeInstance->mAlternates.begin(); while (true) - { + { bool foundMethodInType = false; curType->PopulateType(); @@ -593,7 +593,7 @@ bool DwMethodMatcher::CheckType(DbgType* typeInstance, bool isFailurePass) // These aren't proper TPI types so we don't have any method declarations until we PopulateTypeGlobals mExprEvaluator->mDbgModule->PopulateTypeGlobals(curType); } - + for (auto methodNameEntry : curType->mMethodNameList) { if ((methodNameEntry->mCompileUnitId != -1) && (methodNameEntry->mName == mMethodName)) @@ -602,7 +602,7 @@ bool DwMethodMatcher::CheckType(DbgType* typeInstance, bool isFailurePass) if (!curType->mCompileUnit->mDbgModule->IsObjectFile()) curType->mCompileUnit->mDbgModule->MapCompileUnitMethods(methodNameEntry->mCompileUnitId); methodNameEntry->mCompileUnitId = -1; - } + } } auto checkMethod = curType->mMethodList.mHead; @@ -641,12 +641,12 @@ bool DwMethodMatcher::CheckType(DbgType* typeInstance, bool isFailurePass) checkMethod = checkMethod->mNext; continue; } - + if (!curType->mHasGlobalsPopulated) - mExprEvaluator->mDbgModule->PopulateTypeGlobals(curType); + mExprEvaluator->mDbgModule->PopulateTypeGlobals(curType); /*if (!foundMethodInType) - { + { if (curType->mCompileUnit->mLanguage != DbgLanguage_Beef) { String fullMethodName = String(curType->mTypeName) + "::" + mMethodName; @@ -659,7 +659,7 @@ bool DwMethodMatcher::CheckType(DbgType* typeInstance, bool isFailurePass) return false; checkMethod = checkMethod->mNext; - } + } if (mBestMethodDef != NULL) { @@ -672,7 +672,7 @@ bool DwMethodMatcher::CheckType(DbgType* typeInstance, bool isFailurePass) else return true; } - + /*if (baseItr != typeInstance->mBaseTypes.end()) { auto baseTypeEntry = *baseItr; @@ -680,13 +680,13 @@ bool DwMethodMatcher::CheckType(DbgType* typeInstance, bool isFailurePass) baseItr++; continue;; }*/ - + if (altItr != typeInstance->mAlternates.end()) - { + { curType = *altItr; ++altItr; continue; - } + } /*allowPrivate = false; @@ -694,11 +694,11 @@ bool DwMethodMatcher::CheckType(DbgType* typeInstance, bool isFailurePass) break;*/ break; } - + if (mBestMethodDef == NULL) { // FAILED, but select the first method which will fire an actual error on param type matching - mBestMethodDef = mBackupMethodDef; + mBestMethodDef = mBackupMethodDef; for (auto subType : typeInstance->mSubTypeList) { @@ -720,7 +720,7 @@ bool DwMethodMatcher::CheckType(DbgType* typeInstance, bool isFailurePass) if (mBestMethodDef != NULL) break; } - } + } } return true; @@ -729,12 +729,12 @@ bool DwMethodMatcher::CheckType(DbgType* typeInstance, bool isFailurePass) ////////////////////////////////////////////////////////////////////////// DbgExprEvaluator::DbgExprEvaluator(WinDebugger* winDebugger, DbgModule* dbgModule, BfPassInstance* passInstance, int callStackIdx, int cursorPos) -{ +{ mCountResultOverride = -1; mCapturingChildRef = true; mPassInstance = passInstance; mDebugger = winDebugger; - mLanguage = DbgLanguage_NotSet; + mLanguage = DbgLanguage_NotSet; mOrigDbgModule = dbgModule; if (dbgModule != NULL) { @@ -752,7 +752,7 @@ DbgExprEvaluator::DbgExprEvaluator(WinDebugger* winDebugger, DbgModule* dbgModul mExpectingType = NULL; mCurMethod = NULL; mIgnoreErrors = false; - mCallStackIdx = callStackIdx; + mCallStackIdx = callStackIdx; mCursorPos = cursorPos; mAutoComplete = NULL; mIsEmptyTarget = (dbgModule == NULL) || (dbgModule->mDebugTarget->mIsEmpty); @@ -775,7 +775,7 @@ DbgExprEvaluator::DbgExprEvaluator(WinDebugger* winDebugger, DbgModule* dbgModul } DbgExprEvaluator::~DbgExprEvaluator() -{ +{ delete mStackSearch; } @@ -784,7 +784,7 @@ DbgTypedValue DbgExprEvaluator::GetInt(int value) DbgTypedValue dbgValue; dbgValue.mType = mDbgModule->GetPrimitiveType(DbgType_i32, GetLanguage()); dbgValue.mInt32 = value; - return dbgValue; + return dbgValue; } DbgTypedValue DbgExprEvaluator::GetString(const StringImpl& str) @@ -804,7 +804,7 @@ DbgTypedValue DbgExprEvaluator::GetString(const StringImpl& str) dbgValue.mLocalPtr = resultPtr->c_str(); dbgValue.mIsLiteral = true; dbgValue.mDataLen = resultPtr->mLength; - } + } return dbgValue; } @@ -832,7 +832,7 @@ DbgType* DbgExprEvaluator::GetExpectingType() } void DbgExprEvaluator::GetNamespaceSearch() -{ +{ if (!mNamespaceSearch.empty()) return; @@ -841,13 +841,13 @@ void DbgExprEvaluator::GetNamespaceSearch() { auto parent = currentMethod->GetParent(); while (parent != NULL) - { + { parent = parent->GetPrimaryType(); - mNamespaceSearch.push_back(parent); + mNamespaceSearch.push_back(parent); parent = parent->mParent; } } - + if (!mNamespaceSearchStr.empty()) { auto language = GetLanguage(); @@ -868,7 +868,7 @@ void DbgExprEvaluator::GetNamespaceSearch() auto dbgTypeEntry = mDbgModule->mTypeMap.Find(namespaceEntry.c_str(), language); if (dbgTypeEntry != NULL) mNamespaceSearch.push_back(dbgTypeEntry->mValue); - } + } } DbgType* DbgExprEvaluator::ResolveSubTypeRef(DbgType* checkType, const StringImpl& name) @@ -900,7 +900,7 @@ DbgType* DbgExprEvaluator::FixType(DbgType* dbgType) DbgTypedValue DbgExprEvaluator::FixThis(const DbgTypedValue& thisVal) { - /*if ((thisVal.mType != NULL) && (thisVal.mType->GetLanguage() == DbgLanguage_Beef) && + /*if ((thisVal.mType != NULL) && (thisVal.mType->GetLanguage() == DbgLanguage_Beef) && (!thisVal.mType->IsBfObjectPtr()) && (thisVal.mType->IsPointer())) { // Beef structs expect 'this' as a valuetype, not a pointer @@ -952,13 +952,13 @@ DbgType* DbgExprEvaluator::ResolveTypeRef(BfTypeReference* typeRef) else { Fail(StrFormat("Illegal array size type"), arrayTypeRef->mParams[0]); - } + } return mDbgModule->GetSizedArrayType(elementType, count); } } } - + if (auto declTypeRef = BfNodeDynCastExact(typeRef)) { mResult = DbgTypedValue(); @@ -981,7 +981,7 @@ DbgType* DbgExprEvaluator::ResolveTypeRef(BfTypeReference* typeRef) typeIdx = atoi(endPtr + 1); mDebugTarget->mDbgModuleMap.TryGetValue(moduleIdx, &dbgModule); } - + if ((dbgModule != NULL) && (typeIdx >= 0) && (typeIdx < (int)dbgModule->mTypes.size())) return dbgModule->mTypes[typeIdx]; } @@ -989,7 +989,7 @@ DbgType* DbgExprEvaluator::ResolveTypeRef(BfTypeReference* typeRef) auto entry = mDbgModule->mTypeMap.Find(name.c_str(), GetLanguage()); if (entry != NULL) return FixType(entry->mValue); - + if (mExplicitThis) { bool isPtr = typeRef->IsA(); @@ -1005,7 +1005,7 @@ DbgType* DbgExprEvaluator::ResolveTypeRef(BfTypeReference* typeRef) checkType = checkType->mTypeParam; ResolveSubTypeRef(checkType, name); - } + } auto currentType = GetCurrentType(); if (currentType != NULL) @@ -1025,8 +1025,8 @@ DbgType* DbgExprEvaluator::ResolveTypeRef(BfTypeReference* typeRef) } DbgType* DbgExprEvaluator::ResolveTypeRef(BfAstNode* typeRef, BfAstNode** parentChildRef) -{ - StringT<128> name = typeRef->ToString(); +{ + StringT<128> name = typeRef->ToString(); if ((name.StartsWith("_T_")) && ((int)name.IndexOf('.') == -1)) { int endIdx = name.length(); @@ -1050,7 +1050,7 @@ DbgType* DbgExprEvaluator::ResolveTypeRef(BfAstNode* typeRef, BfAstNode** parent typeIdx = atoi(endPtr + 1); mDebugTarget->mDbgModuleMap.TryGetValue(moduleIdx, &dbgModule); } - + if ((dbgModule != NULL) && (typeIdx >= 0) && (typeIdx < (int)dbgModule->mTypes.size())) { if ((mExplicitThisExpr != NULL) && (parentChildRef != NULL)) @@ -1070,7 +1070,7 @@ DbgType* DbgExprEvaluator::ResolveTypeRef(BfAstNode* typeRef, BfAstNode** parent if ((name[i] == ':') && (name[i - 1] == ':')) { name[i] = '.'; - name.erase(name.begin() + i - 1); + name.erase(name.begin() + i - 1); i--; } }*/ @@ -1081,7 +1081,7 @@ DbgType* DbgExprEvaluator::ResolveTypeRef(BfAstNode* typeRef, BfAstNode** parent return entry->mValue; auto currentType = GetCurrentType(); if (currentType != NULL) - { + { GetNamespaceSearch(); for (auto usingNamespace : mNamespaceSearch) { @@ -1096,7 +1096,7 @@ DbgType* DbgExprEvaluator::ResolveTypeRef(BfAstNode* typeRef, BfAstNode** parent } DbgType* DbgExprEvaluator::ResolveTypeRef(const StringImpl& typeName) -{ +{ auto entry = mDbgModule->mTypeMap.Find(typeName.c_str(), GetLanguage()); if (entry != NULL) return entry->mValue; @@ -1121,12 +1121,12 @@ bool DbgExprEvaluator::TypeIsSubTypeOf(DbgType* srcType, DbgType* wantType, int* return false; if (srcType->Equals(wantType)) return true; - + if (srcType->mTypeCode == DbgType_TypeDef) return TypeIsSubTypeOf(srcType->mTypeParam, wantType); if (wantType->mTypeCode == DbgType_TypeDef) return TypeIsSubTypeOf(srcType, wantType->mTypeParam); - + srcType->PopulateType(); for (auto srcBaseType : srcType->mBaseTypes) { @@ -1142,7 +1142,7 @@ bool DbgExprEvaluator::TypeIsSubTypeOf(DbgType* srcType, DbgType* wantType, int* addr_target vtableAddr = 0; gDebugger->ReadMemory(*thisAddr, sizeof(addr_target), &vtableAddr); gDebugger->ReadMemory(vtableAddr + srcBaseType->mVTableOffset * sizeof(int32), sizeof(int32), &virtThisOffset); - + *thisOffset += virtThisOffset; } else if (thisOffset != NULL) @@ -1165,7 +1165,7 @@ DbgTypedValue DbgExprEvaluator::GetBeefTypeById(int typeId) mDebugTarget->mTargetBinary->ParseTypeData(); auto typeTypeEntry = mDebugTarget->mTargetBinary->FindType("System.Type", DbgLanguage_Beef); - if ((typeTypeEntry != NULL) && (typeTypeEntry->mValue != NULL)) + if ((typeTypeEntry != NULL) && (typeTypeEntry->mValue != NULL)) { auto typeType = typeTypeEntry->mValue; mDebugTarget->mTargetBinary->mBfTypeType = typeType; @@ -1178,13 +1178,13 @@ DbgTypedValue DbgExprEvaluator::GetBeefTypeById(int typeId) { auto stackFrame = GetStackFrame(); DbgAddrType addrType; - mDebugTarget->mTargetBinary->mBfTypesInfoAddr = member->mCompileUnit->mDbgModule->EvaluateLocation(NULL, member->mLocationData, member->mLocationLen, stackFrame, &addrType); + mDebugTarget->mTargetBinary->mBfTypesInfoAddr = member->mCompileUnit->mDbgModule->EvaluateLocation(NULL, member->mLocationData, member->mLocationLen, stackFrame, &addrType); } } - + if (mDebugTarget->mTargetBinary->mBfTypesInfoAddr <= 0) { - mDebugTarget->mTargetBinary->ParseSymbolData(); + mDebugTarget->mTargetBinary->ParseSymbolData(); auto entry = mDebugTarget->mTargetBinary->mSymbolNameMap.Find( #ifdef BF_DBG_64 "?sTypes@Type@System@bf@@2PEAPEAV123@A" @@ -1192,7 +1192,7 @@ DbgTypedValue DbgExprEvaluator::GetBeefTypeById(int typeId) "?sTypes@Type@System@bf@@2PAPAV123@A" #endif ); - + if (entry) mDebugTarget->mTargetBinary->mBfTypesInfoAddr = entry->mValue->mAddress; } @@ -1283,7 +1283,7 @@ void DbgExprEvaluator::BeefTypeToString(const DbgTypedValue& val, String& outStr _TypeId mTypeId; _TypeId mBoxedType; _TypeFlags mTypeFlags; - int32 mMemberDataOffset; + int32 mMemberDataOffset; _TypeCode mTypeCode; uint8 mAlign; }; @@ -1325,7 +1325,7 @@ void DbgExprEvaluator::BeefTypeToString(const DbgTypedValue& val, String& outStr #else int16 mPadding0; #endif - + addr_target mTypeClassVData; addr_target mName; addr_target mNamespace; @@ -1336,14 +1336,14 @@ void DbgExprEvaluator::BeefTypeToString(const DbgTypedValue& val, String& outStr _TypeId mUnderlyingType; _TypeId mOuterType; int32 mInheritanceId; - int32 mInheritanceCount; + int32 mInheritanceCount; uint8 mInterfaceSlot; uint8 mInterfaceCount; int16 mInterfaceMethodCount; int16 mMethodDataCount; int16 mPropertyDataCount; - int16 mFieldDataCount; + int16 mFieldDataCount; #ifdef BF_DBG_32 int16 mPadding1; @@ -1373,16 +1373,16 @@ void DbgExprEvaluator::BeefTypeToString(const DbgTypedValue& val, String& outStr int32 mElementSize; uint8 mRank; uint8 mElemensDataOffset; - }; + }; #pragma pack(pop) - + int typeIdSize = sizeof(_TypeId); int ptrSize = (int)sizeof(addr_target); int objectSize = mDebugTarget->mBfObjectSize; int typeSize = sizeof(_Type); int typeInstanceSize = objectSize + sizeof(_TypeInstance); - + auto addr = useVal.mSrcAddress; auto typeAddr = addr + objectSize; @@ -1495,7 +1495,7 @@ void DbgExprEvaluator::BeefTypeToString(const DbgTypedValue& val, String& outStr } else { - BfTypeCode typeCode = (BfTypeCode)mDebugger->ReadMemory(typeAddr + (int)offsetof(_Type, mTypeCode)); + BfTypeCode typeCode = (BfTypeCode)mDebugger->ReadMemory(typeAddr + (int)offsetof(_Type, mTypeCode)); if (typeCode == BfTypeCode_Pointer) { _TypeId elementType = mDebugger->ReadMemory<_TypeId>(typeAddr + offsetof(_PointerType, mElementType)); @@ -1531,7 +1531,7 @@ void DbgExprEvaluator::BeefTypeToString(const DbgTypedValue& val, String& outStr case BfTypeCode_Float: outStr += "float"; break; case BfTypeCode_Double: outStr += "double"; break; } - } + } } CPUStackFrame* DbgExprEvaluator::GetStackFrame() @@ -1577,10 +1577,10 @@ DbgTypedValue DbgExprEvaluator::GetRegister(const StringImpl& regName) if (mCallStackIdx < (int)mDebugger->mCallStack.size()) regForms = &mDebugger->mCallStack[mCallStackIdx]->mRegForms; } - DbgTypedValue result = mDebugger->GetRegister(regName, GetLanguage(), GetRegisters(), regForms); + DbgTypedValue result = mDebugger->GetRegister(regName, GetLanguage(), GetRegisters(), regForms); if ((result) && (mReferenceId != NULL)) { - int regNum = CPURegisters::GetCompositeRegister(result.mRegNum); + int regNum = CPURegisters::GetCompositeRegister(result.mRegNum); const char* regName = CPURegisters::GetRegisterName(regNum); if (regName != NULL) *mReferenceId = String("$") + regName; @@ -1602,11 +1602,11 @@ DbgSubprogram* DbgExprEvaluator::GetCurrentMethod() mDebugger->UpdateCallStackMethod(mCallStackIdx); if (mCallStackIdx >= (int)mDebugger->mCallStack.size()) return NULL; - auto callStack = mDebugger->mCallStack[mCallStackIdx]; + auto callStack = mDebugger->mCallStack[mCallStackIdx]; auto subProgram = callStack->mSubProgram; if (subProgram != NULL) subProgram->PopulateSubprogram(); - return subProgram; + return subProgram; } DbgType* DbgExprEvaluator::GetCurrentType() @@ -1720,7 +1720,7 @@ bool DbgExprEvaluator::CanCast(DbgTypedValue typedVal, DbgType* toType, BfCastFl } if ((fromType->IsPrimitiveType()) && (toType->IsPrimitiveType())) - { + { DbgTypeCode fromTypeCode = fromType->mTypeCode; DbgTypeCode toTypeCode = toType->mTypeCode; if ((fromTypeCode == toTypeCode)) @@ -1728,10 +1728,10 @@ bool DbgExprEvaluator::CanCast(DbgTypedValue typedVal, DbgType* toType, BfCastFl // Must be from a default int to do an implicit constant cast, not casted by user, ie: (ushort)123 if ((toType->IsInteger()) /*&& (typedVal.mValue != NULL) && (fromTypeCode == DbgType_i32)*/) - { + { // Allow constant ints to be implicitly downcasted if they fit if (typedVal.mIsLiteral) - { + { int64 srcVal = typedVal.GetInt64(); if (toType->IsSigned()) { @@ -1783,10 +1783,10 @@ bool DbgExprEvaluator::CanCast(DbgTypedValue typedVal, DbgType* toType, BfCastFl break; case DbgType_u16: switch (fromTypeCode) - { + { case DbgType_i8: return true; - case DbgType_u8: + case DbgType_u8: case DbgType_UChar: case DbgType_UChar16: return true; @@ -1910,14 +1910,14 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty { if (!typedVal) return typedVal; - + DbgType* fromType = typedVal.mType; fromType = fromType->RemoveModifiers(); toType = toType->RemoveModifiers(); fromType = fromType->GetPrimaryType(); toType = toType->GetPrimaryType(); - + if ((toType->IsBfObject()) && (fromType->IsPointer())) toType = toType->GetDbgModule()->GetPointerType(toType); @@ -1938,7 +1938,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty } } } - + if (fromType == toType) return typedVal; @@ -1947,7 +1947,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty { DbgTypedValue val; val.mPtr = typedVal.mPtr; - val.mType = toType; + val.mType = toType; return val; } @@ -1975,7 +1975,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty if (fromType->IsBfPayloadEnum()) { if (!allowCast) - { + { for (auto member : fromType->mMemberList) { if (member->mType->Equals(toType)) @@ -2006,7 +2006,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty { intptr valAddr; DbgType* valType; - DbgAddrType addrType = DbgAddrType_Value; + DbgAddrType addrType = DbgAddrType_Value; String findName = "$"; //BF_ASSERT(typedVal.mVariable != NULL); if (typedVal.mVariable != NULL) @@ -2014,8 +2014,8 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty findName += "$d"; if (mDebugTarget->GetValueByName(GetCurrentMethod(), findName, GetStackFrame(), &valAddr, &valType, &addrType)) { - return ReadTypedValue(srcNode, valType, valAddr, addrType); - } + return ReadTypedValue(srcNode, valType, valAddr, addrType); + } } // Optimized composite - probably stored in register @@ -2058,7 +2058,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty } } - if ((fromType->IsPointer()) && (fromType->mTypeParam->IsCompositeType()) && + if ((fromType->IsPointer()) && (fromType->mTypeParam->IsCompositeType()) && (toType->IsPointer()) && (toType->mTypeParam->IsCompositeType())) { auto fromInnerType = fromType->mTypeParam->RemoveModifiers(); @@ -2105,7 +2105,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty } } - + // IFace -> object|IFace if ((fromType->IsInterface()) || ((fromType->IsPointer()) && (fromType->mTypeParam->IsInterface()))) @@ -2134,13 +2134,13 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty val.mPtr = typedVal.GetPointer(); val.mType = toType; return val; - } + } } - + // Enum -> Int if ((((fromType->IsBfEnum()) || (fromType->IsEnum())) && (toType->IsInteger())) && ((explicitCast) || (fromType == curTypeInstance))) - { + { DbgTypedValue result = typedVal; result.mType = toType; return result; @@ -2150,14 +2150,14 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty if (((fromType->IsInteger()) && ((toType->IsBfEnum()) || (toType->IsEnum()))) && ((explicitCast) || (toType == curTypeInstance))) { - DbgTypedValue result = typedVal; + DbgTypedValue result = typedVal; result.mType = toType; return result; } // TypedPrimitive -> Primitive if ((fromType->IsTypedPrimitive()) && (toType->IsPrimitiveType())) - { + { DbgTypedValue fromValue = typedVal; fromValue.mType = fromType->GetBaseType(); return Cast(srcNode, fromValue, toType, explicitCast); @@ -2178,7 +2178,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty // Primitive -> TypedPrimitive if ((fromType->IsPrimitiveType()) && (toType->IsTypedPrimitive())) - { + { DbgTypedValue primTypedVal = Cast(srcNode, typedVal, toType->GetBaseType(), true); if (primTypedVal) { @@ -2186,10 +2186,10 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty return primTypedVal; } } - + if ((fromType->IsPrimitiveType()) && (toType->IsPrimitiveType())) - { + { DbgTypeCode fromTypeCode = fromType->mTypeCode; DbgTypeCode toTypeCode = toType->mTypeCode; @@ -2200,7 +2200,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty { int64 srcVal = typedVal.GetInt64(); /*if (toType->IsSigned()) - { + { int64 minVal = -(1LL << (8 * toType->mSize - 1)); int64 maxVal = (1LL << (8 * toType->mSize - 1)) - 1; if ((srcVal >= minVal) && (srcVal <= maxVal)) @@ -2212,7 +2212,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty explicitCast = true; } else - { + { int64 minVal = 0; int64 maxVal = (1LL << (8 * toType->mSize)) - 1; if ((srcVal >= minVal) && (srcVal <= maxVal)) @@ -2253,7 +2253,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty } } } - + DbgTypedValue result; result.mType = toType; if (((fromType->IsInteger()) || (fromType->IsChar())) && @@ -2265,11 +2265,11 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty } switch (toTypeCode) - { + { case DbgType_u8: case DbgType_UChar: switch (fromTypeCode) - { + { case DbgType_u8: case DbgType_UChar: return result; @@ -2293,7 +2293,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty case DbgType_u16: case DbgType_UChar16: switch (fromTypeCode) - { + { case DbgType_i8: case DbgType_SChar: return result; @@ -2323,11 +2323,11 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty case DbgType_UChar32: case DbgType_u32: switch (fromTypeCode) - { + { case DbgType_i8: - case DbgType_i16: + case DbgType_i16: case DbgType_SChar: - case DbgType_SChar16: + case DbgType_SChar16: return result; case DbgType_u8: case DbgType_u16: @@ -2378,7 +2378,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty case DbgType_Single: switch (fromTypeCode) { - case DbgType_i8: + case DbgType_i8: case DbgType_i16: case DbgType_i32: case DbgType_i64: @@ -2387,7 +2387,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty case DbgType_SChar32: result.mSingle = typedVal.GetInt64(); return result; - case DbgType_u8: + case DbgType_u8: case DbgType_u16: case DbgType_u32: case DbgType_u64: @@ -2400,7 +2400,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty break; case DbgType_Double: switch (fromTypeCode) - { + { case DbgType_i8: case DbgType_i16: case DbgType_i32: @@ -2416,7 +2416,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty case DbgType_u64: case DbgType_UChar: case DbgType_UChar16: - case DbgType_UChar32: + case DbgType_UChar32: result.mDouble = typedVal.GetInt64(); return result; case DbgType_Single: @@ -2445,7 +2445,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty } switch (toTypeCode) - { + { case DbgType_Single: switch (fromTypeCode) { @@ -2469,7 +2469,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty result.mSingle = (float)typedVal.mDouble; return result; } - break; + break; } } } @@ -2478,11 +2478,11 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty { DbgTypedValue realTypedVal = typedVal; realTypedVal.mType = fromType->mTypeParam; - return Cast(srcNode, realTypedVal, toType, explicitCast, silentFail); + return Cast(srcNode, realTypedVal, toType, explicitCast, silentFail); } - if (toType->mTypeCode == DbgType_TypeDef) - return Cast(srcNode, typedVal, toType->mTypeParam, explicitCast, silentFail); + if (toType->mTypeCode == DbgType_TypeDef) + return Cast(srcNode, typedVal, toType->mTypeParam, explicitCast, silentFail); if (!silentFail) { @@ -2498,17 +2498,17 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty bool DbgExprEvaluator::HasField(DbgType* curCheckType, const StringImpl& fieldName) { - curCheckType = curCheckType->RemoveModifiers(); - curCheckType = curCheckType->GetPrimaryType(); + curCheckType = curCheckType->RemoveModifiers(); + curCheckType = curCheckType->GetPrimaryType(); curCheckType->PopulateType(); for (auto checkMember : curCheckType->mMemberList) { if (checkMember->mName == NULL) - { + { auto checkResult = HasField(checkMember->mType, fieldName); - if (checkResult) - return checkResult; + if (checkResult) + return checkResult; } else if (checkMember->mName == fieldName) return true; @@ -2516,10 +2516,10 @@ bool DbgExprEvaluator::HasField(DbgType* curCheckType, const StringImpl& fieldNa for (auto baseTypeEntry : curCheckType->mBaseTypes) { - auto baseType = baseTypeEntry->mBaseType; + auto baseType = baseTypeEntry->mBaseType; auto result = HasField(baseType, fieldName); if (result) - return result; + return result; } //if (wantsStatic) @@ -2536,7 +2536,7 @@ bool DbgExprEvaluator::HasField(DbgType* curCheckType, const StringImpl& fieldNa } for (auto altType : curCheckType->mAlternates) - { + { auto result = HasField(altType, fieldName); if (result) return result; @@ -2547,7 +2547,7 @@ bool DbgExprEvaluator::HasField(DbgType* curCheckType, const StringImpl& fieldNa } DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValue target, DbgType* curCheckType, const StringImpl& fieldName, CPUStackFrame* stackFrame, bool allowImplicitThis) -{ +{ if (mStackSearch != NULL) { if (mStackSearch->mIdentifier == targetSrc) @@ -2566,8 +2566,8 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu wantsStatic = true; } - curCheckType = curCheckType->RemoveModifiers(); - curCheckType = curCheckType->GetPrimaryType(); + curCheckType = curCheckType->RemoveModifiers(); + curCheckType = curCheckType->GetPrimaryType(); curCheckType->PopulateType(); //BfLogDbgExpr("DoLookupField %s %s Priority=%d\n", fieldName.c_str(), curCheckType->mName, curCheckType->mPriority); @@ -2575,20 +2575,20 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu if ((curCheckType->mNeedsGlobalsPopulated) && ((curCheckType->IsNamespace()) || (curCheckType->IsRoot()))) { // Global variables don't show up in any type declaration like static fields do, so we need to populate here - mDbgModule->PopulateTypeGlobals(curCheckType); + mDbgModule->PopulateTypeGlobals(curCheckType); } /*auto checkMember = curCheckType->mMemberList.mHead; while (checkMember != NULL)*/ - String findFieldName = fieldName; + String findFieldName = fieldName; if ((language == DbgLanguage_Beef) && (flavor == DbgFlavor_MS) && (target.mHasNoValue)) { //if ((curCheckType->IsRoot()) || (curCheckType->IsNamespace())) //findFieldName.insert(0, "bf__"); } - - //for (auto checkMember : curCheckType->mMemberList) + + //for (auto checkMember : curCheckType->mMemberList) auto nextMember = curCheckType->mMemberList.mHead; while (nextMember != NULL) { @@ -2596,7 +2596,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu nextMember = checkMember->mNext; if (checkMember->mName == NULL) - { + { //TODO: Check inside anonymous type DbgTypedValue innerTarget; @@ -2609,11 +2609,11 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu innerTarget.mType = checkMember->mType; auto checkResult = LookupField(targetSrc, innerTarget, fieldName); - if (checkResult) - return checkResult; + if (checkResult) + return checkResult; } else if (checkMember->mName == findFieldName) - { + { //BfLogDbgExpr(" Got Match\n"); //TODO: @@ -2625,14 +2625,14 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu return DbgTypedValue(fieldInstance->mStaticValue, fieldInstance->mType); }*/ - //checkMember->mMemberOffset + //checkMember->mMemberOffset if (mReferenceId != NULL) { if (curCheckType->IsRoot()) *mReferenceId = fieldName; else if (curCheckType->IsEnum()) - *mReferenceId = curCheckType->ToString(); + *mReferenceId = curCheckType->ToString(); else *mReferenceId = curCheckType->ToString() + "." + fieldName; } @@ -2646,7 +2646,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu mDbgModule->PopulateTypeGlobals(curCheckType); return DoLookupField(targetSrc, target, curCheckType, fieldName, stackFrame, allowImplicitThis); } - + /*String memberName = curCheckType->ToString() + "::" + checkMember->mName; mDbgModule->ParseSymbolData(); auto entry = mDbgModule->mSymbolNameMap.Find(memberName.c_str()); @@ -2665,8 +2665,8 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu BF_ASSERT("Static field not found" == 0); }*/ } - else - { + else + { continue; //BF_FATAL("Unhandled"); @@ -2734,10 +2734,10 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu Fail("Static variable not found, may have be optimized out", targetSrc); //BfLogDbgExpr(" Static variable optimized out\n"); } - else + else { if ((allowImplicitThis) && (target.mPtr == 0)) - target = GetThis(); + target = GetThis(); if (!target) { @@ -2766,7 +2766,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu } if (checkMember->mBitSize != 0) - { + { int expectedShift = (checkMember->mType->mSize * 8) - checkMember->mBitSize; int shift = expectedShift - checkMember->mBitOffset; @@ -2808,11 +2808,11 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu methodNameEntry->mCompileUnitId = -1; } } - } + } } for (int pass = 0; pass < 2; pass++) - { + { for (auto method : curCheckType->mMethodList) { if (method->mName != NULL) @@ -2836,7 +2836,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu continue; } - DbgSubprogram*& subprogramRef = isGetter ? mPropGet : mPropSet; + DbgSubprogram*& subprogramRef = isGetter ? mPropGet : mPropSet; if ((subprogramRef == NULL) || ((!method->mHasThis) && (wantsStatic)) || @@ -2846,11 +2846,11 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu { target = GetThis(); } - + if (subprogramRef == NULL) subprogramRef = method; else if ((method->mVTableLoc != -1) || (subprogramRef->mVTableLoc == -1)) - subprogramRef = method; + subprogramRef = method; } } } @@ -2865,9 +2865,9 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu continue; if (method->mBlock.mLowPC == 0) - { + { if (!curCheckType->mHasGlobalsPopulated) - mDbgModule->PopulateTypeGlobals(curCheckType); + mDbgModule->PopulateTypeGlobals(curCheckType); for (auto methodNameEntry : curCheckType->mMethodNameList) { const char* methodName = methodNameEntry->mName; @@ -2902,8 +2902,8 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu } }*/ - - //curCheckType = curCheckType->GetBaseType(); + + //curCheckType = curCheckType->GetBaseType(); for (auto baseTypeEntry : curCheckType->mBaseTypes) { @@ -2919,7 +2919,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu if (ptrRef != NULL) { if (baseTypeEntry->mVTableOffset != -1) - { + { addr_target vtableAddr = mDebugger->ReadMemory(target.mPtr); int32 virtThisOffset = mDebugger->ReadMemory(vtableAddr + baseTypeEntry->mVTableOffset * sizeof(int32)); *ptrRef += virtThisOffset; @@ -2931,9 +2931,9 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu //BF_ASSERT(baseTypeEntry->mVTableOffset == -1); auto result = DoLookupField(targetSrc, baseTarget, baseType, fieldName, stackFrame, allowImplicitThis); if (result) - return result; + return result; } - + if (wantsStatic) { // Look for statics in anonymous inner classes @@ -2946,7 +2946,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu { if ((checkSubType->IsGlobalsContainer()) && (checkSubType->mPriority <= DbgTypePriority_Normal)) continue; - auto rawCheckSubType = checkSubType->RemoveModifiers(); + auto rawCheckSubType = checkSubType->RemoveModifiers(); auto result = DoLookupField(targetSrc, DbgTypedValue(), rawCheckSubType, fieldName, stackFrame, false); if (result) return result; @@ -2955,7 +2955,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu //Turn alternates back on! /*for (auto altType : curCheckType->mAlternates) - { + { auto result = DoLookupField(targetSrc, DbgTypedValue(), altType, fieldName, stackFrame, false); if (result) return result; @@ -2966,10 +2966,10 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu } DbgTypedValue DbgExprEvaluator::LookupField(BfAstNode* targetSrc, DbgTypedValue target, const StringImpl& fieldName) -{ +{ CPUStackFrame* stackFrame = GetStackFrame(); - - DbgType* curCheckType = NULL; + + DbgType* curCheckType = NULL; /*if (currentMethod != NULL) curCheckType = currentMethod->mParentType;*/ DbgType* curMethodType = curCheckType; @@ -2984,13 +2984,13 @@ DbgTypedValue DbgExprEvaluator::LookupField(BfAstNode* targetSrc, DbgTypedValue } else { - curCheckType = target.mType; + curCheckType = target.mType; } BF_ASSERT(curCheckType != NULL); } else if (target.mType != NULL) curCheckType = target.mType; - + if (curCheckType != NULL) { curCheckType = curCheckType->RemoveModifiers(); @@ -3005,9 +3005,9 @@ DbgTypedValue DbgExprEvaluator::LookupField(BfAstNode* targetSrc, DbgTypedValue if (currentMethod != NULL) { curCheckType = currentMethod->GetTargetType(); - allowImplicitThis = currentMethod->mHasThis; + allowImplicitThis = currentMethod->mHasThis; } - } + } //SetAndRestoreValue prevTypeInstance(curMethodType, curCheckType); @@ -3029,7 +3029,7 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(BfAstNode* targetSrc, DbgType* db if (addrType == DbgAddrType_Alias) { String findName = (const char*)valAddr; - + if (targetSrc == NULL) return DbgTypedValue(); @@ -3042,12 +3042,12 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(BfAstNode* targetSrc, DbgType* db int srcStart = bfParser->AllocChars(findName.length()); memcpy((char*)source->mSrc + srcStart, findName.c_str(), findName.length()); identifierNode->Init(srcStart, srcStart, srcStart + findName.length()); - + SetAndRestoreValue prevIgnoreErrors(mIgnoreErrors, true); auto result = LookupIdentifier(identifierNode); if (result) return result; - + // Allow lookup in calling method if we are inlined (for mixin references) auto currentMethod = GetCurrentMethod(); if ((currentMethod != NULL) && (currentMethod->mInlineeInfo != NULL)) @@ -3082,12 +3082,12 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(BfAstNode* targetSrc, DbgType* db } if (addrType == DbgAddrType_NoValue) - { + { mPassInstance->Fail(StrFormat("No value", valAddr)); return DbgTypedValue(); } else if (addrType == DbgAddrType_OptimizedOut) - { + { mPassInstance->Fail(StrFormat("Optimized out", valAddr)); return DbgTypedValue(); } @@ -3097,7 +3097,7 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(BfAstNode* targetSrc, DbgType* db while (true) { if (dbgType->mTypeCode == DbgType_Const) - { + { dbgType = mDbgModule->GetInnerTypeOrVoid(dbgType); } else if ((dbgType->mTypeCode == DbgType_TypeDef) || (dbgType->mTypeCode == DbgType_Volatile)) @@ -3115,7 +3115,7 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(BfAstNode* targetSrc, DbgType* db if (addrType == DbgAddrType_Register) { auto registers = GetRegisters(); - valAddr = registers->mIntRegsArray[valAddr]; + valAddr = registers->mIntRegsArray[valAddr]; } //valIsAddr = true; @@ -3129,27 +3129,27 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(BfAstNode* targetSrc, DbgType* db if (addrType == DbgAddrType_Register) { auto registers = GetRegisters(); - valAddr = registers->mIntRegsArray[valAddr]; + valAddr = registers->mIntRegsArray[valAddr]; } addrType = DbgAddrType_Target; } - dbgType = dbgType->mTypeParam; + dbgType = dbgType->mTypeParam; } else break; } dbgType = dbgType->GetPrimaryType(); - + if (dbgType->GetByteCount() == 0) - { + { DbgTypedValue result; result.mType = dbgType; return result; } if (dbgType->mTypeCode == DbgType_Bitfield) - { + { DbgType* underlyingType = dbgType->mTypeParam; DbgTypedValue result = ReadTypedValue(targetSrc, dbgType->mTypeParam, valAddr, addrType); result.mType = dbgType; @@ -3174,7 +3174,7 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(BfAstNode* targetSrc, DbgType* db bool valIsAddr = (addrType == DbgAddrType_Local) || (addrType == DbgAddrType_Target); DbgTypedValue result; - result.mType = origDwType; + result.mType = origDwType; if (addrType == DbgAddrType_Register) { @@ -3182,7 +3182,7 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(BfAstNode* targetSrc, DbgType* db auto registers = GetRegisters(); if (result.mRegNum < CPURegisters::kNumIntRegs) - result.mUInt64 = registers->mIntRegsArray[result.mRegNum]; + result.mUInt64 = registers->mIntRegsArray[result.mRegNum]; else if ((result.mRegNum >= CPUReg_XMMREG_FIRST) && (result.mRegNum <= CPUReg_XMMREG_LAST)) { auto dwType = origDwType->RemoveModifiers(); @@ -3213,11 +3213,11 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(BfAstNode* targetSrc, DbgType* db dbgType = dbgType->mTypeParam; switch (dbgType->mTypeCode) - { + { case DbgType_Void: break; - case DbgType_Bool: + case DbgType_Bool: case DbgType_i8: case DbgType_u8: case DbgType_SChar: @@ -3263,7 +3263,7 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(BfAstNode* targetSrc, DbgType* db case DbgType_Struct: case DbgType_Class: case DbgType_Union: - case DbgType_SizedArray: + case DbgType_SizedArray: if (((dbgType->IsTypedPrimitive()) || (local)) && (dbgType->GetByteCount() <= 8)) { mDebugger->ReadMemory(valAddr, dbgType->GetByteCount(), &result.mInt64, local); @@ -3278,7 +3278,7 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(BfAstNode* targetSrc, DbgType* db result.mSrcAddress = (addr_target)valAddr; } //result.mPtr = (addr_target)valAddr; - break; + break; //TODO: Why was it treated as a pointer //case DbgType_SizedArray: @@ -3289,10 +3289,10 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(BfAstNode* targetSrc, DbgType* db result.mPtr = valAddr; break; - case DbgType_Enum: + case DbgType_Enum: result = ReadTypedValue(targetSrc, dbgType->mTypeParam, valAddr, addrType); if (result) - result.mType = dbgType; + result.mType = dbgType; break; case DbgType_Subroutine: @@ -3307,12 +3307,12 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(BfAstNode* targetSrc, DbgType* db #ifdef BF_DBG_32 if ((symbolName.length() > 0) && (symbolName[0] == '_')) symbolName = symbolName.Substring(1); -#endif +#endif static String demangledName; demangledName = BfDemangler::Demangle(symbolName, dbgType->GetLanguage()); - DbgTypedValue result; - result.mCharPtr = demangledName.c_str(); + DbgTypedValue result; + result.mCharPtr = demangledName.c_str(); } else { @@ -3411,16 +3411,16 @@ DbgTypedValue DbgExprEvaluator::CheckEnumCreation(BfAstNode* targetSrc, DbgType* Fail("Address for enum cannot be inferred", targetSrc); return DbgTypedValue(); } - + enumType = enumType->RemoveModifiers(); enumType = enumType->GetPrimaryType(); - int caseNum = -1; + int caseNum = -1; DbgVariable* matchedMember = NULL; for (auto member : enumType->mMemberList) { if ((member->mName[0] == '_') && (member->mName[1] >= '0') && (member->mName[1] <= '9')) - { + { for (int i = 1; true; i++) { if (member->mName[i] == '_') @@ -3477,11 +3477,11 @@ void DbgExprEvaluator::AutocompleteCheckType(BfTypeReference* typeReference) else if (auto qualifiedTypeRef = BfNodeDynCast(typeReference)) { if (IsAutoCompleteNode(qualifiedTypeRef->mLeft)) - { + { AutocompleteCheckType(qualifiedTypeRef->mLeft); return; } - + auto dbgType = ResolveTypeRef(qualifiedTypeRef->mLeft); if (dbgType != NULL) { @@ -3499,7 +3499,7 @@ void DbgExprEvaluator::AutocompleteCheckType(BfTypeReference* typeReference) } AutocompleteAddMembers(dbgType, false, false, filter); } - } + } else if (auto elementedTypeRef = BfNodeDynCast(typeReference)) { AutocompleteCheckType(elementedTypeRef->mElementType); @@ -3580,22 +3580,22 @@ void DbgExprEvaluator::AutocompleteAddTopLevelTypes(const StringImpl& filter) } DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bool ignoreInitialError, bool* hadError) -{ +{ if (!mDebugger->mIsRunning) return DbgTypedValue(); - + auto qualifiedNameNode = BfNodeDynCast(identifierNode); if (qualifiedNameNode != NULL) { LookupQualifiedName(qualifiedNameNode, ignoreInitialError, hadError); - auto qualifiedResult = mResult; + auto qualifiedResult = mResult; mResult = DbgTypedValue(); return qualifiedResult; - } + } - String findName = identifierNode->ToString(); + String findName = identifierNode->ToString(); if ((findName.StartsWith('$')) && (findName != "$prim")) - { + { if (IsAutoCompleteNode(identifierNode)) { String filter = identifierNode->ToString(); @@ -3620,8 +3620,8 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo return GetString(mDebugger->mActiveThread->mName); else if (findName == "$TargetName") return GetString(GetFileName(mDebugTarget->mTargetPath)); - else if (findName == "LaunchName") - return GetString(GetFileName(mDebugTarget->mLaunchBinary->mFilePath)); + else if (findName == "LaunchName") + return GetString(GetFileName(mDebugTarget->mLaunchBinary->mFilePath)); else if (findName == "$TargetPath") return GetString(mDebugTarget->mTargetPath); else if (findName == "$ModuleName") @@ -3659,7 +3659,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo if (mExplicitThis) { if ((mExplicitThis.mSrcAddress == -1) && ((DbgVariable*)mExplicitThis.mVariable != NULL)) - { + { mResult = DbgTypedValue(); LookupSplatMember(mExplicitThis, findName); result = mResult; @@ -3668,11 +3668,11 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo else if (!result) { mExplicitThis.mType = mExplicitThis.mType->RemoveModifiers(); - result = LookupField(identifierNode, mExplicitThis, findName); + result = LookupField(identifierNode, mExplicitThis, findName); } if (result) - { + { if (mExplicitThisExpr != NULL) mDeferredInsertExplicitThisVector.push_back(NodeReplaceRecord(identifierNode, mCurChildRef)); return result; @@ -3681,14 +3681,14 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo CPUStackFrame* stackFrame = GetStackFrame(); auto language = GetLanguage(); - + intptr valAddr; DbgType* valType; - DbgAddrType addrType = DbgAddrType_None; + DbgAddrType addrType = DbgAddrType_None; if (IsAutoCompleteNode(identifierNode)) - { - String filter = identifierNode->ToString(); + { + String filter = identifierNode->ToString(); DbgType* dbgType = NULL; @@ -3702,19 +3702,19 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo else if (!thisVal) dbgType = currentMethod->GetTargetType(); } - + Array capturedNames; Array capturedTypes; mDebugTarget->mCapturedNamesPtr = &capturedNames; mDebugTarget->mCapturedTypesPtr = &capturedTypes; - { + { mDebugTarget->GetValueByName(GetCurrentMethod(), "*", stackFrame, &valAddr, &valType, &addrType); } mDebugTarget->mCapturedNamesPtr = NULL; mDebugTarget->mCapturedTypesPtr = NULL; auto language = GetLanguage(); BF_ASSERT(capturedTypes.size() == capturedNames.size()); - { + { //for (auto capturedName : capturedNames) for (int i = 0; i < (int)capturedNames.size(); i++) { @@ -3736,7 +3736,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo } if (dbgType != NULL) - { + { dbgType = dbgType->RemoveModifiers(); if (dbgType->IsPointerOrRef()) { @@ -3745,7 +3745,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo } if (dbgType->mIsDeclaration) dbgType = dbgType->GetPrimaryType(); - + bool wantsStatic = true; bool wantsNonStatic = currentMethod->mHasThis; // In Beef, we can only access statics by class name @@ -3761,7 +3761,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo if (currentMethod != NULL) { if (strstr(currentMethod->mName, "operator()") != NULL) - { + { if (mDebugTarget->GetValueByName(currentMethod, "this", stackFrame, &valAddr, &valType, &addrType)) { valType = valType->RemoveModifiers(); @@ -3769,7 +3769,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo valType = valType->mTypeParam; valType = valType->RemoveModifiers(); AutocompleteAddMembers(valType, true, true, filter, true); - } + } } } } @@ -3795,13 +3795,13 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo mAutoComplete->mInsertStartIdx = identifierNode->GetSrcStart(); mAutoComplete->mInsertEndIdx = identifierNode->GetSrcEnd(); - - AutocompleteAddTopLevelTypes(filter); + + AutocompleteAddTopLevelTypes(filter); } - + if (language == DbgLanguage_C) { - // For C++ lambdas, captured a "this" is named "__this", so allow lookups into that + // For C++ lambdas, captured a "this" is named "__this", so allow lookups into that auto currentMethod = GetCurrentMethod(); if (currentMethod != NULL) { @@ -3829,7 +3829,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo return GetThis(); if (findName == "_") { - if (mSubjectValue) + if (mSubjectValue) { if (mSubjectValue.mSrcAddress != 0) { @@ -3839,7 +3839,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo } return mSubjectValue; } - + if (!mSubjectExpr.IsEmpty()) { DwFormatInfo formatInfo; @@ -3857,7 +3857,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo } if (stackFrame != NULL) - { + { if (mDebugTarget->GetValueByName(GetCurrentMethod(), findName, stackFrame, &valAddr, &valType, &addrType)) { //BF_ASSERT(valType != NULL); @@ -3883,10 +3883,10 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo } } - bool isClosure = false; + bool isClosure = false; if (language == DbgLanguage_Beef) - { + { intptr valAddr; DbgType* valType; //bool valIsAddr = false; @@ -3929,23 +3929,23 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo } }*/ - if (!isClosure) + if (!isClosure) { // This uses an incorrect 'this' in the case of a closure result = LookupField(identifierNode, DbgTypedValue(), findName); if ((result) || (HasPropResult())) - return result; + return result; } - - result = GetRegister(findName); + + result = GetRegister(findName); if ((result) || (HasPropResult())) - { + { return result; } mDbgModule->ParseGlobalsData(); for (auto compileUnit : mDbgModule->mCompileUnits) - { + { if (mDbgCompileUnit == NULL) continue; if ((compileUnit->mLanguage != DbgLanguage_Unknown) && (compileUnit->mLanguage != mDbgCompileUnit->mLanguage)) @@ -3967,28 +3967,28 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo auto dbgType = currentMethod->mParentType; if (dbgType->IsPointerOrRef()) dbgType = dbgType->mTypeParam; - - auto curAlloc = &dbgType->mCompileUnit->mDbgModule->mAlloc; + + auto curAlloc = &dbgType->mCompileUnit->mDbgModule->mAlloc; result = DoLookupField(identifierNode, DbgTypedValue(), dbgType, findName, NULL, false); if ((result) || (HasPropResult())) return result; - + GetNamespaceSearch(); for (auto usingNamespace : mNamespaceSearch) - { + { usingNamespace = usingNamespace->GetPrimaryType(); result = DoLookupField(identifierNode, DbgTypedValue(), usingNamespace, findName, NULL, false); if ((result) || (HasPropResult())) return result; for (auto checkNamespace : usingNamespace->mAlternates) - { + { result = DoLookupField(identifierNode, DbgTypedValue(), checkNamespace, findName, NULL, false); - if ((result) || (HasPropResult())) - return result; + if ((result) || (HasPropResult())) + return result; } - } + } } return DbgTypedValue(); @@ -3997,7 +3997,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupIdentifier(BfAstNode* identifierNode, bo DbgTypedValue DbgExprEvaluator::LookupIdentifier(BfAstNode* identifierNode, bool ignoreInitialError, bool* hadError) { if ((mStackSearch != NULL) && (mStackSearch->mIdentifier == NULL)) - { + { mStackSearch->mIdentifier = identifierNode; mStackSearch->mStartingStackIdx = mCallStackIdx; @@ -4005,7 +4005,7 @@ DbgTypedValue DbgExprEvaluator::LookupIdentifier(BfAstNode* identifierNode, bool StringT<256> findStr; for (int i = 0; i < mStackSearch->mSearchStr.mLength; i++) - { + { char c = mStackSearch->mSearchStr[i]; if (c == '^') @@ -4032,7 +4032,7 @@ DbgTypedValue DbgExprEvaluator::LookupIdentifier(BfAstNode* identifierNode, bool { mDebugger->UpdateCallStackMethod(mCallStackIdx); if (stackFrame->mSubProgram != NULL) - { + { int strLen = strlen(stackFrame->mSubProgram->mName); if (strLen >= findStr.mLength) { @@ -4086,11 +4086,11 @@ void DbgExprEvaluator::Visit(BfAssignmentExpression* assignExpr) auto binaryOp = BfAssignOpToBinaryOp(assignExpr->mOp); - //auto ptr = mModule->GetOrCreateVarAddr(assignExpr->mLeft); + //auto ptr = mModule->GetOrCreateVarAddr(assignExpr->mLeft); VisitChild(assignExpr->mLeft); if ((!mResult) && (!HasPropResult())) return; - + if (HasPropResult()) { if (mPropSet == NULL) @@ -4103,7 +4103,7 @@ void DbgExprEvaluator::Visit(BfAssignmentExpression* assignExpr) auto propSet = mPropSet; auto propTarget = mPropTarget; auto indexerValues = mIndexerValues; - + auto indexerExprValues = mIndexerExprValues; mPropGet = NULL; mPropSet = NULL; @@ -4125,15 +4125,15 @@ void DbgExprEvaluator::Visit(BfAssignmentExpression* assignExpr) PerformBinaryOperation(assignExpr->mLeft, assignExpr->mRight, binaryOp, assignExpr->mOpToken, true); if (!mResult) return; - convVal = mResult; + convVal = mResult; } else { - convVal = CreateValueFromExpression(assignExpr->mRight, valueParam->mType); + convVal = CreateValueFromExpression(assignExpr->mRight, valueParam->mType); } if (!convVal) return; - + // SizedArray argPushQueue; // if (propSet->mHasThis) @@ -4142,12 +4142,12 @@ void DbgExprEvaluator::Visit(BfAssignmentExpression* assignExpr) // argPushQueue.push_back(indexer); // argPushQueue.push_back(convVal); // if (propSet->mParams.Size() == argPushQueue.size()) -// { +// { // mResult = CreateCall(propSet, argPushQueue, false); -// +// // } - indexerExprValues.push_back(assignExpr->mRight); + indexerExprValues.push_back(assignExpr->mRight); indexerValues.push_back(convVal); mResult = CreateCall(propSrc, propTarget, propSet, false, indexerExprValues, indexerValues); @@ -4155,13 +4155,13 @@ void DbgExprEvaluator::Visit(BfAssignmentExpression* assignExpr) } GetResult(); - auto ptr = mResult; + auto ptr = mResult; mResult = DbgTypedValue(); - + if (binaryOp != NULL) { PerformBinaryOperation(assignExpr->mLeft, assignExpr->mRight, binaryOp, assignExpr->mOpToken, true); - } + } else { SetAndRestoreValue prevReceiveValue(mReceivingValue, &ptr); @@ -4178,7 +4178,7 @@ void DbgExprEvaluator::Visit(BfAssignmentExpression* assignExpr) } if (!mResult) return; - + if ((ptr.mType->mTypeCode == DbgType_Ref) || (ptr.mType->mTypeCode == DbgType_RValueReference)) ptr.mType = ptr.mType->mTypeParam; @@ -4197,14 +4197,14 @@ void DbgExprEvaluator::Visit(BfAssignmentExpression* assignExpr) mResult = Cast(assignExpr->mRight, mResult, ptr.mType, true); if (!mResult) return; - + if ((mExpressionFlags & DwEvalExpressionFlag_AllowSideEffects) == 0) - { + { mBlockedSideEffects = true; return; } - StoreValue(ptr, mResult, assignExpr->mLeft); + StoreValue(ptr, mResult, assignExpr->mLeft); } bool DbgExprEvaluator::StoreValue(DbgTypedValue& ptr, DbgTypedValue& value, BfAstNode* refNode) @@ -4272,7 +4272,7 @@ bool DbgExprEvaluator::StoreValue(DbgTypedValue& ptr, BfExpression* expr) return true; // Already written if (!result) return false; - + return StoreValue(ptr, result, expr);; } @@ -4301,22 +4301,22 @@ DbgTypedValue DbgExprEvaluator::GetResult() { if (mPropGet == NULL) { - Fail("Property has no getter", mPropSrc); + Fail("Property has no getter", mPropSrc); } else { // SizedArray argPushQueue; // auto curParam = mPropGet->mParams.mHead; // if (mPropGet->mHasThis) -// { +// { // argPushQueue.push_back(mPropTarget); // if (curParam != NULL) // curParam = curParam->mNext; // } // bool failed = false; -// for (int indexerIdx = 0; indexerIdx < (int)mIndexerValues.size(); indexerIdx++) +// for (int indexerIdx = 0; indexerIdx < (int)mIndexerValues.size(); indexerIdx++) // { -// auto val = mIndexerValues[indexerIdx]; +// auto val = mIndexerValues[indexerIdx]; // if (curParam != NULL) // { // val = Cast(mPropSrc, val, curParam->mType); @@ -4327,7 +4327,7 @@ DbgTypedValue DbgExprEvaluator::GetResult() // } // } // argPushQueue.push_back(val); -// +// // if (curParam != NULL) // curParam = curParam->mNext; // } @@ -4342,7 +4342,7 @@ DbgTypedValue DbgExprEvaluator::GetResult() // Fail("Indexer parameter count mismatch", mPropSrc); // } // } - + SetAndRestoreValue prevFlags(mExpressionFlags); if ((mExpressionFlags & DwEvalExpressionFlag_AllowPropertyEval) != 0) mExpressionFlags = (DwEvalExpressionFlags)(mExpressionFlags | DwEvalExpressionFlag_AllowCalls); @@ -4430,7 +4430,7 @@ void DbgExprEvaluator::AutocompleteAddMembers(DbgType* dbgType, bool wantsStatic // Don't get primary type for namespace, causes mAlternates infinite loop if (!dbgType->IsNamespace()) dbgType = dbgType->GetPrimaryType(); - + // false/false means just add subtypes if ((wantsStatic) || (!wantsNonStatic)) { @@ -4439,7 +4439,7 @@ void DbgExprEvaluator::AutocompleteAddMembers(DbgType* dbgType, bool wantsStatic { if (subType->mLanguage != language) { - // Ignore + // Ignore } else if (subType->mTypeName == NULL) { @@ -4473,7 +4473,7 @@ void DbgExprEvaluator::AutocompleteAddMembers(DbgType* dbgType, bool wantsStatic if (subType->IsBfObject()) entry->mEntryType = "class"; else if (subType->IsNamespace()) - entry->mEntryType = "namespace"; + entry->mEntryType = "namespace"; else entry->mEntryType = "valuetype"; } @@ -4508,7 +4508,7 @@ void DbgExprEvaluator::AutocompleteAddMembers(DbgType* dbgType, bool wantsStatic return; for (auto member : dbgType->mMemberList) - { + { if (((member->mIsStatic) && (wantsStatic)) || ((!member->mIsStatic) && (wantsNonStatic))) { @@ -4517,7 +4517,7 @@ void DbgExprEvaluator::AutocompleteAddMembers(DbgType* dbgType, bool wantsStatic { if (member->mName[0] == '?') continue; - + mAutoComplete->AddEntry(AutoCompleteEntry(GetTypeName(member->mType), name), filter); if ((isCapture) && (strcmp(member->mName, "__this") == 0)) @@ -4554,12 +4554,12 @@ void DbgExprEvaluator::AutocompleteAddMembers(DbgType* dbgType, bool wantsStatic } for (auto method : dbgType->mMethodList) - { + { if (((!method->mHasThis) && (wantsStatic)) || ((method->mHasThis) && (wantsNonStatic))) - { + { if ((method->mName != NULL) && (strcmp(method->mName, "this") != 0)) - { + { mDbgModule->FindTemplateStr(method->mName, method->mTemplateNameIdx); if (method->mTemplateNameIdx == -1) { @@ -4573,7 +4573,7 @@ void DbgExprEvaluator::AutocompleteAddMembers(DbgType* dbgType, bool wantsStatic { BF_ASSERT(!dbgType->mMethodList.IsEmpty()); }*/ - + /* for (auto methodNameEntry : dbgType->mMethodNameList) { @@ -4584,7 +4584,7 @@ void DbgExprEvaluator::AutocompleteAddMembers(DbgType* dbgType, bool wantsStatic for (auto baseTypeEntry : dbgType->mBaseTypes) { AutocompleteAddMembers(baseTypeEntry->mBaseType, wantsStatic, wantsNonStatic, filter); - } + } } void DbgExprEvaluator::AutocompleteCheckMemberReference(BfAstNode* target, BfAstNode* dotToken, BfAstNode* memberName) @@ -4699,12 +4699,12 @@ void DbgExprEvaluator::Visit(BfMemberReferenceExpression* memberRefExpr) }*/ auto flavor = GetFlavor(); - + String findName; BfAstNode* nameRefNode = memberRefExpr->mMemberName; if (auto attrIdentifierExpr = BfNodeDynCast(memberRefExpr->mMemberName)) { - nameRefNode = attrIdentifierExpr->mIdentifier; + nameRefNode = attrIdentifierExpr->mIdentifier; if (nameRefNode != NULL) findName = attrIdentifierExpr->mIdentifier->ToString(); } @@ -4715,7 +4715,7 @@ void DbgExprEvaluator::Visit(BfMemberReferenceExpression* memberRefExpr) // { - SetAndRestoreValue prevIgnoreError(mIgnoreErrors, true); + SetAndRestoreValue prevIgnoreError(mIgnoreErrors, true); mResult.mType = ResolveTypeRef(memberRefExpr); if (mResult.mType != NULL) { @@ -4735,7 +4735,7 @@ void DbgExprEvaluator::Visit(BfMemberReferenceExpression* memberRefExpr) if (expectingType != NULL) { DbgTypedValue expectingVal; - expectingVal.mType = expectingType; + expectingVal.mType = expectingType; mResult = LookupField(memberRefExpr->mMemberName, expectingVal, findName); if ((mResult) || (HasPropResult())) return; @@ -4748,8 +4748,8 @@ void DbgExprEvaluator::Visit(BfMemberReferenceExpression* memberRefExpr) thisValue.mType = mExpectingType; else thisValue.mType = ResolveTypeRef(memberRefExpr->mTarget, (BfAstNode**)&(memberRefExpr->mTarget)); - if (thisValue.mType != NULL) - thisValue.mHasNoValue = true; + if (thisValue.mType != NULL) + thisValue.mHasNoValue = true; } if (thisValue.mType == NULL) @@ -4778,7 +4778,7 @@ void DbgExprEvaluator::Visit(BfMemberReferenceExpression* memberRefExpr) // Look up static field thisValue.mType = ResolveTypeRef(typeRef); }*/ - + if (thisValue.mSrcAddress == -1) { LookupSplatMember(memberRefExpr->mTarget, memberRefExpr, thisValue, findName); @@ -4788,7 +4788,7 @@ void DbgExprEvaluator::Visit(BfMemberReferenceExpression* memberRefExpr) /*if (mResult) { if (mReferenceId != NULL) - *mReferenceId = thisValue.mType->ToString() + "." + findName; + *mReferenceId = thisValue.mType->ToString() + "." + findName; }*/ if ((!mResult) && (!HasPropResult())) @@ -4805,14 +4805,14 @@ void DbgExprEvaluator::Visit(BfMemberReferenceExpression* memberRefExpr) if (thisValue.mHasNoValue) { for (auto altDwType : thisValue.mType->mAlternates) - { + { auto altThisValue = thisValue; altThisValue.mType = altDwType; mResult = LookupField(memberRefExpr->mMemberName, altThisValue, findName); if (mResult) return; } - } + } Fail("Unable to find member", memberRefExpr->mMemberName); } @@ -4828,7 +4828,7 @@ DbgTypedValue DbgExprEvaluator::RemoveRef(DbgTypedValue typedValue) } void DbgExprEvaluator::Visit(BfIndexerExpression* indexerExpr) -{ +{ VisitChild(indexerExpr->mTarget); GetResult(); if (!mResult) @@ -4849,7 +4849,7 @@ void DbgExprEvaluator::Visit(BfIndexerExpression* indexerExpr) if (!mResult) indexerFailed = true; indexerValues.push_back(mResult); - mResult = DbgTypedValue(); + mResult = DbgTypedValue(); } if (indexerFailed) @@ -4870,12 +4870,12 @@ void DbgExprEvaluator::Visit(BfIndexerExpression* indexerExpr) isBfArrayIndex = true; } } - + if (!isBfArrayIndex) { mIndexerExprValues = indexerExprValues; mIndexerValues = indexerValues; - mResult = LookupField(indexerExpr->mTarget, collection, ""); + mResult = LookupField(indexerExpr->mTarget, collection, ""); if (HasPropResult()) { // Only use this if we actually have the method. Otherwise fall through so we can try a debug visualizer or something @@ -4896,14 +4896,14 @@ void DbgExprEvaluator::Visit(BfIndexerExpression* indexerExpr) Fail("Expected single index", indexerExpr->mOpenBracket); return; } - DbgTypedValue indexArgument = indexerValues[0]; + DbgTypedValue indexArgument = indexerValues[0]; indexArgument.mType = indexArgument.mType->RemoveModifiers(); if (!indexArgument.mType->IsInteger()) { mResult = DbgTypedValue(); Fail("Expected integer index", indexerExpr->mArguments[0]); return; - } + } if (mReferenceId != NULL) *mReferenceId += "[]"; @@ -4971,11 +4971,11 @@ void DbgExprEvaluator::Visit(BfIndexerExpression* indexerExpr) } } } - + addr_target target = collection.mPtr; if (collection.mType->mTypeCode == DbgType_SizedArray) target = collection.mSrcAddress; - + if ((!collection.mType->IsPointer()) && (collection.mType->mTypeCode != DbgType_SizedArray)) { mResult = DbgTypedValue(); @@ -4988,8 +4988,8 @@ void DbgExprEvaluator::Visit(BfIndexerExpression* indexerExpr) { int innerSize = collection.mType->mTypeParam->GetStride(); int len = 0; - if (innerSize > 0) - len = collection.mType->GetStride() / innerSize; + if (innerSize > 0) + len = collection.mType->GetStride() / innerSize; int idx = (int)indexArgument.GetInt64(); if ((idx < 0) || (idx >= len)) { @@ -5019,7 +5019,7 @@ void DbgExprEvaluator::Visit(BfThisExpression* thisExpr) if (mExplicitThisExpr != NULL) mDeferredInsertExplicitThisVector.push_back(NodeReplaceRecord(thisExpr, mCurChildRef)); mResult = mExplicitThis; - + /*if (mReferenceId != NULL) { auto checkType = mExplicitThis.mType; @@ -5043,7 +5043,7 @@ void DbgExprEvaluator::Visit(BfThisExpression* thisExpr) } void DbgExprEvaluator::Visit(BfIdentifierNode* identifierNode) -{ +{ //BfLogDbgExpr("Visit BfIdentifierNode %s\n", identifierNode->ToString().c_str()); mResult = LookupIdentifier(identifierNode, false, NULL); @@ -5055,7 +5055,7 @@ void DbgExprEvaluator::Visit(BfIdentifierNode* identifierNode) } if ((mResult) || (HasPropResult())) - return; + return; { SetAndRestoreValue prevIgnoreError(mIgnoreErrors, true); @@ -5114,7 +5114,7 @@ void DbgExprEvaluator::LookupSplatMember(const DbgTypedValue& target, const Stri } } }*/ - + bool found = false; while (checkType != NULL) { @@ -5177,13 +5177,13 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku SplatLookupEntry* splatLookupEntry = NULL; if (lookupNode != NULL) - { + { if (mSplatLookupMap.TryAdd(lookupNode, NULL, &splatLookupEntry)) { // } else if (forceName == NULL) - { + { if (outFindName != NULL) *outFindName = splatLookupEntry->mFindName; if (outIsConst != NULL) @@ -5241,18 +5241,18 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku if (forceName != NULL) findName = *forceName; - + CPUStackFrame* stackFrame = GetStackFrame(); intptr valAddr; DbgType* valType = NULL; DbgAddrType addrType = DbgAddrType_Value; - + bool foundWantType = true; DbgType* wantType = target.mType; auto checkType = target.mType; checkType = checkType->RemoveModifiers(); bool valWasConst = false; - + bool foundParent = false; if (target.mSrcAddress == -1) { @@ -5270,20 +5270,20 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku { foundParent = true; findName = parentFindName; - valType = mResult.mType; + valType = mResult.mType; valWasConst = parentIsConst; } } } - + if (!foundParent) - { + { if (!mDebugTarget->GetValueByName(curMethod, findName, stackFrame, &valAddr, &valType, &addrType)) return; if (addrType == DbgAddrType_Alias) { - findName = (const char*)valAddr; + findName = (const char*)valAddr; if (!mDebugTarget->GetValueByName(curMethod, findName, stackFrame, &valAddr, &valType, &addrType)) { @@ -5297,18 +5297,18 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku return; } - } - + } + if (addrType == DbgAddrType_LocalSplat) { DbgVariable* dbgVariable = (DbgVariable*)valAddr; // Use real name, in case of aliases findName = dbgVariable->mName; - } + } } if ((wasCast) && (valType != NULL)) - { + { checkType = valType->RemoveModifiers(); foundWantType = false; @@ -5342,7 +5342,7 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku if (member->mName == fieldName) { wasUnion = checkType->IsBfUnion(); - memberType = member->mType; + memberType = member->mType; found = true; break; } @@ -5364,7 +5364,7 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku findName += "$u"; else findName += "$m$" + fieldName; - + if (outFindName != NULL) *outFindName = findName; if (outIsConst != NULL) @@ -5381,14 +5381,14 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku /*if ((valType->IsConst()) && (!memberType->IsConst())) { // Set readonly if the original value was const - memberType = mDbgModule->GetConstType(valType); + memberType = mDbgModule->GetConstType(valType); }*/ - mResult = ReadTypedValue(targetNode, memberType, valAddr, addrType); + mResult = ReadTypedValue(targetNode, memberType, valAddr, addrType); if (wantConst) { // Set readonly if the original value was const mResult.mIsReadOnly = true; - } + } } } else @@ -5412,7 +5412,7 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku //BF_ASSERT((target.mVariable != NULL) || (target.mType->GetByteCount() == 0)); mResult = target; mResult.mType = memberType; - } + } } if (splatLookupEntry != NULL) @@ -5427,10 +5427,10 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku void DbgExprEvaluator::LookupQualifiedName(BfQualifiedNameNode* nameNode, bool ignoreInitialError, bool* hadError) { String fieldName = nameNode->mRight->ToString(); - + mResult = LookupIdentifier(nameNode->mLeft, ignoreInitialError, hadError); mResult = GetResult(); - + if (!mResult) { if (!ignoreInitialError) @@ -5451,7 +5451,7 @@ void DbgExprEvaluator::LookupQualifiedName(BfQualifiedNameNode* nameNode, bool i { auto target = mResult; mResult = DbgTypedValue(); - LookupSplatMember(nameNode->mLeft, nameNode, target, fieldName); + LookupSplatMember(nameNode->mLeft, nameNode, target, fieldName); } else { @@ -5465,7 +5465,7 @@ void DbgExprEvaluator::LookupQualifiedName(BfQualifiedNameNode* nameNode, bool i } } if ((mResult) || (mPropSrc != NULL)) - return; + return; if (hadError != NULL) *hadError = true; @@ -5480,7 +5480,7 @@ DbgType* DbgExprEvaluator::FindSubtype(DbgType* type, const StringImpl& name) return subType; } for (auto baseType : type->mBaseTypes) - { + { auto subType = FindSubtype(baseType->mBaseType->GetPrimaryType(), name); if (subType != NULL) return subType; @@ -5575,7 +5575,7 @@ bool DbgExprEvaluator::EnsureRunning(BfAstNode* astNode) } void DbgExprEvaluator::Visit(BfQualifiedNameNode* nameNode) -{ +{ AutocompleteCheckMemberReference(nameNode->mLeft, nameNode->mDot, nameNode->mRight); bool hadError = false; @@ -5599,7 +5599,7 @@ void DbgExprEvaluator::Visit(BfDefaultExpression* defaultExpr) } void DbgExprEvaluator::Visit(BfLiteralExpression* literalExpr) -{ +{ mIsComplexExpression = true; mResult.mIsLiteral = true; @@ -5608,17 +5608,17 @@ void DbgExprEvaluator::Visit(BfLiteralExpression* literalExpr) switch (literalExpr->mValue.mTypeCode) { case BfTypeCode_NullPtr: - { + { mResult.mPtr = 0; mResult.mType = mDbgModule->GetPrimitiveType(DbgType_Null, GetLanguage()); } break; - case BfTypeCode_CharPtr: - mResult = GetString(*literalExpr->mValue.mString); - break; + case BfTypeCode_CharPtr: + mResult = GetString(*literalExpr->mValue.mString); + break; case BfTypeCode_Boolean: mResult.mType = mDbgModule->GetPrimitiveType(DbgType_Bool, GetLanguage()); - mResult.mBool = literalExpr->mValue.mBool; + mResult.mBool = literalExpr->mValue.mBool; break; case BfTypeCode_Char8: mResult.mType = mDbgModule->GetPrimitiveType((language == DbgLanguage_Beef) ? DbgType_UChar : DbgType_SChar, language); @@ -5722,11 +5722,11 @@ void DbgExprEvaluator::Visit(BfCastExpression* castExpr) mResult = CreateValueFromExpression(castExpr->mExpression); if (!mResult) return; - mResult = Cast(castExpr, mResult, resolvedType, true); + mResult = Cast(castExpr, mResult, resolvedType, true); } // We pass by reference to support "RAW" debug expression simplification -DbgTypedValue DbgExprEvaluator::CreateValueFromExpression(ASTREF(BfExpression*)& expr, DbgType* castToType, DbgEvalExprFlags flags) +DbgTypedValue DbgExprEvaluator::CreateValueFromExpression(ASTREF(BfExpression*)& expr, DbgType* castToType, DbgEvalExprFlags flags) { // { @@ -5763,18 +5763,18 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress { DbgTypedValue leftValue; if (leftExpression != NULL) - leftValue = CreateValueFromExpression(leftExpression, mExpectingType, DbgEvalExprFlags_NoCast); + leftValue = CreateValueFromExpression(leftExpression, mExpectingType, DbgEvalExprFlags_NoCast); DbgTypedValue rightValue; if (rightExpression == NULL) - { + { return; - } + } if (!leftValue) - { + { VisitChild(rightExpression); return; } - + leftValue.mType = leftValue.mType->RemoveModifiers(); /*if (leftValue.mType->IsRef()) @@ -5790,7 +5790,7 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress return; } - auto boolType = leftValue.mType; + auto boolType = leftValue.mType; if (isAnd) { @@ -5799,14 +5799,14 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress mResult = leftValue; return; } - + rightValue = CreateValueFromExpression(rightExpression); - if (rightValue) + if (rightValue) rightValue = Cast(rightExpression, rightValue, boolType); mResult = rightValue; } else - { + { if (leftValue.mBool) { mResult = leftValue; @@ -5814,29 +5814,29 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress } rightValue = CreateValueFromExpression(rightExpression); - if (rightValue) + if (rightValue) rightValue = Cast(rightExpression, rightValue, boolType); mResult = rightValue; } return; } - + if ((binaryOp == BfBinaryOp_NullCoalesce) && ((leftValue.mType->IsPointer()) || (leftValue.mType->IsBfObject()))) - { + { if (leftValue.mPtr != 0) { mResult = leftValue; return; } - + CreateValueFromExpression(rightExpression, leftValue.mType); return; } - rightValue = CreateValueFromExpression(rightExpression, mExpectingType, DbgEvalExprFlags_NoCast); + rightValue = CreateValueFromExpression(rightExpression, mExpectingType, DbgEvalExprFlags_NoCast); if ((!leftValue) || (!rightValue)) return; - + rightValue.mType = rightValue.mType->RemoveModifiers(); if (leftValue.mType->IsTypedPrimitive()) @@ -5860,7 +5860,7 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress rightCompareSize += 0x100; if ((rightValue.mIsLiteral) && (rightValue.mType->IsPointer())) rightCompareSize += 0x200; - + /*if ((leftValue.mType->IsTypedPrimitive()) && (rightValue.mType->IsTypedPrimitive())) { int leftInheritDepth = leftValue.mType->ToTypeInstance()->mInheritDepth; @@ -5873,7 +5873,7 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress } }*/ - auto resultType = leftValue.mType; + auto resultType = leftValue.mType; if (!forceLeftType) { if ((resultType->IsNull()) || @@ -5896,7 +5896,7 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress DbgTypedValue* otherTypedValue; DbgType* otherType; BfAstNode* resultTypeSrc; - BfAstNode* otherTypeSrc; + BfAstNode* otherTypeSrc; if (resultType == leftValue.mType) { @@ -5906,7 +5906,7 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress otherTypeSrc = rightExpression; otherType = otherTypedValue->mType; } - else + else { resultTypedValue = &rightValue; resultTypeSrc = rightExpression; @@ -5914,9 +5914,9 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress otherTypeSrc = leftExpression; otherType = otherTypedValue->mType; } - + if ((resultTypedValue->mIsLiteral) && (resultType->IsPointer())) - { + { // If we're comparing against a string literal like 'str == "Hey!"', handle that if (BfBinOpEqualityCheck(binaryOp)) { @@ -5966,9 +5966,9 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress } } } - + Fail("Cannot perform operation with a literal value", resultTypeSrc); - return; + return; } DbgTypedValue convLeftValue; @@ -5989,17 +5989,17 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress /*if (!mModule->IsInSpecializedGeneric()) { //CS0472: The result of the expression is always 'true' since a value of type 'int' is never equal to 'null' of type '' - mModule->mCompiler->mPassInstance->Warn(BfWarning_CS0472_ValueTypeNullCompare, - StrFormat("The result of the expression is always '%s' since a value of type '%s' can never be null", + mModule->mCompiler->mPassInstance->Warn(BfWarning_CS0472_ValueTypeNullCompare, + StrFormat("The result of the expression is always '%s' since a value of type '%s' can never be null", isEquality ? "false" : "true", mModule->TypeToString(resultType).c_str()), otherTypeSrc); }*/ // Valuetypes never equal null auto boolType = mDbgModule->GetPrimitiveType(DbgType_Bool, GetLanguage()); mResult.mType = boolType; - mResult.mBool = !isEquality; + mResult.mBool = !isEquality; return; - } + } } //TODO: Use operator methods? @@ -6039,10 +6039,10 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress } if (methodMatcher.mBestMethodDef != NULL) { - SetElementType(opToken, BfSourceElementType_Method); + SetElementType(opToken, BfSourceElementType_Method); mResult = CreateCall(&methodMatcher, DbgTypedValue()); - if ((invertResult) && (mResult.mType == mModule->GetPrimitiveType(BfTypeCode_Boolean))) - mResult.mValue = mModule->mIRBuilder->CreateNot(mResult.mValue); + if ((invertResult) && (mResult.mType == mModule->GetPrimitiveType(BfTypeCode_Boolean))) + mResult.mValue = mModule->mIRBuilder->CreateNot(mResult.mValue); return; } }*/ @@ -6054,13 +6054,13 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress { if (!resultType->Equals(otherType)) { - Fail(StrFormat("Operands must be the same type, '%s' doesn't match '%s'", + Fail(StrFormat("Operands must be the same type, '%s' doesn't match '%s'", leftValue.mType->ToString().c_str(), rightValue.mType->ToString().c_str()), opToken); return; } - - DbgType* intPtrType = mDbgModule->GetPrimitiveType(DbgType_IntPtr_Alias, GetLanguage()); + + DbgType* intPtrType = mDbgModule->GetPrimitiveType(DbgType_IntPtr_Alias, GetLanguage()); long ptrDiff = leftValue.mPtr - rightValue.mPtr; int elemSize = resultType->mTypeParam->GetStride(); if (elemSize == 0) @@ -6080,7 +6080,7 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress { Fail("Invalid operation on pointers", opToken); return; - } + } // Compare them as ints resultType = mDbgModule->GetPrimitiveType(DbgType_UIntPtr_Alias, GetLanguage()); @@ -6133,13 +6133,13 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress } if (innerType->GetByteCount() == 0) - { + { Warn("Adding to a pointer to a zero-sized element has no effect", opToken); } return; } - } + } if ((resultType->IsPointer()) || (resultType->IsBfObject()) || (resultType->IsInterface()) /*|| (resultType->IsGenericParam())*/) { @@ -6174,24 +6174,24 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress if ((binaryOp == BfBinaryOp_Equality) || (binaryOp == BfBinaryOp_StrictEquality)) mResult.mBool = resultTypedValue->mPtr == convertedValue.mPtr; else - mResult.mBool = resultTypedValue->mPtr != convertedValue.mPtr; + mResult.mBool = resultTypedValue->mPtr != convertedValue.mPtr; } return; - } + } /*else if (resultType->IsTypedPrimitive()) { bool needsOtherCast = true; if (otherType != resultType) - { + { if (otherType->IsPrimitiveType()) - { + { // Allow zero comparisons to match all typed primitives if ((binaryOp == BfBinaryOp_Equality) || (binaryOp == BfBinaryOp_InEquality)) { auto intConstant = dyn_cast(otherTypedValue->mValue); if (intConstant != NULL) - { + { if (intConstant->getSExtValue() == 0) { needsOtherCast = false; @@ -6215,14 +6215,14 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress Value* convOtherValue = mModule->CastToValue(otherTypeSrc, *otherTypedValue, underlyingType, true); if ((!underlyingType->IsValuelessType()) && ((convResultValue == NULL) || (convOtherValue == NULL))) - return; + return; if (resultTypedValue == &leftValue) PerformBinaryOperation(underlyingType, convResultValue, convOtherValue, binaryOp, opToken); else PerformBinaryOperation(underlyingType, convOtherValue, convResultValue, binaryOp, opToken); if (mResult.mType == underlyingType) - mResult.mType = resultType; + mResult.mType = resultType; return; }*/ else if (((leftValue.mType->IsStruct()) || (leftValue.mType->IsBfObject())) && (!resultType->IsEnum())) @@ -6241,7 +6241,7 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress TypeToString(rightValue.mType).c_str()), opToken); } return; - } + } if ((resultType->IsInteger()) && (!forceLeftType)) { @@ -6257,7 +6257,7 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress { if (binaryOp == BfBinaryOp_Subtract) { - + } else if (resultType->GetByteCount() < 4) { @@ -6290,8 +6290,8 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress explicitCast = true; } } - } - } + } + } if (convLeftValue == NULL) convLeftValue = Cast(leftExpression, leftValue, resultType, explicitCast); @@ -6304,13 +6304,13 @@ void DbgExprEvaluator::PerformBinaryOperation(ASTREF(BfExpression*)& leftExpress void DbgExprEvaluator::PerformBinaryOperation(DbgType* resultType, DbgTypedValue convLeftValue, DbgTypedValue convRightValue, BfBinaryOp binaryOp, BfTokenNode* opToken) { if (resultType->IsValuelessType()) - { + { switch (binaryOp) { case BfBinaryOp_Equality: case BfBinaryOp_StrictEquality: mResult.mType = mDbgModule->GetPrimitiveType(DbgType_Bool, GetLanguage()); - mResult.mBool = true; + mResult.mBool = true; break; case BfBinaryOp_InEquality: case BfBinaryOp_StrictInEquality: @@ -6321,14 +6321,14 @@ void DbgExprEvaluator::PerformBinaryOperation(DbgType* resultType, DbgTypedValue Fail("Invalid operation for void", opToken); break; } - return; + return; } if ((convLeftValue == NULL) || (convRightValue == NULL)) return; - if ((resultType->IsEnum()) || (resultType->IsTypedPrimitive())) - resultType = resultType->GetUnderlyingType(); + if ((resultType->IsEnum()) || (resultType->IsTypedPrimitive())) + resultType = resultType->GetUnderlyingType(); if (resultType->IsPrimitiveType()) { @@ -6361,7 +6361,7 @@ void DbgExprEvaluator::PerformBinaryOperation(DbgType* resultType, DbgTypedValue } return; } - } + } if ((!resultType->IsIntegral()) && (!resultType->IsFloat())) { @@ -6371,7 +6371,7 @@ void DbgExprEvaluator::PerformBinaryOperation(DbgType* resultType, DbgTypedValue mResult.mType = resultType; if (resultType->IsInteger()) - { + { switch (binaryOp) { case BfBinaryOp_BitwiseAnd: @@ -6386,7 +6386,7 @@ void DbgExprEvaluator::PerformBinaryOperation(DbgType* resultType, DbgTypedValue case BfBinaryOp_LeftShift: mResult.mInt64 = convLeftValue.GetInt64() << convRightValue.GetInt64(); return; - case BfBinaryOp_RightShift: + case BfBinaryOp_RightShift: mResult.mInt64 = convLeftValue.GetInt64() >> convRightValue.GetInt64(); return; } @@ -6401,7 +6401,7 @@ void DbgExprEvaluator::PerformBinaryOperation(DbgType* resultType, DbgTypedValue else if (resultType->mTypeCode == DbgType_Double) mResult.mDouble = convLeftValue.mDouble + convRightValue.mDouble; else - mResult.mInt64 = convLeftValue.GetInt64() + convRightValue.GetInt64(); + mResult.mInt64 = convLeftValue.GetInt64() + convRightValue.GetInt64(); break; case BfBinaryOp_Subtract: case BfBinaryOp_OverflowSubtract: @@ -6529,7 +6529,7 @@ void DbgExprEvaluator::Visit(BfBinaryOperatorExpression* binOpExpr) //PerformBinaryOperation(binOpExpr->mLeft, binOpExpr->mRight, binOpExpr->mOp, binOpExpr->mOpToken, false); // Check for "(double)-1.0" style cast, misidentified as a binary operation - if ((binOpExpr->mOp == BfBinaryOp_Add) || (binOpExpr->mOp == BfBinaryOp_Subtract) || + if ((binOpExpr->mOp == BfBinaryOp_Add) || (binOpExpr->mOp == BfBinaryOp_Subtract) || (binOpExpr->mOp == BfBinaryOp_BitwiseAnd) || (binOpExpr->mOp == BfBinaryOp_Multiply)) { if (auto parenExpr = BfNodeDynCast(binOpExpr->mLeft)) @@ -6557,7 +6557,7 @@ void DbgExprEvaluator::Visit(BfBinaryOperatorExpression* binOpExpr) { VisitChild(binOpExpr->mRight); if (!mResult) - return; + return; } if ((mResult) && (binOpExpr->mOp == BfBinaryOp_Subtract)) @@ -6570,7 +6570,7 @@ void DbgExprEvaluator::Visit(BfBinaryOperatorExpression* binOpExpr) mResult.mInt64 = -mResult.GetInt64(); } - mResult = Cast(binOpExpr, mResult, resolvedType, true); + mResult = Cast(binOpExpr, mResult, resolvedType, true); return; } } @@ -6586,7 +6586,7 @@ void DbgExprEvaluator::Visit(BfBinaryOperatorExpression* binOpExpr) VisitChild(binOpExpr->mLeft); if (mResult) - { + { //if (mAutoComplete != NULL) //mAutoComplete->CheckEmptyStart(binOpExpr->mOpToken, mResult.mType); } @@ -6624,7 +6624,7 @@ void DbgExprEvaluator::PerformUnaryExpression(BfAstNode* opToken, BfUnaryOp unar if (ptr.mType->IsEnum()) ptr.mType = ptr.mType->mTypeParam; - + auto val = mResult; int add = ((unaryOp == BfUnaryOp_Decrement) || (unaryOp == BfUnaryOp_PostDecrement)) ? -1 : 1; switch (ptr.mType->mTypeCode) @@ -6690,7 +6690,7 @@ void DbgExprEvaluator::PerformUnaryExpression(BfAstNode* opToken, BfUnaryOp unar { Fail("Operator can only be used on pointer values", opToken); return; - } + } mResult = ReadTypedValue(opToken, type->mTypeParam, mResult.mPtr, DbgAddrType_Target); } break; @@ -6722,7 +6722,7 @@ void DbgExprEvaluator::PerformUnaryExpression(BfAstNode* opToken, BfUnaryOp unar { Fail("Operator can only be used on boolean values", opToken); return; - } + } mResult.mIsLiteral = wasLiteral; mResult.mBool = !mResult.mBool; } @@ -6737,7 +6737,7 @@ void DbgExprEvaluator::PerformUnaryExpression(BfAstNode* opToken, BfUnaryOp unar if (wasLiteral) { // This is a special case where the user entered -0x80000000 (maxint) but we thought "0x80000000" was a uint in the parser - // which would get expanded to an int64 for this negate. Properly bring back down to an int32 + // which would get expanded to an int64 for this negate. Properly bring back down to an int32 if ((primType->mTypeCode == DbgType_u32) && (mResult.GetInt64() == -0x80000000LL)) { //mResult = DbgTypedValue(mModule->GetConstValue((int) i64Val), mModule->GetPrimitiveType(DwTypeCode_Int32)); @@ -6763,7 +6763,7 @@ void DbgExprEvaluator::PerformUnaryExpression(BfAstNode* opToken, BfUnaryOp unar } mResult.mIsLiteral = wasLiteral; - if (mResult.mType->mTypeCode == DbgType_Single) + if (mResult.mType->mTypeCode == DbgType_Single) mResult.mSingle = -mResult.mSingle; else if (mResult.mType->mTypeCode == DbgType_Double) mResult.mDouble = -mResult.mDouble; @@ -6814,9 +6814,9 @@ void DbgExprEvaluator::Visit(BfUnaryOperatorExpression* unaryOpExpr) bool DbgExprEvaluator::ResolveArgValues(const BfSizedArray& arguments, SizedArrayImpl& outArgValues) { for (int argIdx = 0; argIdx < (int) arguments.size(); argIdx++) - { + { //BfExprEvaluator exprEvaluator(mModule); - //exprEvaluator.Evaluate(arguments[argIdx]); + //exprEvaluator.Evaluate(arguments[argIdx]); auto arg = arguments[argIdx]; DbgTypedValue argValue; if (arg != NULL) @@ -6844,7 +6844,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, DbgTypedValue mPassInstance->Fail("Not running"); return DbgTypedValue(); }*/ - + #ifdef BF_WANTS_LOG_DBGEXPR auto _GetResultString = [&](DbgTypedValue val) { @@ -6852,7 +6852,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, DbgTypedValue if (val.mSrcAddress != 0) { result += StrFormat("0x%p ", val.mSrcAddress); - + int64 vals[4] = { 0 }; mDebugger->ReadMemory(val.mSrcAddress, 4 * 8, vals); @@ -6864,18 +6864,18 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, DbgTypedValue } return result; }; -#endif - +#endif + int curCallResultIdx = mCallResultIdx++; if (((mExpressionFlags & DwEvalExpressionFlag_AllowCalls) == 0) || (mCreatedPendingCall)) { BfLogDbgExpr(" BlockedSideEffects\n"); - mBlockedSideEffects = true; + mBlockedSideEffects = true; return GetDefaultTypedValue(method->mReturnType); } - mHadSideEffects = true; - + mHadSideEffects = true; + // Our strategy is to create "pending results" for each call in a debug expression, and then we continually re-evaluate the // entire expression using the actual returned results for each of those calls until we can finally evaluate it as a whole if (curCallResultIdx < (int)mCallResults->size() - 1) @@ -6909,7 +6909,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, DbgTypedValue returnVal = mDebugger->ReadReturnValue(&newPhysRegisters, method->mReturnType); bool hadRef = false; auto returnType = method->mReturnType->RemoveModifiers(&hadRef); - if (hadRef) + if (hadRef) { returnVal = ReadTypedValue(NULL, returnType, returnVal.mPtr, DbgAddrType_Target); returnVal.mType = returnType; @@ -6919,17 +6919,17 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, DbgTypedValue { returnVal.mType = mDbgModule->GetPrimitiveType(DbgType_Void, GetLanguage()); } - + BfLogDbgExpr(" using new results %s\n", _GetResultString(returnVal).c_str()); mDebugger->RestoreAllRegisters(); - + if ((method->mReturnType->IsCompositeType()) && (mDebugger->CheckNeedsSRetArgument(method->mReturnType))) { callResult.mSRetData.Resize(method->mReturnType->GetByteCount()); mDebugger->ReadMemory(returnVal.mSrcAddress, method->mReturnType->GetByteCount(), &callResult.mSRetData[0]); } - callResult.mResult = returnVal; + callResult.mResult = returnVal; return returnVal; } @@ -6990,14 +6990,14 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, DbgTypedValue } mDebugger->SaveAllRegisters(); - + BfLogDbg("Starting RunState_DebugEval on thread %d\n", mDebugger->mActiveThread->mThreadId); - addr_target prevSP = registers->GetSP(); - + addr_target prevSP = registers->GetSP(); + //registers->mIntRegs.efl = 0x244; - //mDebugger->PushValue(registers, 0); + //mDebugger->PushValue(registers, 0); mDebugger->PushValue(registers, 42); *(registers->GetPCRegisterRef()) = startAddr; @@ -7007,12 +7007,12 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, DbgTypedValue // If we step ONTO the PC we set, then that means we have returned from kernel mode // so we need to set the registers again (they would have been clobbered due to SetThreadContext bugs). // If we step past the PC then we're all good - registers->mIntRegs.efl |= 0x100; - mDebugger->SetRegisters(registers); + registers->mIntRegs.efl |= 0x100; + mDebugger->SetRegisters(registers); //::ResumeThread(mDebugger->mActiveThread->mHThread); //TODO: For debugging stepping: - + if ((mExpressionFlags & DwEvalExpressionFlag_StepIntoCalls) != 0) { mDebugger->mDebugManager->mOutMessages.push_back("rehupLoc"); @@ -7031,7 +7031,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, DbgTypedValue mDebugger->mRequestedStackFrameIdx = -1; BfLogDbg("DbgExprEvaluator::CreateCall %p in thread %d\n", startAddr, mDebugger->mActiveThread->mThreadId); - + DbgCallResult callResult; callResult.mSubProgram = method; callResult.mStructRetVal = structRetVal; @@ -7044,8 +7044,8 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, DbgTypedValue DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue target, DbgSubprogram* method, bool bypassVirtual, const BfSizedArray& arguments, SizedArrayImpl& argValues) { HashSet splatParams; - SizedArray argPushQueue; - + SizedArray argPushQueue; + // { for (auto variable : method->mBlock.mVariables) @@ -7064,7 +7064,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t int argIdx = 0; int paramIdx = 0; - + auto _PushArg = [&](const DbgTypedValue& typedValue, DbgVariable* param) { if (typedValue.mType->GetByteCount() == 0) @@ -7087,7 +7087,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t { auto elemTypedValue = ReadTypedValue(targetSrc, type, typedVal.mSrcAddress, DbgAddrType_Target); DbgMethodArgument methodArg; - methodArg.mTypedValue = elemTypedValue; + methodArg.mTypedValue = elemTypedValue; argPushQueue.push_back(methodArg); return; } @@ -7117,7 +7117,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t return; } } - + DbgMethodArgument methodArg; methodArg.mTypedValue = typedValue; methodArg.mWantsRef = param->mType->IsRef(); @@ -7133,7 +7133,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t if (method->mHasThis) { - auto param = method->mParams[paramIdx]; + auto param = method->mParams[paramIdx]; if ((param->mType != NULL) && (param->mType->IsValueType())) thisByValue = true; @@ -7142,12 +7142,12 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t Fail(StrFormat("An object reference is required to invoke the non-static method '%s'", method->ToString().c_str()), targetSrc); return DbgTypedValue(); } - + _PushArg(target, param); - methodParamCount--; + methodParamCount--; } else - { + { if (target.mPtr != 0) { Fail(StrFormat("Method '%s' cannot be accessed with an instance reference; qualify it with a type name instead", method->ToString().c_str()), targetSrc); @@ -7157,8 +7157,8 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t DbgTypedValue expandedParamsArray; DbgType* expandedParamsElementType = NULL; - int extendedParamIdx = 0; - + int extendedParamIdx = 0; + int paramOffset = method->mHasThis ? 1 : 0; while (true) { @@ -7180,18 +7180,18 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t } break; } - + DbgVariable* param = NULL; DbgType* wantType = NULL; - if (expandedParamsElementType != NULL) + if (expandedParamsElementType != NULL) { - wantType = expandedParamsElementType; + wantType = expandedParamsElementType; } else { param = method->mParams[paramIdx + paramOffset]; wantType = param->mType; - + //TODO: /*if (method->mParams[paramIdx]->mParamType == BfParamType_Params) { @@ -7199,7 +7199,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t bool isDirectPass = false; if (argIdx < (int)arguments.size()) - { + { if (argValues[argIdx].mValue == NULL) return DbgTypedValue(); if (mModule->CanCast(argValues[argIdx], wantType)) @@ -7268,7 +7268,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t BfAstNode* refNode = targetSrc; if (arguments.size() > 0) refNode = arguments.back(); - mModule->Fail(StrFormat("Not enough parameters specified. Got %d, expected %d.", arguments.size(), methodInstance->mParamTypes.size()), refNode); + mModule->Fail(StrFormat("Not enough parameters specified. Got %d, expected %d.", arguments.size(), methodInstance->mParamTypes.size()), refNode); return DbgTypedValue(); } llvmArgs.push_back(methodInstance->mDefaultValues[argIdx]);*/ @@ -7283,7 +7283,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t continue; } - + if (argValue.mType == NULL) return DbgTypedValue(); @@ -7319,7 +7319,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t wantType = mDbgModule->GetPointerType(wantType->mTypeParam); argValue.mPtr = argValue.mSrcAddress; argValue.mSrcAddress = 0; - argValue.mType = wantType; + argValue.mType = wantType; }*/ argValue = Cast(arg, argValue, wantType); @@ -7348,7 +7348,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t Fail("Invalid expression type", arg); return DbgTypedValue(); } - + //TODO: /*if (expandedParamsArray) { @@ -7360,18 +7360,18 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t else*/ { //llvmArgs.push_back(argValue.mValue); - _PushArg(argValue, param); + _PushArg(argValue, param); paramIdx++; - } + } argIdx++; } return CreateCall(method, argPushQueue, bypassVirtual); } - + DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, SizedArrayImpl& argPushQueue, bool bypassVirtual) { - BfLogDbgExpr("CreateCall #%d %s", mCallResultIdx, method->mName); + BfLogDbgExpr("CreateCall #%d %s", mCallResultIdx, method->mName); if (mDebugger->IsMiniDumpDebugger()) { @@ -7384,7 +7384,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, SizedArrayImpl mBlockedSideEffects = true; return GetDefaultTypedValue(method->mReturnType); } - mHadSideEffects = true; + mHadSideEffects = true; // We need current physical registers to make sure we push params in correct stack frame CPURegisters registers; @@ -7408,18 +7408,18 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, SizedArrayImpl if ((param->mType != NULL) && (param->mType->IsValueType())) thisByValue = true; } - + DbgTypedValue structRetVal; if (mDebugger->CheckNeedsSRetArgument(method->mReturnType)) { int retSize = BF_ALIGN(method->mReturnType->GetByteCount(), 16); - *regSP -= retSize; + *regSP -= retSize; structRetVal.mType = method->mReturnType; structRetVal.mSrcAddress = *regSP; // For chained calls we need to leave the sret form the previous calls intact mCallStackPreservePos = *regSP; - } + } for (int i = (int)argPushQueue.size() - 1; i >= 0; i--) { @@ -7429,19 +7429,19 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, SizedArrayImpl // on the stack and pass that address if (arg.mWantsRef) { - auto& typedValue = arg.mTypedValue; + auto& typedValue = arg.mTypedValue; auto rootType = typedValue.mType->RemoveModifiers(); if (arg.mTypedValue.mSrcAddress != 0) { typedValue.mPtr = typedValue.mSrcAddress; } else - { + { int rootSize = rootType->GetByteCount(); - *regSP -= BF_ALIGN(rootSize, 16); + *regSP -= BF_ALIGN(rootSize, 16); mDebugger->WriteMemory(*regSP, &arg.mTypedValue.mInt64, rootSize); // Write from debugger memory to target typedValue.mPtr = *regSP; - } + } typedValue.mType = mDbgModule->GetPointerType(rootType); typedValue.mSrcAddress = 0; @@ -7449,11 +7449,11 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, SizedArrayImpl } if (structRetVal.mSrcAddress != 0) - { + { BfLogDbgExpr(" SRet:0x%p", structRetVal.mSrcAddress); mDebugger->AddParamValue(0, method->mHasThis && !thisByValue, ®isters, structRetVal); paramIdx++; - } + } DbgTypedValue thisVal; for (int padCount = 0; true; padCount++) @@ -7462,12 +7462,12 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, SizedArrayImpl int paramIdxSave = paramIdx; *regSP -= padCount * sizeof(addr_target); - + for (int i = (int)argPushQueue.size() - 1; i >= 0; i--) { auto& arg = argPushQueue[i]; if ((i == 0) && (method->mHasThis) && (!method->ThisIsSplat())) - { + { thisVal = arg.mTypedValue; addr_target thisAddr; if (thisVal.mType->IsCompositeType()) @@ -7496,14 +7496,14 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, SizedArrayImpl registers = regSave; paramIdx = paramIdxSave; - + BF_ASSERT(padCount < 3); } return CreateCall(method, thisVal, structRetVal, bypassVirtual, ®isters); } -DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue target, bool allowImplicitThis, bool bypassVirtual, const StringImpl& methodName, +DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue target, bool allowImplicitThis, bool bypassVirtual, const StringImpl& methodName, const BfSizedArray& arguments, BfSizedArray* methodGenericArguments) { SetAndRestoreValue prevReferenceId(mReferenceId, NULL); @@ -7516,7 +7516,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue SizedArray argValues; if (!ResolveArgValues(arguments, argValues)) return DbgTypedValue(); - + if ((methodName == "__cast") || (methodName == "__bitcast")) { if (argValues.size() > 0) @@ -7547,7 +7547,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue BeefTypeToString(arg, typeName); } } - + auto castedType = mDbgModule->FindType(typeName, NULL, GetLanguage(), true); if (castedType == NULL) { @@ -7565,22 +7565,22 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue Fail(StrFormat("Unable to find type: '%s'", typeName.c_str()), targetSrc); return argValues[targetArgIdx]; } - + if (methodName == "__bitcast") { DbgTypedValue result = argValues[targetArgIdx]; result.mType = castedType; return result; } - - return Cast(arguments[targetArgIdx], argValues[targetArgIdx], castedType, true); - } - } + + return Cast(arguments[targetArgIdx], argValues[targetArgIdx], castedType, true); + } + } else if (methodName == "__hasField") { if (argValues.size() == 2) { - auto checkType = argValues[0].mType; + auto checkType = argValues[0].mType; if ((checkType != NULL) && (checkType->IsPointer())) checkType = checkType->mTypeParam; if (checkType != NULL) @@ -7784,7 +7784,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue else if (methodName == "__stringView") { if (argValues.size() >= 2) - { + { if ((argValues[1].mType != NULL) && (argValues[1].mType->IsInteger())) mCountResultOverride = (intptr)argValues[1].GetInt64(); return argValues[0]; @@ -7812,7 +7812,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue if (bitCount <= 0) return argValues[0]; - + int64 andBits = (0x8000000000000000LL) >> ((argValues[0].mType->GetByteCount() - 8) * 8 + bitCount - 1); DbgTypedValue result; result.mType = argValues[0].mType; @@ -7823,7 +7823,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue else if (methodName == "__parseCompileUnits") { for (auto dbgModule : mDebugTarget->mDbgModules) - { + { dbgModule->ParseCompileUnits(); } } @@ -7832,7 +7832,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue DbgType* targetTypeInst = NULL; bool checkNonStatic = true; if (target) - { + { targetTypeInst = target.mType; curTypeDef = targetTypeInst; } @@ -7842,7 +7842,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue { //TODO ; //targetTypeInst = mModule->GetPrimitiveStructType(target.mType); - } + } else targetTypeInst = target.mType; if (targetTypeInst == NULL) @@ -7854,15 +7854,15 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue checkNonStatic = false; } else // Current scope - { + { curTypeDef = GetCurrentType(); targetTypeInst = GetCurrentType(); auto currentMethod = GetCurrentMethod(); - + checkNonStatic = (currentMethod != NULL) && (currentMethod->mHasThis); } - DbgSubprogram* methodDef = NULL; + DbgSubprogram* methodDef = NULL; BfTypeVector checkMethodGenericArguments; bool isFailurePass = false; @@ -7872,7 +7872,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue methodMatcher.mTargetIsConst = targetTypeInst->IsConst(); if (targetTypeInst != NULL) { - methodMatcher.CheckType(targetTypeInst, false); + methodMatcher.CheckType(targetTypeInst, false); if (methodMatcher.mBestMethodDef == NULL) { isFailurePass = true; @@ -7904,8 +7904,8 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue if (allowImplicitThis) { //auto thisValue = mModule->GetThis(); - //LookupField(targetSrc, thisValue, methodName); - fieldVal = LookupIdentifier(BfNodeDynCast(targetSrc)); + //LookupField(targetSrc, thisValue, methodName); + fieldVal = LookupIdentifier(BfNodeDynCast(targetSrc)); } else { @@ -7924,9 +7924,9 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue if (fieldTypeInst->mTypeDef->mIsDelegate) return MatchMethod(targetSrc, fieldVal, false, false, "Invoke", arguments, methodGenericArguments); } - fieldVal.mType = mModule->ResolveGenericParam(fieldVal.mType); - if (fieldVal.mType->IsVar()) - return DbgTypedValue(mModule->GetDefaultValue(fieldVal.mType), fieldVal.mType); + fieldVal.mType = mModule->ResolveGenericParam(fieldVal.mType); + if (fieldVal.mType->IsVar()) + return DbgTypedValue(mModule->GetDefaultValue(fieldVal.mType), fieldVal.mType); mModule->Fail(StrFormat("Cannot perform invocation on type '%s'", mModule->TypeToString(fieldVal.mType).c_str()), targetSrc); return DbgTypedValue(); }*/ @@ -7960,7 +7960,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue mModule->Fail("Objects must be allocated through 'new' or 'stack'", targetSrc); return DbgTypedValue(); } - + DbgTypedValue structInst = DbgTypedValue(mModule->mIRBuilder->CreateAlloca(resolvedType->mLLVMType), resolvedType, false); MatchConstructor(targetSrc, structInst, resolvedType, arguments, false); @@ -7970,11 +7970,11 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue }*/ if ((methodDef == NULL) && (!target)) - { + { for (int compileUnitIdx = 0; compileUnitIdx < (int)mDbgModule->mCompileUnits.size(); compileUnitIdx++) { auto compileUnit = mDbgModule->mCompileUnits[compileUnitIdx]; - methodMatcher.CheckType(compileUnit->mGlobalType, isFailurePass); + methodMatcher.CheckType(compileUnit->mGlobalType, isFailurePass); if (methodMatcher.mBestMethodDef != NULL) { isFailurePass = false; @@ -7982,7 +7982,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue methodDef = methodMatcher.mBestMethodDef; break; } - } + } } if ((methodDef == NULL) && ((methodGenericArguments == NULL) || (methodGenericArguments->IsEmpty()))) @@ -7998,11 +7998,11 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue } if (methodDef == NULL) - { + { Fail("Method does not exist", targetSrc); return DbgTypedValue(); - } - + } + // Don't execute the method if we've had a failure (like an ambiguous lookup) if ((mPassInstance != NULL) && (mPassInstance->HasFailed())) return DbgTypedValue(); @@ -8013,7 +8013,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue callTarget = target; } else if (target) - { + { bool handled = false; if (target.mType->IsCompositeType()) { @@ -8022,7 +8022,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue /*if (curTypeInst->IsObject()) { // Box it - callTarget = mModule->Cast(targetSrc, target, curTypeInst, true); + callTarget = mModule->Cast(targetSrc, target, curTypeInst, true); handled = true; }*/ } @@ -8034,7 +8034,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue callTarget = DbgTypedValue(mModule->mIRBuilder->CreateBitCast(targetValue, curTypeInst->mPtrLLVMType), curTypeInst);*/ callTarget = target; } - } + } if (prevReferenceId.mPrevVal != NULL) { @@ -8043,7 +8043,7 @@ DbgTypedValue DbgExprEvaluator::MatchMethod(BfAstNode* targetSrc, DbgTypedValue *prevReferenceId.mPrevVal += methodDef->ToString(); } - return CreateCall(targetSrc, callTarget, methodDef, bypassVirtual, arguments, argValues); + return CreateCall(targetSrc, callTarget, methodDef, bypassVirtual, arguments, argValues); } void DbgExprEvaluator::DoInvocation(BfAstNode* target, BfSizedArray& args, BfSizedArray* methodGenericArguments) @@ -8056,11 +8056,11 @@ void DbgExprEvaluator::DoInvocation(BfAstNode* target, BfSizedArray(target)) - { + { //GetAutoComplete()->CheckMemberReference(memberRefExpression->mTarget, memberRefExpression->mDotToken, memberRefExpression->mMemberName); if (memberRefExpression->mMemberName == NULL) - return; + return; if (memberRefExpression->IsA()) bypassVirtual = true; @@ -8069,13 +8069,13 @@ void DbgExprEvaluator::DoInvocation(BfAstNode* target, BfSizedArray(memberRefExpression->mMemberName)) { - methodNodeSrc = attrIdentifier->mIdentifier; + methodNodeSrc = attrIdentifier->mIdentifier; if (attrIdentifier->mIdentifier != NULL) targetFunctionName = attrIdentifier->mIdentifier->ToString(); } else targetFunctionName = memberRefExpression->mMemberName->ToString(); - + if (memberRefExpression->mTarget == NULL) { // Dot-qualified @@ -8102,22 +8102,22 @@ void DbgExprEvaluator::DoInvocation(BfAstNode* target, BfSizedArray(target)) - { + { /*if (GetAutoComplete() != NULL) GetAutoComplete()->CheckMemberReference(qualifiedName->mLeft, qualifiedName->mDot, qualifiedName->mRight);*/ - - String leftName = qualifiedName->mLeft->ToString(); - if (leftName == "base") - bypassVirtual = true; - methodNodeSrc = qualifiedName->mRight; + String leftName = qualifiedName->mLeft->ToString(); + if (leftName == "base") + bypassVirtual = true; + + methodNodeSrc = qualifiedName->mRight; if (auto attrIdentifier = BfNodeDynCast(qualifiedName->mRight)) { - methodNodeSrc = attrIdentifier->mIdentifier; + methodNodeSrc = attrIdentifier->mIdentifier; targetFunctionName = attrIdentifier->mIdentifier->ToString(); } else - targetFunctionName = qualifiedName->mRight->ToString(); + targetFunctionName = qualifiedName->mRight->ToString(); bool hadError = false; thisValue = LookupIdentifier(qualifiedName->mLeft, true, &hadError); @@ -8132,12 +8132,12 @@ void DbgExprEvaluator::DoInvocation(BfAstNode* target, BfSizedArray prevIgnoreErrors(mIgnoreErrors, true); type = ResolveTypeRef(qualifiedName->mLeft); - } + } /*if (type->IsGenericParam()) { auto genericParamInstance = mModule->GetGenericParamInstance((BfGenericParamType*)type); - type = genericParamInstance->mTypeConstraint; + type = genericParamInstance->mTypeConstraint; }*/ if (type != NULL) @@ -8156,13 +8156,13 @@ void DbgExprEvaluator::DoInvocation(BfAstNode* target, BfSizedArray(target)) { allowImplicitThis = true; targetFunctionName = target->ToString(); - + } else if (auto invocationExpr = BfNodeDynCast(target)) { @@ -8173,7 +8173,7 @@ void DbgExprEvaluator::DoInvocation(BfAstNode* target, BfSizedArrayIsTypeInstance()) { auto invocationTypeInst = innerInvocationResult.mType->ToTypeInstance(); @@ -8188,7 +8188,7 @@ void DbgExprEvaluator::DoInvocation(BfAstNode* target, BfSizedArrayToString().c_str()), invocationExpr->mTarget); return; - } + } } else { @@ -8197,16 +8197,16 @@ void DbgExprEvaluator::DoInvocation(BfAstNode* target, BfSizedArrayIsPointer()) { - //BF_ASSERT(thisValue.mIsAddr); + //BF_ASSERT(thisValue.mIsAddr); thisValue.mType = thisValue.mType->mTypeParam; thisValue.mSrcAddress = thisValue.mPtr; } if (thisValue.mType->IsPrimitiveType()) - { + { //TODO: /*auto primStructType = GetPrimitiveStructType(thisValue.mType); //thisValue = mModule->Cast(target, thisValue, primStructType); @@ -8215,19 +8215,19 @@ void DbgExprEvaluator::DoInvocation(BfAstNode* target, BfSizedArraysetAlignment(primStructType->mAlign); auto primPtr = mModule->mIRBuilder->CreateConstInBoundsGEP2_32(srcAlloca, 0, 0); mModule->mIRBuilder->CreateStore(thisValue.mValue, primPtr); - + thisValue = DbgTypedValue(srcAlloca, primStructType, true);*/ } if (thisValue.mType->IsEnum()) - { + { //auto enumStructType = thisValue.mType->ToTypeInstance(); /*auto srcAlloca = mModule->GetHeadIRBuilder()->CreateAlloca(enumStructType->mInstLLVMType, 0); srcAlloca->setAlignment(enumStructType->mAlign); auto enumPtr = mModule->mIRBuilder->CreateConstInBoundsGEP2_32(srcAlloca, 0, 0); mModule->mIRBuilder->CreateStore(thisValue.mValue, enumPtr);*/ - + //thisValue = DbgTypedValue(mModule->mIRBuilder->CreateBitCast(srcAlloca, enumStructType->mBaseType->mPtrLLVMType), enumStructType->mBaseType, true); } @@ -8238,29 +8238,29 @@ void DbgExprEvaluator::DoInvocation(BfAstNode* target, BfSizedArraymIsCapturingMethodMatchInfo); /*if (mAutoComplete != NULL) mAutoComplete->CheckInvocation(invocationExpr, invocationExpr->mOpenParen, invocationExpr->mCloseParen, invocationExpr->mCommas);*/ - + BfSizedArray* methodGenericArguments = NULL; if (invocationExpr->mGenericArgs != NULL) methodGenericArguments = &invocationExpr->mGenericArgs->mGenericArgs; DoInvocation(invocationExpr->mTarget, invocationExpr->mArguments, methodGenericArguments); - + if ((wasCapturingMethodInfo) && (!mAutoComplete->mIsCapturingMethodMatchInfo)) - { + { mAutoComplete->mIsCapturingMethodMatchInfo = true; BF_ASSERT(mAutoComplete->mMethodMatchInfo != NULL); } else if (mAutoComplete != NULL) - mAutoComplete->mIsCapturingMethodMatchInfo = false; + mAutoComplete->mIsCapturingMethodMatchInfo = false; } void DbgExprEvaluator::Visit(BfConditionalExpression* condExpr) @@ -8294,7 +8294,7 @@ void DbgExprEvaluator::Visit(BfTypeAttrExpression* typeAttrExpr) { if (typeAttrExpr->mTypeRef == NULL) return; - + AutocompleteCheckType(typeAttrExpr->mTypeRef); auto dbgType = ResolveTypeRef(typeAttrExpr->mTypeRef); if (dbgType == NULL) @@ -8337,13 +8337,13 @@ void DbgExprEvaluator::Visit(BfTupleExpression* tupleExpr) Fail(StrFormat("Tuple expressions cannot be used for type '%s'", mReceivingValue->mType->ToString().c_str()), tupleExpr); return; } - + CheckTupleCreation(mReceivingValue->mSrcAddress, tupleExpr, mReceivingValue->mType, tupleExpr->mValues, &tupleExpr->mNames); mReceivingValue = NULL; } DbgTypedValue DbgExprEvaluator::Resolve(BfExpression* expr, DbgType* wantType) -{ +{ //BfLogDbgExpr("Dbg Evaluate %s\n", expr->ToString().c_str()); BF_ASSERT(!HasPropResult()); @@ -8368,12 +8368,12 @@ DbgTypedValue DbgExprEvaluator::Resolve(BfExpression* expr, DbgType* wantType) { if (!mResult) break; - if (//(mResult.mType->mTypeCode == DbgType_Const) || + if (//(mResult.mType->mTypeCode == DbgType_Const) || (mResult.mType->mTypeCode == DbgType_Volatile)) mResult.mType = mResult.mType->mTypeParam; else break; - } + } if ((mResult) && (wantType != NULL)) mResult = Cast(expr, mResult, wantType); @@ -8407,7 +8407,7 @@ BfAstNode* DbgExprEvaluator::FinalizeExplicitThisReferences(BfAstNode* headNode) if ((unaryOpExpr->mOp != BfUnaryOp_AddressOf) && (unaryOpExpr->mOp != BfUnaryOp_Dereference)) doWrap = true; } - if ((explicitThisExpr->IsA()) || + if ((explicitThisExpr->IsA()) || (explicitThisExpr->IsA()) || (explicitThisExpr->IsA())) doWrap = true; @@ -8421,14 +8421,14 @@ BfAstNode* DbgExprEvaluator::FinalizeExplicitThisReferences(BfAstNode* headNode) auto source = headNode->GetSourceData(); for (auto& replaceNodeRecord : mDeferredInsertExplicitThisVector) - { + { auto replaceNode = replaceNodeRecord.mNode; DbgType* castType = NULL; auto typeRef = BfNodeDynCast(replaceNode); if ((typeRef != NULL) || (replaceNodeRecord.mForceTypeRef)) - { + { castType = ResolveTypeRef(replaceNode); if (castType == NULL) continue; @@ -8438,14 +8438,14 @@ BfAstNode* DbgExprEvaluator::FinalizeExplicitThisReferences(BfAstNode* headNode) // We must do this because we can't insert the actual 'this' node into multiple parents auto thisExprNode = source->mAlloc.Alloc(); BfAstNode* newNode = NULL; - + if (castType != NULL) { bfReducer.ReplaceNode(replaceNode, thisExprNode); newNode = thisExprNode; } else if (auto thisNode = BfNodeDynCast(replaceNode)) - { + { bfReducer.ReplaceNode(replaceNode, thisExprNode); newNode = thisExprNode; } @@ -8463,7 +8463,7 @@ BfAstNode* DbgExprEvaluator::FinalizeExplicitThisReferences(BfAstNode* headNode) bfReducer.MoveNode(thisExprNode, memberRefNode); memberRefNode->mTarget = thisExprNode; - newNode = memberRefNode; + newNode = memberRefNode; } if (newNode != NULL) @@ -8484,7 +8484,7 @@ BfAstNode* DbgExprEvaluator::FinalizeExplicitThisReferences(BfAstNode* headNode) int thisLen = (int)replaceString.length(); int srcStart = bfParser->AllocChars(thisLen); - memcpy((char*)source->mSrc + srcStart, replaceString.c_str(), thisLen); + memcpy((char*)source->mSrc + srcStart, replaceString.c_str(), thisLen); thisExprNode->Init(srcStart, srcStart, srcStart + thisLen); } diff --git a/IDEHelper/DbgModule.cpp b/IDEHelper/DbgModule.cpp index 29ffb0ae..085ea5f9 100644 --- a/IDEHelper/DbgModule.cpp +++ b/IDEHelper/DbgModule.cpp @@ -95,7 +95,7 @@ DbgSubprogram* DbgSubprogram::GetLineInlinee(const DbgLineData& lineData) DbgSrcFile* DbgSubprogram::GetLineSrcFile(const DbgLineData& lineData) { - auto inlineRoot = GetRootInlineParent(); + auto inlineRoot = GetRootInlineParent(); return inlineRoot->mLineInfo->mContexts[lineData.mCtxIdx].mSrcFile; } @@ -132,19 +132,19 @@ DbgLineData* DbgLineDataBuilder::Add(DbgCompileUnit* compileUnit, DbgLineData& l addr_target address = (addr_target)(lineData.mRelAddress + mDbgModule->mImageBase); if ((compileUnit->mLowPC != (addr_target)-1) && ((address < (addr_target)compileUnit->mLowPC) || (address >= (addr_target)compileUnit->mHighPC))) return NULL; - + if ((mCurSubprogram == NULL) || (address < mCurSubprogram->mBlock.mLowPC) || (address >= mCurSubprogram->mBlock.mHighPC)) { DbgSubprogramMapEntry* mapEntry = mDbgModule->mDebugTarget->mSubprogramMap.Get(address, DBG_MAX_LOOKBACK); if (mapEntry != NULL) { mCurSubprogram = mapEntry->mEntry; - + if (address > mCurSubprogram->mBlock.mHighPC) mCurSubprogram = NULL; if (mCurSubprogram != NULL) - { + { SubprogramRecord** recordPtr = NULL; if (mRecords.TryAdd(mCurSubprogram, NULL, &recordPtr)) { @@ -154,7 +154,7 @@ DbgLineData* DbgLineDataBuilder::Add(DbgCompileUnit* compileUnit, DbgLineData& l *recordPtr = mCurRecord; mCurRecord->mContexts.mAlloc = &mAlloc; mCurRecord->mContexts.Reserve(16); - mCurRecord->mLines.mAlloc = &mAlloc; + mCurRecord->mLines.mAlloc = &mAlloc; mCurRecord->mLines.Reserve(128); mCurRecord->mCurContext = -1; mCurRecord->mHasInlinees = false; @@ -169,7 +169,7 @@ DbgLineData* DbgLineDataBuilder::Add(DbgCompileUnit* compileUnit, DbgLineData& l if (mCurSubprogram == NULL) return NULL; - + bool needsNewCtx = false; if (mCurRecord->mCurContext == -1) { @@ -181,7 +181,7 @@ DbgLineData* DbgLineDataBuilder::Add(DbgCompileUnit* compileUnit, DbgLineData& l if ((curContext.mInlinee != inlinee) || (curContext.mSrcFile != srcFile)) { needsNewCtx = true; - for (int ctxIdx = 0; ctxIdx < (int)mCurRecord->mContexts.size(); ctxIdx++) + for (int ctxIdx = 0; ctxIdx < (int)mCurRecord->mContexts.size(); ctxIdx++) { auto& ctx = mCurRecord->mContexts[ctxIdx]; if ((ctx.mInlinee == inlinee) && (ctx.mSrcFile == srcFile)) @@ -193,15 +193,15 @@ DbgLineData* DbgLineDataBuilder::Add(DbgCompileUnit* compileUnit, DbgLineData& l } } } - + if (needsNewCtx) - { + { DbgLineInfoCtx ctx; ctx.mInlinee = inlinee; ctx.mSrcFile = srcFile; if (inlinee != NULL) mCurRecord->mHasInlinees = true; - mCurRecord->mContexts.Add(ctx); + mCurRecord->mContexts.Add(ctx); mCurRecord->mCurContext = (int)mCurRecord->mContexts.size() - 1; } @@ -209,7 +209,7 @@ DbgLineData* DbgLineDataBuilder::Add(DbgCompileUnit* compileUnit, DbgLineData& l if ((mCurSubprogram->mPrologueSize > 0) && (mCurRecord->mLines.size() == 1) && (inlinee == NULL)) { - auto& firstLine = mCurRecord->mLines[0]; + auto& firstLine = mCurRecord->mLines[0]; auto dbgStartAddr = firstLine.mRelAddress + mCurSubprogram->mPrologueSize; if (lineData.mRelAddress != dbgStartAddr) { @@ -225,7 +225,7 @@ DbgLineData* DbgLineDataBuilder::Add(DbgCompileUnit* compileUnit, DbgLineData& l { if (inlinee->mInlineeInfo->mFirstLineData.mRelAddress == 0) inlinee->mInlineeInfo->mFirstLineData = lineData; - inlinee->mInlineeInfo->mLastLineData = lineData; + inlinee->mInlineeInfo->mLastLineData = lineData; } mCurRecord->mLines.Add(lineData); @@ -235,9 +235,9 @@ DbgLineData* DbgLineDataBuilder::Add(DbgCompileUnit* compileUnit, DbgLineData& l void DbgLineDataBuilder::Commit() { HashSet usedSrcFiles; - + for (auto& recordKV : mRecords) - { + { auto dbgSubprogram = recordKV.mKey; auto record = recordKV.mValue; @@ -249,8 +249,8 @@ void DbgLineDataBuilder::Commit() ctx.mSrcFile->mLineDataRefs.Add(dbgSubprogram); } } - - for (int lineIdx = 0; lineIdx < (int)record->mLines.size() - 1; lineIdx++) + + for (int lineIdx = 0; lineIdx < (int)record->mLines.size() - 1; lineIdx++) { auto& lineData = record->mLines[lineIdx]; auto& nextLineData = record->mLines[lineIdx + 1]; @@ -267,7 +267,7 @@ void DbgLineDataBuilder::Commit() auto nextCtx = record->mContexts[lineData.mCtxIdx]; sameInliner = ctx.mInlinee == nextCtx.mInlinee; } - if ((sameInliner) && (lineData.mRelAddress + lineData.mContribSize < nextLineData.mRelAddress)) + if ((sameInliner) && (lineData.mRelAddress + lineData.mContribSize < nextLineData.mRelAddress)) { auto ctx = record->mContexts[lineData.mCtxIdx]; if (ctx.mInlinee != NULL) @@ -276,7 +276,7 @@ void DbgLineDataBuilder::Commit() } DbgLineData* lastLine = NULL; - for (int lineIdx = 0; lineIdx < (int)record->mLines.size(); lineIdx++) + for (int lineIdx = 0; lineIdx < (int)record->mLines.size(); lineIdx++) { auto& lineData = record->mLines[lineIdx]; if (lineData.mContribSize == 0) @@ -297,7 +297,7 @@ void DbgLineDataBuilder::Commit() contexts.CopyFrom(&record->mContexts[0], (int)record->mContexts.size(), mDbgModule->mAlloc); dbgSubprogram->mLineInfo->mContexts = contexts.mVals; - dbgSubprogram->mLineInfo->mHasInlinees = record->mHasInlinees; + dbgSubprogram->mLineInfo->mHasInlinees = record->mHasInlinees; } } @@ -317,18 +317,18 @@ struct AbstractOriginEntry public: int mClassType; DbgDebugData* mDestination; - DbgDebugData* mAbstractOrigin; + DbgDebugData* mAbstractOrigin; private: AbstractOriginEntry() - { + { } public: static AbstractOriginEntry Create(int classType, DbgDebugData* destination, DbgDebugData* abstractOrigin) { AbstractOriginEntry abstractOriginEntry; - abstractOriginEntry.mClassType = classType; + abstractOriginEntry.mClassType = classType; abstractOriginEntry.mDestination = destination; abstractOriginEntry.mAbstractOrigin = abstractOrigin; return abstractOriginEntry; @@ -351,7 +351,7 @@ public: { destSubprogram->mFrameBaseData = originSubprogram->mFrameBaseData; destSubprogram->mFrameBaseLen = originSubprogram->mFrameBaseLen; - } + } destSubprogram->mReturnType = originSubprogram->mReturnType; auto originItr = originSubprogram->mParams.begin(); @@ -363,8 +363,8 @@ public: if (destParam->mName == NULL) destParam->mName = originParam->mName; if (destParam->mType == NULL) - destParam->mType = originParam->mType; - } + destParam->mType = originParam->mType; + } ++originItr; } //BF_ASSERT(originItr == originSubprogram->mParams.end()); @@ -376,7 +376,7 @@ public: if (destVariable->mName == NULL) destVariable->mName = originVariable->mName; if (destVariable->mType == NULL) - destVariable->mType = originVariable->mType; + destVariable->mType = originVariable->mType; } else { @@ -395,7 +395,7 @@ void DbgSubprogram::ToString(StringImpl& str, bool internalName) mCompileUnit->mDbgModule->FixupInlinee(this); PopulateSubprogram(); - + if (mCheckedKind == BfCheckedKind_Checked) str += "[Checked] "; else if (mCheckedKind == BfCheckedKind_Unchecked) @@ -403,14 +403,14 @@ void DbgSubprogram::ToString(StringImpl& str, bool internalName) auto language = GetLanguage(); if (mName == NULL) - { + { if (mLinkName[0] == '<') { str += mLinkName; return; } str = BfDemangler::Demangle(StringImpl::MakeRef(mLinkName), language); - // Strip off the params since we need to generate those ourselves + // Strip off the params since we need to generate those ourselves int parenPos = (int)str.IndexOf('('); if (parenPos != -1) str = str.Substring(0, parenPos); @@ -469,7 +469,7 @@ void DbgSubprogram::ToString(StringImpl& str, bool internalName) str += "."; else str += "::"; - } + } } const char* name = mName; @@ -480,11 +480,11 @@ void DbgSubprogram::ToString(StringImpl& str, bool internalName) { char c = *cPtr; if (c == 0) - break; + break; if ((c == ':') && (cPtr[1] == ':')) { name = cPtr + 2; - } + } } } @@ -564,7 +564,7 @@ void DbgSubprogram::ToString(StringImpl& str, bool internalName) showedParam = true; i++; } - str += ")"; + str += ")"; } String DbgSubprogram::ToString() @@ -575,22 +575,22 @@ String DbgSubprogram::ToString() } // For inlined subprograms, the "root" inliner means the bottom-most non-inlined function. This subprogram contains -// all the line data for it's own non-inlined instructions, PLUS line data for all inlined functions that it calls. +// all the line data for it's own non-inlined instructions, PLUS line data for all inlined functions that it calls. // The inlined functions has empty mLineInfo structures. -// +// // When we pass a non-NULL value into inlinedSubprogram, we are requesting to ONLY return lines that were emitted from -// that subprogram (inlined or not). +// that subprogram (inlined or not). // // If we call FindClosestLine on an inlined subprogram, we only want results of functions that are inside or inlined by // the 'this' subprogram. Thus, we do a "get any line" call on the root inliner and then filter the results based // on whether they are relevant. DbgLineData* DbgSubprogram::FindClosestLine(addr_target addr, DbgSubprogram** inlinedSubprogram, DbgSrcFile** srcFile, int* outLineIdx) -{ +{ if (mLineInfo == NULL) { if (mInlineeInfo == NULL) return NULL; - + if ((inlinedSubprogram != NULL) && (*inlinedSubprogram != NULL)) { // Keep explicit inlinee requirement @@ -619,7 +619,7 @@ DbgLineData* DbgSubprogram::FindClosestLine(addr_target addr, DbgSubprogram** in } return NULL; - } + } } // Binary search - lineData is sorted @@ -637,7 +637,7 @@ DbgLineData* DbgSubprogram::FindClosestLine(addr_target addr, DbgSubprogram** in else if (midAddr == addr) { useIdx = middle; - break; + break; } else last = middle - 1; @@ -650,7 +650,7 @@ DbgLineData* DbgSubprogram::FindClosestLine(addr_target addr, DbgSubprogram** in if (last == -1) return NULL; - + // If we have lines with the same addr, take the more inner one while (true) { @@ -679,7 +679,7 @@ DbgLineData* DbgSubprogram::FindClosestLine(addr_target addr, DbgSubprogram** in *srcFile = ctx.mSrcFile; if (inlinedSubprogram != NULL) - { + { auto subprogram = (ctx.mInlinee != NULL) ? ctx.mInlinee : this; if (*inlinedSubprogram != NULL) { @@ -716,7 +716,7 @@ DbgLineData* DbgSubprogram::FindClosestLine(addr_target addr, DbgSubprogram** in } DbgType* DbgSubprogram::GetParent() -{ +{ if ((mParentType == NULL) && (mCompileUnit != NULL)) mCompileUnit->mDbgModule->MapCompileUnitMethods(mCompileUnit); return mParentType; @@ -725,7 +725,7 @@ DbgType* DbgSubprogram::GetParent() DbgType* DbgSubprogram::GetTargetType() { if (!mHasThis) - return mParentType; + return mParentType; auto thisType = mParams.mHead->mType; if (thisType == NULL) return mParentType; @@ -735,7 +735,7 @@ DbgType* DbgSubprogram::GetTargetType() } DbgLanguage DbgSubprogram::GetLanguage() -{ +{ if (mParentType != NULL) return mParentType->GetLanguage(); if (mCompileUnit->mLanguage != DbgLanguage_Unknown) @@ -749,7 +749,7 @@ bool DbgSubprogram::Equals(DbgSubprogram* checkMethod, bool allowThisMismatch) { return strcmp(mLinkName, checkMethod->mLinkName) == 0; } - + if (strcmp(mName, checkMethod->mName) != 0) return false; @@ -822,7 +822,7 @@ bool DbgSubprogram::IsGenericMethod() bool DbgSubprogram::ThisIsSplat() { if (mBlock.mVariables.mHead == NULL) - return false; + return false; return strncmp(mBlock.mVariables.mHead->mName, "$this$", 6) == 0; } @@ -854,8 +854,8 @@ bool DbgSrcFile::IsBeef() DbgSrcFile::~DbgSrcFile() { - for (auto replacedLineInfo : mHotReplacedDbgLineInfo) - delete replacedLineInfo; + for (auto replacedLineInfo : mHotReplacedDbgLineInfo) + delete replacedLineInfo; } void DbgSrcFile::RemoveDeferredRefs(DbgModule* debugModule) @@ -863,10 +863,10 @@ void DbgSrcFile::RemoveDeferredRefs(DbgModule* debugModule) for (int deferredIdx = 0; deferredIdx < (int)mDeferredRefs.size(); ) { if (mDeferredRefs[deferredIdx].mDbgModule == debugModule) - { + { // Fast remove mDeferredRefs[deferredIdx] = mDeferredRefs.back(); - mDeferredRefs.pop_back(); + mDeferredRefs.pop_back(); } else deferredIdx++; @@ -896,7 +896,7 @@ void DbgSrcFile::RemoveLines(DbgModule* debugModule) } void DbgSrcFile::RemoveLines(DbgModule* debugModule, DbgSubprogram* dbgSubprogram, bool isHotReplaced) -{ +{ debugModule->mDebugTarget->mPendingSrcFileRehup.Add(this); if (isHotReplaced) @@ -955,16 +955,16 @@ void DbgSrcFile::GetHash(String& outStr) DbgType::DbgType() { - mTypeIdx = -1; - mIsDeclaration = false; - mParent = NULL; + mTypeIdx = -1; + mIsDeclaration = false; + mParent = NULL; mTypeName = NULL; mTypeCode = DbgType_Null; - mSize = 0; + mSize = 0; mPtrType = NULL; mTypeParam = NULL; mBlockParam = NULL; - mNext = NULL; + mNext = NULL; mPriority = DbgTypePriority_Normal; } @@ -1009,7 +1009,7 @@ bool DbgType::Equals(DbgType* dbgType) } if ((mTypeParam != NULL) && (!mTypeParam->Equals(dbgType->mTypeParam))) return false; - + // Did mName already include the parent name? if (mCompileUnit->mDbgModule->mDbgFlavor == DbgFlavor_MS) return true; @@ -1027,7 +1027,7 @@ bool DbgType::IsStruct() } bool DbgType::IsPrimitiveType() -{ +{ return (mTypeCode >= DbgType_i8) && (mTypeCode <= DbgType_Bool); } @@ -1056,7 +1056,7 @@ bool DbgType::IsTypedPrimitive() PopulateType(); if (mTypeCode != DbgType_Struct) - return false; + return false; if (mTypeParam != NULL) return true; @@ -1067,7 +1067,7 @@ bool DbgType::IsTypedPrimitive() if (!baseType->IsTypedPrimitive()) return false; - + mTypeParam = baseType->mTypeParam; return true; } @@ -1130,7 +1130,7 @@ DbgExtType DbgType::CalcExtType() auto language = GetLanguage(); if ((!mFixedName) && (language == DbgLanguage_Beef)) { - FixName(); + FixName(); } auto primaryType = GetPrimaryType(); @@ -1173,7 +1173,7 @@ DbgExtType DbgType::CalcExtType() { for (auto member : mMemberList) { - if (strcmp(member->mName, "__bftag") == 0) + if ((member->mName != NULL) && (strcmp(member->mName, "__bftag") == 0)) return DbgExtType_BfPayloadEnum; } return DbgExtType_Normal; @@ -1182,7 +1182,7 @@ DbgExtType DbgType::CalcExtType() { for (auto member : mMemberList) { - if (strcmp(member->mName, "$bfunion") == 0) + if ((member->mName != NULL) && (strcmp(member->mName, "$bfunion") == 0)) return DbgExtType_BfUnion; } } @@ -1195,7 +1195,7 @@ DbgExtType DbgType::CalcExtType() } DbgLanguage DbgType::GetLanguage() -{ +{ return mLanguage; } @@ -1203,7 +1203,7 @@ void DbgType::FixName() { if (mFixedName) return; - + int depthCount = 0; auto dbgModule = mCompileUnit->mDbgModule; @@ -1260,14 +1260,14 @@ void DbgType::FixName() } bool DbgType::IsBfObject() -{ +{ if (mExtType == DbgExtType_Unknown) mExtType = CalcExtType(); return (mExtType == DbgExtType_BfObject) || (mExtType == DbgExtType_Interface); } bool DbgType::IsBfPayloadEnum() -{ +{ if (mExtType == DbgExtType_Unknown) mExtType = CalcExtType(); return mExtType == DbgExtType_BfPayloadEnum; @@ -1326,7 +1326,7 @@ bool DbgType::HasCPPVTable() }*/ if (mHasVTable) return true; - + if (GetLanguage() == DbgLanguage_Beef) return false; @@ -1368,7 +1368,7 @@ bool DbgType::IsRoot() bool DbgType::IsRef() { - return + return (mTypeCode == DbgType_Ref) || (mTypeCode == DbgType_RValueReference); } @@ -1449,46 +1449,46 @@ void DbgType::PopulateType() DbgModule* DbgType::GetDbgModule() { if (mCompileUnit == NULL) - return NULL; + return NULL; return mCompileUnit->mDbgModule; } DbgType* DbgType::GetPrimaryType() -{ +{ if (mPrimaryType != NULL) return mPrimaryType; mPrimaryType = this; if (mPriority <= DbgTypePriority_Normal) - { - if ((mCompileUnit != NULL) && - ((mCompileUnit->mLanguage == DbgLanguage_Beef)|| (mLanguage == DbgLanguage_Beef) || + { + if ((mCompileUnit != NULL) && + ((mCompileUnit->mLanguage == DbgLanguage_Beef)|| (mLanguage == DbgLanguage_Beef) || (mTypeCode == DbgType_Namespace) || (mIsDeclaration))) - { - mPrimaryType = mCompileUnit->mDbgModule->GetPrimaryType(this); + { + mPrimaryType = mCompileUnit->mDbgModule->GetPrimaryType(this); mPrimaryType->PopulateType(); mTypeCode = mPrimaryType->mTypeCode; mTypeParam = mPrimaryType->mTypeParam; } } - + return mPrimaryType; } DbgType* DbgType::GetBaseType() { auto primaryType = GetPrimaryType(); - if (primaryType != this) + if (primaryType != this) return primaryType->GetBaseType(); PopulateType(); if (mBaseTypes.mHead == NULL) - return NULL; + return NULL; if (GetLanguage() != DbgLanguage_Beef) return NULL; auto baseType = mBaseTypes.mHead->mBaseType; BF_ASSERT(!baseType->IsInterface()); - + if ((baseType == NULL) || (baseType->mPriority > DbgTypePriority_Normal)) return baseType; baseType = mCompileUnit->mDbgModule->GetPrimaryType(baseType); @@ -1504,7 +1504,7 @@ DbgType* DbgType::GetBaseType() if (baseType->ToString() == "System.Function") { DbgBaseTypeEntry* baseTypeEntry = mCompileUnit->mDbgModule->mAlloc.Alloc(); - baseTypeEntry->mBaseType = mCompileUnit->mDbgModule->GetPrimitiveType(DbgType_IntPtr_Alias, DbgLanguage_Beef); + baseTypeEntry->mBaseType = mCompileUnit->mDbgModule->GetPrimitiveType(DbgType_IntPtr_Alias, DbgLanguage_Beef); baseType->mBaseTypes.PushBack(baseTypeEntry); } } @@ -1526,7 +1526,7 @@ DbgType* DbgType::RemoveModifiers(bool* hadRef) { DbgType* dbgType = this; while (dbgType != NULL) - { + { bool curHadRef = (dbgType->mTypeCode == DbgType_Ref) || (dbgType->mTypeCode == DbgType_RValueReference); if ((curHadRef) && (hadRef != NULL)) *hadRef = true; @@ -1547,12 +1547,12 @@ DbgType* DbgType::RemoveModifiers(bool* hadRef) String DbgType::ToStringRaw(DbgLanguage language) { if (mTypeIdx != -1) - return StrFormat("_T_%d_%d", mCompileUnit->mDbgModule->GetLinkedModule()->mId, mTypeIdx); + return StrFormat("_T_%d_%d", mCompileUnit->mDbgModule->GetLinkedModule()->mId, mTypeIdx); return ToString(language); } void DbgType::ToString(StringImpl& str, DbgLanguage language, bool allowDirectBfObject, bool internalName) -{ +{ if (language == DbgLanguage_Unknown) language = GetLanguage(); @@ -1673,7 +1673,7 @@ void DbgType::ToString(StringImpl& str, DbgLanguage language, bool allowDirectBf } return; } - + //String combName; /*if (mTemplateParams != NULL) { @@ -1685,7 +1685,7 @@ void DbgType::ToString(StringImpl& str, DbgLanguage language, bool allowDirectBf if ((!mFixedName) /*&& (language == DbgLanguage_Beef)*/) { FixName(); - } + } char* nameP = (char*)mTypeName; if (parent == NULL) @@ -1708,20 +1708,20 @@ void DbgType::ToString(StringImpl& str, DbgLanguage language, bool allowDirectBf if ((internalName) && (parent->mTypeCode != DbgType_Namespace)) str += "+"; else - str += "."; + str += "."; str += nameP; } else - { + { parent->ToString(str, language, allowDirectBfObject, internalName); if ((internalName) && (parent->mTypeCode != DbgType_Namespace)) str += "+"; else - str += "::"; + str += "::"; str += nameP; } return; - } + } switch (mTypeCode) { @@ -1900,7 +1900,7 @@ void DbgType::ToString(StringImpl& str, DbgLanguage language, bool allowDirectBf str += "void"; return; case DbgType_Subroutine: - { + { mTypeParam->ToString(str, language, allowDirectBfObject, internalName); str += " ("; int paramIdx = 0; @@ -1953,7 +1953,7 @@ String DbgType::ToString(DbgLanguage language, bool allowDirectBfObject) intptr DbgType::GetByteCount() -{ +{ if (!mSizeCalculated) { PopulateType(); @@ -1970,7 +1970,7 @@ intptr DbgType::GetByteCount() { mSize = primaryType->GetByteCount(); mAlign = primaryType->mAlign; - } + } } } else if ((mTypeCode == DbgType_Ref) || (mTypeCode == DbgType_Ptr) || (mTypeCode == DbgType_PtrToMember)) @@ -2019,7 +2019,7 @@ intptr DbgType::GetStride() } int DbgType::GetAlign() -{ +{ if (mAlign == 0) { auto primaryType = GetPrimaryType(); @@ -2033,8 +2033,8 @@ int DbgType::GetAlign() } if (mAlign != 0) - return mAlign; - return 1; + return mAlign; + return 1; } void DbgType::EnsureMethodsMapped() @@ -2086,7 +2086,7 @@ void DbgType::EnsureMethodsMapped() DbgModule::DbgModule(DebugTarget* debugTarget) : mDefaultCompileUnit(this) { - mMemReporter = NULL; + mMemReporter = NULL; mLoadState = DbgModuleLoadState_NotLoaded; mMappedImageFile = NULL; @@ -2130,12 +2130,12 @@ DbgModule::DbgModule(DebugTarget* debugTarget) : mDefaultCompileUnit(this) CREATE_PRIMITIVE(DbgType_SChar16, "wchar_t", "wchar", "System.Char16", wchar_t); CREATE_PRIMITIVE(DbgType_i8, "int8_t", "int8", "System.SByte", int8); CREATE_PRIMITIVE(DbgType_i16, "short", "int16", "System.Int16", int16); - CREATE_PRIMITIVE(DbgType_i32, "int", "int32", "System.Int32", int32); - CREATE_PRIMITIVE(DbgType_i64, "int64_t", "int64", "System.Int64", int64); + CREATE_PRIMITIVE(DbgType_i32, "int", "int32", "System.Int32", int32); + CREATE_PRIMITIVE(DbgType_i64, "int64_t", "int64", "System.Int64", int64); CREATE_PRIMITIVE(DbgType_u8, "uint8_t", "uint8", "System.UInt8", uint8); CREATE_PRIMITIVE(DbgType_u16, "uint16_t", "uint16", "System.UInt16", uint16); - CREATE_PRIMITIVE(DbgType_u32, "uint32_t", "uint32", "System.UInt32", uint32); + CREATE_PRIMITIVE(DbgType_u32, "uint32_t", "uint32", "System.UInt32", uint32); CREATE_PRIMITIVE(DbgType_u64, "uint64_t", "uint64", "System.UInt64", uint64); CREATE_PRIMITIVE(DbgType_Single, "float", "float", "System.Single", float); @@ -2150,7 +2150,7 @@ DbgModule::DbgModule(DebugTarget* debugTarget) : mDefaultCompileUnit(this) CREATE_PRIMITIVE(DbgType_RawText, "@RawText", "@RawText", "@RawText", bool); CREATE_PRIMITIVE(DbgType_RegGroup, "@RegGroup", "@RegGroup", "@RegGroup", void*); - + CREATE_PRIMITIVE_C(DbgType_i16, "int16_t", int16_t); CREATE_PRIMITIVE_C(DbgType_i32, "int32_t", int32_t); CREATE_PRIMITIVE_C(DbgType_i64, "__int64", int64); @@ -2161,7 +2161,7 @@ DbgModule::DbgModule(DebugTarget* debugTarget) : mDefaultCompileUnit(this) CREATE_PRIMITIVE_C(DbgType_u32, "unsigned int", uint32); CREATE_PRIMITIVE_C(DbgType_u32, "unsigned int32_t", uint32_t); CREATE_PRIMITIVE_C(DbgType_u32, "unsigned long", uint32); - CREATE_PRIMITIVE_C(DbgType_u64, "unsigned int64_t", uint64); + CREATE_PRIMITIVE_C(DbgType_u64, "unsigned int64_t", uint64); } mIsDwarf64 = false; @@ -2173,15 +2173,15 @@ DbgModule::DbgModule(DebugTarget* debugTarget) : mDefaultCompileUnit(this) mDebugLineData = NULL; mDebugInfoData = NULL; mDebugPubNames = NULL; - mDebugFrameAddress = 0; + mDebugFrameAddress = 0; mDebugFrameData = NULL; mDebugLocationData = NULL; mDebugRangesData = NULL; mDebugAbbrevData = NULL; - mDebugStrData = NULL; - mDebugAbbrevPtrData = NULL; + mDebugStrData = NULL; + mDebugAbbrevPtrData = NULL; mEHFrameData = NULL; - mEHFrameAddress = 0; + mEHFrameAddress = 0; mStringTable = NULL; mSymbolData = NULL; mCheckedBfObject = false; @@ -2192,17 +2192,17 @@ DbgModule::DbgModule(DebugTarget* debugTarget) : mDefaultCompileUnit(this) mHotIdx = 0; mId = 0; mStartSubprogramIdx = 0; - mEndSubprogramIdx = 0; + mEndSubprogramIdx = 0; mCodeAddress = NULL; - mMayBeOld = false; + mMayBeOld = false; mTimeStamp = 0; mExpectedFileSize = 0; mBfTypeType = NULL; mBfTypesInfoAddr = 0; - + mImageBase = 0; mPreferredImageBase = 0; - mImageSize = 0; + mImageSize = 0; mOrigImageData = NULL; mDeleting = false; @@ -2224,14 +2224,14 @@ DbgModule::DbgModule(DebugTarget* debugTarget) : mDefaultCompileUnit(this) } DbgModule::~DbgModule() -{ +{ delete mMemReporter; for (auto dwSrcFile : mEmptySrcFiles) delete dwSrcFile; for (auto dwCompileUnit : mCompileUnits) - delete dwCompileUnit; - + delete dwCompileUnit; + delete mSymbolData; delete mStringTable; delete mDebugLineData; @@ -2242,11 +2242,11 @@ DbgModule::~DbgModule() delete mDebugRangesData; delete mDebugAbbrevData; delete mDebugAbbrevPtrData; - delete mDebugStrData; + delete mDebugStrData; for (auto entry : mExceptionDirectory) delete entry.mData; delete mEHFrameData; - + delete mOrigImageData; if ((IsObjectFile()) && (mImageBase != 0)) @@ -2263,7 +2263,7 @@ DbgSubprogram* DbgModule::FindSubprogram(DbgType* dbgType, const char * methodNa dbgType = dbgType->GetPrimaryType(); dbgType->PopulateType(); - if (dbgType->mNeedsGlobalsPopulated) + if (dbgType->mNeedsGlobalsPopulated) PopulateTypeGlobals(dbgType); for (auto methodNameEntry : dbgType->mMethodNameList) @@ -2306,7 +2306,7 @@ void DbgModule::Fail(const StringImpl& error) errorStr += mFilePath; errorStr += ": "; } - errorStr += error; + errorStr += error; errorStr += "\n"; mDebugger->OutputRawMessage(errorStr); @@ -2360,7 +2360,7 @@ char* DbgModule::DbgDupString(const char* str, const char* allocName) { int strLen = (int)strlen(str); if (strLen == 0) - return NULL; + return NULL; char* dupStr = (char*)mAlloc.AllocBytes(strLen + 1, (allocName != NULL) ? allocName : "DbgDupString"); memcpy(dupStr, str, strLen); return dupStr; @@ -2425,8 +2425,8 @@ void DbgModule::PopulateStaticVariableMap() return; for (auto staticVariable : mStaticVariables) - { - mStaticVariableMap[staticVariable->GetMappedName()] = staticVariable; + { + mStaticVariableMap[staticVariable->GetMappedName()] = staticVariable; } mPopulatedStaticVariables = true; @@ -2444,7 +2444,7 @@ addr_target DbgModule::RemapAddr(addr_target addr) } void DbgModule::ParseAbbrevData(const uint8* data) -{ +{ while (true) { int abbrevIdx = (int)DecodeULEB128(data); @@ -2599,7 +2599,7 @@ T DbgModule::ReadValue(const uint8*& data, int form, int refOffset, const uint8* else offset = GET(int32); if (extraData != NULL) - { + { *extraData = mDebugLocationData + offset; return 0; } @@ -2615,10 +2615,10 @@ T DbgModule::ReadValue(const uint8*& data, int form, int refOffset, const uint8* { int64_t exprLen = DecodeULEB128(data); const uint8* endData = data + exprLen; - + if (extraData != NULL) *extraData = data; - + data = endData; return (T)exprLen; } @@ -2636,7 +2636,7 @@ T DbgModule::ReadValue(const uint8*& data, int form, int refOffset, const uint8* } break; case DW_FORM_sdata: - return (T)DecodeSLEB128(data); + return (T)DecodeSLEB128(data); case DW_FORM_udata: return (T)DecodeULEB128(data); case DW_FORM_string: @@ -2648,17 +2648,17 @@ T DbgModule::ReadValue(const uint8*& data, int form, int refOffset, const uint8* data++; if (val == 0) return (T)(intptr)str; - } + } } case DW_FORM_block: - { + { int blockLen = (int)DecodeULEB128(data); const uint8* retVal = data; data += blockLen; return (T)(intptr)retVal; } case DW_FORM_block1: - { + { int blockLen = (int)*((uint8*)data); data += sizeof(uint8); const uint8* retVal = data; @@ -2677,16 +2677,16 @@ T DbgModule::ReadValue(const uint8*& data, int form, int refOffset, const uint8* static int gAbbrevNum = 0; DbgType* DbgModule::GetOrCreateType(int typeIdx, DbgDataMap& dataMap) -{ +{ if (typeIdx == 0) return NULL; DbgModule* linkedModule = GetLinkedModule(); DbgType* dbgType = dataMap.Get(typeIdx); if (dbgType != NULL) return dbgType; - dbgType = mAlloc.Alloc(); - dbgType->mTypeIdx = (int)linkedModule->mTypes.size(); - linkedModule->mTypes.push_back(dbgType); + dbgType = mAlloc.Alloc(); + dbgType->mTypeIdx = (int)linkedModule->mTypes.size(); + linkedModule->mTypes.push_back(dbgType); dataMap.Set(typeIdx, dbgType); return dbgType; } @@ -2696,7 +2696,7 @@ typedef llvm::SmallVector DataStack; template T DbgModule::GetOrCreate(int idx, DbgDataMap& dataMap) -{ +{ if (idx == 0) return NULL; T val = dataMap.Get(idx); @@ -2724,9 +2724,9 @@ DbgBlock* GetStackTop(DataStack* dataStack) if (dataPair.first == DbgBlock::ClassType) return (DbgBlock*)dataPair.second; if (dataPair.first == DbgSubprogram::ClassType) - return &((DbgSubprogram*)dataPair.second)->mBlock; + return &((DbgSubprogram*)dataPair.second)->mBlock; if (dataPair.first == DbgType::ClassType) - return ((DbgType*)dataPair.second)->mBlockParam; + return ((DbgType*)dataPair.second)->mBlockParam; return NULL; } @@ -2743,7 +2743,7 @@ template static T GetStackLast(DataStack* dataStack) { for (int i = (int)dataStack->size() - 1; i >= 0; i--) - { + { if ((*dataStack)[i].first == RemoveTypePointer::type::ClassType) return (T)(*dataStack)[i].second; } @@ -2764,7 +2764,7 @@ void DbgModule::FixupInnerTypes(int startingTypeIdx) { DbgType* dbgType = mTypes[typeIdx]; - if ((dbgType->mPriority == DbgTypePriority_Primary_Implicit) && (dbgType->mParent != NULL) && (dbgType->mParent->mTypeCode != DbgType_Namespace) && + if ((dbgType->mPriority == DbgTypePriority_Primary_Implicit) && (dbgType->mParent != NULL) && (dbgType->mParent->mTypeCode != DbgType_Namespace) && (dbgType->mParent->mPriority <= DbgTypePriority_Primary_Implicit)) { auto primaryParent = dbgType->mParent->GetPrimaryType(); @@ -2779,16 +2779,16 @@ void DbgModule::FixupInnerTypes(int startingTypeIdx) void DbgModule::MapTypes(int startingTypeIdx) { BP_ZONE("DbgModule_MapTypes"); - - bool needsInnerFixups = false; + + bool needsInnerFixups = false; for (int typeIdx = startingTypeIdx; typeIdx < (int)mTypes.size(); typeIdx++) { DbgType* dbgType = mTypes[typeIdx]; BF_ASSERT(dbgType->mTypeCode != DbgType_Null); - + if ((dbgType->mTypeCode == DbgType_Namespace) && (dbgType->mPriority < DbgTypePriority_Primary_Implicit)) - continue; - + continue; + //TODO: Always valid? if (dbgType->mIsDeclaration) continue; @@ -2798,7 +2798,7 @@ void DbgModule::MapTypes(int startingTypeIdx) if ((dbgType->mTypeName == NULL) || (dbgType->mName == NULL) /*|| (dbgType->mTypeName[0] == '<')*/) continue; - if (dbgType->mTypeCode > DbgType_DefinitionEnd) + if (dbgType->mTypeCode > DbgType_DefinitionEnd) { // Only add "definition types" continue; @@ -2820,7 +2820,7 @@ void DbgModule::MapTypes(int startingTypeIdx) if ((member->mIsStatic) && (member->mLocationData != NULL)) dbgType->mDefinedMembersSize++; } - + if ((dbgType->mTypeName != NULL) && (strcmp(dbgType->mTypeName, "@") == 0)) { // Globals type. @@ -2860,7 +2860,7 @@ void DbgModule::MapTypes(int startingTypeIdx) prevTypeEntry->mValue = dbgType; } continue; - } + } // Don't replace a ptr to an BfObject with a BfObject if ((prevType->mTypeCode == DbgType_Ptr) && (dbgType->mTypeCode == DbgType_Struct)) @@ -2871,19 +2871,19 @@ void DbgModule::MapTypes(int startingTypeIdx) // Allow this to override prevTypeEntry->mValue = dbgType; continue; - } + } if (prevType->mTypeCode == DbgType_Namespace) - { + { if (dbgType->mTypeCode != DbgType_Namespace) { - // Old type was namespace but new isn't? Replace old type. + // Old type was namespace but new isn't? Replace old type. while (!prevType->mSubTypeList.IsEmpty()) { DbgType* subType = prevType->mSubTypeList.PopFront(); subType->mParent = dbgType; dbgType->mSubTypeList.PushBack(subType); - } + } prevType->mPriority = DbgTypePriority_Normal; if (dbgType->mPriority < DbgTypePriority_Primary_Implicit) dbgType->mPriority = DbgTypePriority_Primary_Implicit; @@ -2905,13 +2905,13 @@ void DbgModule::MapTypes(int startingTypeIdx) continue; if (!prevType->mIsDeclaration) - { + { if ((prevType->mCompileUnit == NULL) || (dbgType->mLanguage < prevType->mLanguage)) { // We always want 'Beef' types to supersede 'C' types, but don't override the built-in primitive types continue; } - + if (prevType->mDefinedMembersSize > 0) { if (dbgType->mDefinedMembersSize > 0) @@ -2973,8 +2973,8 @@ void DbgModule::CreateNamespaces() for (int typeIdx = 0; typeIdx < startLength; typeIdx++) { - DbgType* dbgType = mTypes[typeIdx]; - + DbgType* dbgType = mTypes[typeIdx]; + if (dbgType->mName == NULL) continue; @@ -3005,14 +3005,14 @@ void DbgModule::CreateNamespaces() mTypes.push_back(namespaceType); mTypeMap.Insert(namespaceType); - } + } else namespaceType = namespaceTypeEntry->mValue; - + while (!dbgType->mMemberList.IsEmpty()) - { + { DbgVariable* curVar = dbgType->mMemberList.PopFront(); - namespaceType->mMemberList.PushBack(curVar); + namespaceType->mMemberList.PushBack(curVar); } DbgType* prevType = NULL; @@ -3033,7 +3033,7 @@ void DbgModule::CreateNamespaces() continue; } - } + } // If we didn't have a parent type for a namespace (ie: if System.Collections wasn't linked to System) then we wait // until the end and move those from the global list to the parent list @@ -3042,7 +3042,7 @@ void DbgModule::CreateNamespaces() DbgType* dbgType = mTypes[typeIdx]; if (dbgType->mParent != NULL) continue; - + char* typeName = (char*)dbgType->mTypeName; int lastDotIdx = -1; for (int i = 0; true; i++) @@ -3063,7 +3063,7 @@ void DbgModule::CreateNamespaces() if (parentEntry == NULL) continue; - auto parentType = parentEntry->mValue; + auto parentType = parentEntry->mValue; dbgType->mCompileUnit->mGlobalType->mSubTypeList.Remove(dbgType); dbgType->mParent = parentType; parentType->mSubTypeList.PushBack(dbgType); @@ -3083,7 +3083,7 @@ void DbgModule::FindTemplateStr(const char*& name, int& templateNameIdx) } } templateNameIdx = -1; - } + } } void DbgModule::TempRemoveTemplateStr(const char*& name, int& templateNameIdx) @@ -3091,7 +3091,7 @@ void DbgModule::TempRemoveTemplateStr(const char*& name, int& templateNameIdx) if (templateNameIdx == 0) FindTemplateStr(name, templateNameIdx); if (templateNameIdx == -1) - return; + return; if (!DbgIsStrMutable(name)) name = DbgDupString(name); @@ -3106,7 +3106,7 @@ void DbgModule::ReplaceTemplateStr(const char*& name, int& templateNameIdx) } void DbgModule::MapSubprogram(DbgSubprogram* dbgSubprogram) -{ +{ if (dbgSubprogram->mBlock.IsEmpty()) return; @@ -3116,11 +3116,11 @@ void DbgModule::MapSubprogram(DbgSubprogram* dbgSubprogram) int curSize = progSize - progOffset; if (curSize <= 0) break; - + BP_ALLOC_T(DbgSubprogramMapEntry); DbgSubprogramMapEntry* subprogramMapEntry = mAlloc.Alloc(); subprogramMapEntry->mAddress = dbgSubprogram->mBlock.mLowPC + progOffset; - subprogramMapEntry->mEntry = dbgSubprogram; + subprogramMapEntry->mEntry = dbgSubprogram; mDebugTarget->mSubprogramMap.Insert(subprogramMapEntry); } } @@ -3134,7 +3134,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) int dataOfs = (int)(data - mDebugInfoData); intptr_target length = GET(int); - + DbgModule* linkedModule = GetLinkedModule(); if (length == -1) @@ -3158,20 +3158,20 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) mDbgFlavor = DbgFlavor_GNU; compileUnit->mDbgModule = this; mCompileUnits.push_back(compileUnit); - - DbgSubprogram* subProgram = NULL; - + + DbgSubprogram* subProgram = NULL; + //std::map typeMap; //std::map subprogramMap; int tagStart = (int)(data - startData); int tagEnd = (int)(dataEnd - startData); DbgDataMap dataMap(tagStart, tagEnd); - DataStack dataStack; + DataStack dataStack; Array abstractOriginReplaceList; - - Array deferredArrayDims; - int startingTypeIdx = (int)linkedModule->mTypes.size(); + Array deferredArrayDims; + + int startingTypeIdx = (int)linkedModule->mTypes.size(); while (data < dataEnd) { @@ -3179,29 +3179,29 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) const uint8* tagDataStart = data; int tagIdx = (int)(tagDataStart - startData); - + int abbrevIdx = (int)DecodeULEB128(data); const uint8* abbrevData = mDebugAbbrevPtrData[abbrevIdx]; - - if (abbrevIdx == 0) + + if (abbrevIdx == 0) { if (deferredArrayDims.size() > 0) - { + { DbgType* arrType = GetStackTop(&dataStack); BF_ASSERT(arrType->mTypeCode == DbgType_SizedArray); arrType->mSize = deferredArrayDims[0]; // Byte count still needs to be multiplied by the underlying type size - - DbgType* rootArrType = arrType; + + DbgType* rootArrType = arrType; for (int dimIdx = 0; dimIdx < (int)deferredArrayDims.size() - 1; dimIdx++) { int dimSize = deferredArrayDims[dimIdx]; - + DbgType* subArrType = mAlloc.Alloc(); subArrType->mCompileUnit = compileUnit; subArrType->mLanguage = compileUnit->mLanguage; subArrType->mTypeIdx = (int)linkedModule->mTypes.size(); linkedModule->mTypes.push_back(subArrType); - + subArrType->mTypeCode = DbgType_SizedArray; subArrType->mTypeParam = arrType->mTypeParam; subArrType->mSize = deferredArrayDims[dimIdx + 1]; @@ -3213,12 +3213,12 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) deferredArrayDims.Clear(); } - dataStack.pop_back(); + dataStack.pop_back(); continue; } - + int entryTag = (int) DecodeULEB128(abbrevData); - bool hasChildren = GET_FROM(abbrevData, char) == DW_CHILDREN_yes; + bool hasChildren = GET_FROM(abbrevData, char) == DW_CHILDREN_yes; int64 atLowPC = 0; int64 atHighPC = 0; @@ -3232,13 +3232,13 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) const char* atName = NULL; const char* atCompDir = NULL; const char* atLinkageName = NULL; - int64 atConstValue = 0; + int64 atConstValue = 0; int atDataMemberLocation = 0; const uint8* atDataMemberData = NULL; int atDeclFile = 0; int atDeclLine = 0; int atCallFile = 0; - int atCallLine = 0; + int atCallLine = 0; int atCount = 0; int atType = 0; int atImport = 0; @@ -3252,9 +3252,9 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) int atBitOffset = 0; int atBitSize = 0; int atAbstractOrigin = 0; - const uint8* atVirtualLocData = NULL; + const uint8* atVirtualLocData = NULL; bool atDeclaration = false; - bool atVirtual = false; + bool atVirtual = false; bool hadConstValue = false; bool hadMemberLocation = false; bool isOptimized = false; @@ -3277,7 +3277,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) atLocationLen = (int)ReadValue(data, form, dataOfs, &atLocationData, startData); break; case DW_AT_name: - atName = ReadValue(data, form); + atName = ReadValue(data, form); break; case DW_AT_ordering: /*TODO:*/ ReadValue(data, form); @@ -3344,7 +3344,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) /*TODO:*/ ReadValue(data, form); break; case DW_AT_producer: - atProducer = ReadValue(data, form); + atProducer = ReadValue(data, form); break; case DW_AT_prototyped: /*TODO:*/ ReadValue(data, form); @@ -3386,7 +3386,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) case DW_AT_data_member_location: if (form == DW_FORM_exprloc) { - atDataMemberLocation = (int)ReadValue(data, form, dataOfs, &atDataMemberData); + atDataMemberLocation = (int)ReadValue(data, form, dataOfs, &atDataMemberData); hadMemberLocation = true; } else @@ -3561,7 +3561,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) // case DW_AT_MIPS_linkage_name: - atLinkageName = ReadValue(data, form); + atLinkageName = ReadValue(data, form); break; case DW_AT_APPLE_optimized: @@ -3586,7 +3586,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) if (compileUnit->mLowPC != (addr_target)-1) { - // These are sometimes relative to the compile unit and sometimes absolute + // These are sometimes relative to the compile unit and sometimes absolute if (highPC + compileUnit->mLowPC <= compileUnit->mHighPC) { lowPC += compileUnit->mLowPC; @@ -3609,11 +3609,11 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) if (highPC > (addr_target)atHighPC) atHighPC = highPC;*/ } - + } switch (entryTag) - { + { case DW_TAG_compile_unit: { newDataPair = MakeDataPair(compileUnit); @@ -3632,7 +3632,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) } else { - compileUnit->mLanguage = DbgLanguage_C; + compileUnit->mLanguage = DbgLanguage_C; } compileUnit->mGlobalType->mLanguage = compileUnit->mLanguage; } @@ -3640,23 +3640,23 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) case DW_TAG_imported_module: { DbgType* parentType = GetStackTop(&dataStack); - DbgType* importType = GetOrCreateType(atImport, dataMap); + DbgType* importType = GetOrCreateType(atImport, dataMap); if (parentType != NULL) // Parent type is NULL for Clang DbgModule info parentType->mUsingNamespaces.PushFront(importType, &mAlloc); } break; - case DW_TAG_inlined_subroutine: - case DW_TAG_subprogram: - { + case DW_TAG_inlined_subroutine: + case DW_TAG_subprogram: + { /*//TODO: This is a test. See if it breaks anything. if ((atExternal != 0) && (atLowPC == 0)) break;*/ if (atSpecification == 0) - { + { subProgram = GetOrCreate(tagIdx, dataMap); - subProgram->mCompileUnit = compileUnit; + subProgram->mCompileUnit = compileUnit; subProgram->mVirtual = atVirtual; subProgram->mIsOptimized = isOptimized; @@ -3670,19 +3670,19 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) } //subProgram->mVTableLoc = atVirtualLoc * sizeof(addr_target); - //SplitName(atName, subProgram->mName, subProgram->mTemplateName); + //SplitName(atName, subProgram->mName, subProgram->mTemplateName); subProgram->mName = atName; - subProgram->mLinkName = atLinkageName; + subProgram->mLinkName = atLinkageName; if (atAbstractOrigin != NULL) { - DbgSubprogram* originSubProgram = GetOrCreate(atAbstractOrigin, dataMap); - auto abstractOriginEntry = AbstractOriginEntry::Create(DbgSubprogram::ClassType, subProgram, originSubProgram); + DbgSubprogram* originSubProgram = GetOrCreate(atAbstractOrigin, dataMap); + auto abstractOriginEntry = AbstractOriginEntry::Create(DbgSubprogram::ClassType, subProgram, originSubProgram); abstractOriginReplaceList.push_back(abstractOriginEntry); } - subProgram->mParentType = GetStackTop(&dataStack); - newDataPair = MakeDataPair(subProgram); - + subProgram->mParentType = GetStackTop(&dataStack); + newDataPair = MakeDataPair(subProgram); + //if ((atLinkageName != NULL) && (subProgram->mParentType != NULL)) //subProgram->mParentType->mDefinedMembersCount++; @@ -3695,21 +3695,21 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) else { compileUnit->mGlobalType->mMethodList.PushBack(subProgram); - } + } } else { - subProgram = dataMap.Get(atSpecification); + subProgram = dataMap.Get(atSpecification); BF_ASSERT(subProgram != NULL); // We remove params form the declaration and re-add the real ones here subProgram->mParams.Clear(); - } - + } + newDataPair = MakeDataPair(subProgram); DbgBlock* dwBlock = &subProgram->mBlock; - + if (atType != 0) - subProgram->mReturnType = GetOrCreateType(atType, dataMap); + subProgram->mReturnType = GetOrCreateType(atType, dataMap); if (!atDeclaration) { @@ -3726,10 +3726,10 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) subProgram->mHasThis = true; subProgram->mFrameBaseLen = (int)atFrameBaseLength; subProgram->mFrameBaseData = atFrameBase; - + if (atHighPC > 0) { - MapSubprogram(subProgram); + MapSubprogram(subProgram); } } @@ -3738,11 +3738,11 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) DbgSubprogram* parentSubProgram = GetStackLast(&dataStack); subProgram->mInlineeInfo = mAlloc.Alloc(); subProgram->mInlineeInfo->mInlineParent = parentSubProgram; - subProgram->mInlineeInfo->mRootInliner = parentSubProgram->GetRootInlineParent(); + subProgram->mInlineeInfo->mRootInliner = parentSubProgram->GetRootInlineParent(); subProgram->mFrameBaseData = parentSubProgram->mFrameBaseData; subProgram->mFrameBaseLen = parentSubProgram->mFrameBaseLen; } - + //if (subProgram->mParentType != NULL) //subProgram->mParentType->mDefinedMembersCount++; } @@ -3761,12 +3761,12 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) dwBlock->mLowPC = (addr_target)atLowPC; dwBlock->mHighPC = (addr_target)(atLowPC + atHighPC); } - newDataPair = MakeDataPair(dwBlock); + newDataPair = MakeDataPair(dwBlock); prevBlock->mSubBlocks.PushBack(dwBlock); } break; - case DW_TAG_variable: - { + case DW_TAG_variable: + { DbgBlock* dwBlock = GetStackTop(&dataStack); if (atName && !strncmp(atName, "__asmLines", 10)) @@ -3801,7 +3801,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) { s += *ptr; } - + //int asmLine = atoi(s.c_str()); //asmLines.push_back(asmLine); const char* sPtr = s.c_str(); @@ -3849,18 +3849,18 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) bool isNewVariable = true; DbgVariable* dbgVariable = NULL; if (atSpecification != 0) - { - //dbgVariable = dataMap.Get(atSpecification); + { + //dbgVariable = dataMap.Get(atSpecification); //BF_ASSERT(dbgVariable != NULL); dbgVariable = GetOrCreate(atSpecification, dataMap); //dbgVariable = dataMap.Get(atSpecification); - //BF_ASSERT(dbgVariable != NULL); + //BF_ASSERT(dbgVariable != NULL); } else if (dwBlock != NULL) - { + { dbgVariable = GetOrCreate(tagIdx, dataMap); - dwBlock->mVariables.PushBack(dbgVariable); + dwBlock->mVariables.PushBack(dbgVariable); } else { @@ -3900,9 +3900,9 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) if (dbgType != NULL) { BF_ASSERT(dbgType->IsNamespace() || (dbgType->mTypeCode == DbgType_Root)); - + if (isNewVariable) - dbgType->mMemberList.PushBack(dbgVariable); + dbgType->mMemberList.PushBack(dbgVariable); } } @@ -3911,7 +3911,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) if (atSpecification == 0) { dbgVariable->mIsParam = false; - dbgVariable->mName = atName; + dbgVariable->mName = atName; dbgVariable->mConstValue = atConstValue; dbgVariable->mType = GetOrCreateType(atType, dataMap); dbgVariable->mIsConst = hadConstValue; @@ -3922,16 +3922,16 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) dbgVariable->mLinkName = atLinkageName; dbgVariable->mLocationLen = (int8)atLocationLen; dbgVariable->mLocationData = atLocationData; - dbgVariable->mCompileUnit = compileUnit; + dbgVariable->mCompileUnit = compileUnit; /*if (dbgVariable->mIsStatic && !dbgVariable->mIsConst && (dbgVariable->mLocationLen > 0) && (dbgVariable->mIsExtern)) { DbgAddrType addrType = DbgAddrType_Value; - // + // addr_target valAddr = mDebugTarget->EvaluateLocation(dbgVariable->mCompileUnit->mDbgModule, NULL, dbgVariable->mLocationData, dbgVariable->mLocationLen, NULL, &addrType); if ((addrType == DbgAddrType_Target) && (valAddr != 0)) { - dbgVariable->mStaticCachedAddr = valAddr; + dbgVariable->mStaticCachedAddr = valAddr; if (dbgVariable->mLinkName != NULL) mStaticVariables.push_back(dbgVariable); } @@ -3951,7 +3951,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) abstractOriginReplaceList.push_back(abstractOriginEntry); } else if (dbgVariable->mName == NULL) - dbgVariable->mName = "_unnamed"; + dbgVariable->mName = "_unnamed"; if (addToGlobalVarMap) mGlobalVarMap.Insert(dbgVariable); @@ -3978,13 +3978,13 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) break; } - + if ((dwSubprogram->mParams.IsEmpty()) && (dwSubprogram->mParentType != 0)) - dwSubprogram->mParentType->mMethodsWithParamsCount++; + dwSubprogram->mParentType->mMethodsWithParamsCount++; //DbgVariable* dbgVariable = mAlloc.Alloc(); DbgVariable* dwVariable = GetOrCreate(tagIdx, dataMap); - dwSubprogram->mParams.PushBack(dwVariable); + dwSubprogram->mParams.PushBack(dwVariable); if (atArtificial != 0) { @@ -3995,15 +3995,15 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) dwVariable->mCompileUnit = compileUnit; dwVariable->mIsParam = true; - dwVariable->mName = atName; + dwVariable->mName = atName; dwVariable->mLocationLen = (int)atLocationLen; dwVariable->mLocationData = atLocationData; dwVariable->mType = GetOrCreateType(atType, dataMap); if (atAbstractOrigin != 0) { - - } + + } } break; case DW_TAG_enumerator: @@ -4011,16 +4011,16 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) DbgVariable* member = mAlloc.Alloc(); member->mCompileUnit = compileUnit; member->mConstValue = atConstValue; - member->mName = atName; + member->mName = atName; member->mIsStatic = true; member->mIsConst = true; - DbgType* parentType = GetStackTop(&dataStack); + DbgType* parentType = GetStackTop(&dataStack); parentType->mMemberList.PushBack(member); member->mMemberOffset = atDataMemberLocation; //member->mType = parentType->mTypeParam; member->mType = parentType; - + // Insert into parent's namespace auto prevTop = dataStack.back(); dataStack.pop_back(); @@ -4030,12 +4030,12 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) if (dwBlock != NULL) { DbgVariable* dwVariable = mAlloc.Alloc(); - dwBlock->mVariables.PushBack(dwVariable); + dwBlock->mVariables.PushBack(dwVariable); if (atSpecification == 0) { dwVariable->mIsParam = false; - dwVariable->mName = atName; + dwVariable->mName = atName; dwVariable->mConstValue = atConstValue; dwVariable->mType = parentType->mTypeParam; dwVariable->mIsConst = hadConstValue; @@ -4061,7 +4061,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) { DbgType* derivedType = GetStackTop(&dataStack); DbgBaseTypeEntry* baseTypeEntry = mAlloc.Alloc(); - baseTypeEntry->mBaseType = GetOrCreateType(atType, dataMap); + baseTypeEntry->mBaseType = GetOrCreateType(atType, dataMap); if (atDataMemberData != NULL) { bool foundVirtOffset = false; @@ -4069,7 +4069,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) if (*(opPtr++) == DW_OP_dup) { if (*(opPtr++) == DW_OP_deref) - { + { if (*(opPtr++) == DW_OP_constu) { baseTypeEntry->mVTableOffset = (int)DecodeSLEB128(opPtr) / sizeof(int32); @@ -4078,19 +4078,19 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) if (*(opPtr++) == DW_OP_minus) baseTypeEntry->mVTableOffset = -baseTypeEntry->mVTableOffset; } - } + } } - + BF_ASSERT(foundVirtOffset); } else baseTypeEntry->mThisOffset = atDataMemberLocation; - derivedType->mBaseTypes.PushBack(baseTypeEntry); + derivedType->mBaseTypes.PushBack(baseTypeEntry); } break; case DW_TAG_member: { - DbgType* parentType = GetStackTop(&dataStack); + DbgType* parentType = GetStackTop(&dataStack); if ((atName != NULL) && (strncmp(atName, "_vptr$", 6) == 0)) { @@ -4101,7 +4101,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) DbgVariable* member = GetOrCreate(tagIdx, dataMap); member->mIsMember = true; member->mCompileUnit = compileUnit; - member->mName = atName; + member->mName = atName; member->mType = GetOrCreateType(atType, dataMap); member->mConstValue = atConstValue; member->mIsConst = hadConstValue; @@ -4109,10 +4109,10 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) member->mBitSize = atBitSize; member->mBitOffset = atBitOffset; member->mIsExtern = atExternal != 0; - + parentType->mMemberList.PushBack(member); member->mMemberOffset = atDataMemberLocation; - + if ((member->mIsStatic) && (!member->mIsConst)) parentType->mHasStaticMembers = true; @@ -4129,7 +4129,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) DbgType* parentType = GetStackTop(&dataStack); int arrSize = atCount; - deferredArrayDims.push_back(arrSize); + deferredArrayDims.push_back(arrSize); } break; @@ -4142,7 +4142,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) case DW_TAG_reference_type: case DW_TAG_rvalue_reference_type: case DW_TAG_unspecified_type: - case DW_TAG_class_type: + case DW_TAG_class_type: case DW_TAG_enumeration_type: case DW_TAG_structure_type: case DW_TAG_union_type: @@ -4152,7 +4152,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) //case DW_TAG_subrange_type: case DW_TAG_restrict_type: { - int typeIdx = (int)(tagDataStart - startData); + int typeIdx = (int)(tagDataStart - startData); DbgType* dbgType = GetOrCreateType(typeIdx, dataMap); const char* nameSep = (compileUnit->mLanguage == DbgLanguage_Beef) ? "." : "::"; @@ -4164,7 +4164,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) { BF_ASSERT(dbgType->mTypeCode == DbgType_Null); DbgType* parentType = GetStackTop(&dataStack); - + if (parentType != NULL) { dbgType->mParent = parentType; @@ -4196,7 +4196,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) compileUnit->mGlobalType->mSubTypeList.PushBack(dbgType); } } - + const char* useName = atName; /*if ((useName != NULL) && (strcmp(useName, "@") == 0)) useName = NULL;*/ @@ -4214,9 +4214,9 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) int typeNameLen = (dbgType->mTypeName != NULL) ? (int)strlen(dbgType->mTypeName) : 0; //int templateParamsLen = (dbgType->mTemplateParams != NULL) ? strlen(dbgType->mTemplateParams) : 0; if ((parentNameLen != 0) /*&& (templateParamsLen == 0)*/) - { + { int nameSepLen = (int)strlen(nameSep); - + int nameLen = parentNameLen + typeNameLen /*+ templateParamsLen*/; if ((parentNameLen > 0) && (nameLen > 0)) nameLen += nameSepLen; @@ -4244,7 +4244,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) namePtr += templateParamsLen; }*/ } - + dbgType->mTypeCode = DbgType_Null; dbgType->mIsDeclaration = atDeclaration; @@ -4253,7 +4253,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) dbgType->mSize = atByteSize; dbgType->mSizeCalculated = true; } - + switch (entryTag) { case DW_TAG_base_type: @@ -4275,8 +4275,8 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) dbgType->mTypeCode = DbgType_SChar16; else if (atByteSize == 4) dbgType->mTypeCode = DbgType_SChar32; - else - atEncoding = DW_ATE_signed; + else + atEncoding = DW_ATE_signed; break; case DW_ATE_unsigned_char: if (atByteSize == 1) @@ -4292,7 +4292,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) dbgType->mTypeCode = DbgType_Bool; else atEncoding = DW_ATE_unsigned; - break; + break; } if (dbgType->mTypeCode == DbgType_Null) @@ -4352,7 +4352,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) dbgType->mTypeCode = DbgType_u128; break; } - break; + break; case DW_ATE_float: if (atByteSize == 4) dbgType->mTypeCode = DbgType_Single; @@ -4369,7 +4369,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) else if (atByteSize == 16) dbgType->mTypeCode = DbgType_ComplexDouble; else if (atByteSize == 24) - dbgType->mTypeCode = DbgType_ComplexDouble96; + dbgType->mTypeCode = DbgType_ComplexDouble96; else if (atByteSize == 32) dbgType->mTypeCode = DbgType_ComplexDouble128; break; @@ -4379,7 +4379,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) } } break; - case DW_TAG_enumeration_type: //TODO: Handle these differently + case DW_TAG_enumeration_type: //TODO: Handle these differently dbgType->mTypeCode = DbgType_Enum; dbgType->mTypeParam = mAlloc.Alloc(); if (atByteSize == 8) @@ -4396,7 +4396,7 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) } break; case DW_TAG_namespace: - dbgType->mTypeCode = DbgType_Namespace; + dbgType->mTypeCode = DbgType_Namespace; break; case DW_TAG_const_type: dbgType->mTypeCode = DbgType_Const; @@ -4432,15 +4432,15 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) case DW_TAG_array_type: dbgType->mTypeCode = DbgType_SizedArray; dbgType->mTypeParam = GetOrCreateType(atType, dataMap); - break; + break; case DW_TAG_structure_type: - dbgType->mTypeCode = DbgType_Struct; + dbgType->mTypeCode = DbgType_Struct; break; case DW_TAG_class_type: - dbgType->mTypeCode = DbgType_Class; - break; + dbgType->mTypeCode = DbgType_Class; + break; case DW_TAG_union_type: - dbgType->mTypeCode = DbgType_Union; + dbgType->mTypeCode = DbgType_Union; break; case DW_TAG_typedef: dbgType->mTypeCode = DbgType_TypeDef; @@ -4460,28 +4460,28 @@ bool DbgModule::ParseDWARF(const uint8*& dataPtr) dbgType->mTypeCode = DbgType_Restrict; dbgType->mTypeParam = GetOrCreateType(atType, dataMap); break; - } - + } + newDataPair = MakeDataPair(dbgType); } break; } - + if (hasChildren) - dataStack.push_back(newDataPair); + dataStack.push_back(newDataPair); } for (auto& abstractOriginEntry : abstractOriginReplaceList) abstractOriginEntry.Replace(); GetLinkedModule()->MapTypes(startingTypeIdx); - + dataPtr = dataEnd; return true; } void DbgModule::ParseDebugFrameData() -{ +{ BP_ZONE("ParseDebugFrameData"); const uint8* data = mDebugFrameData; @@ -4498,11 +4498,11 @@ void DbgModule::ParseDebugFrameData() int length = GET(int); if (length == 0) break; - + const uint8* dataEnd = data + length; int cieID = GET(int); - + if (cieID < 0) { BP_ALLOC_T(DwCommonFrameDescriptor); @@ -4511,7 +4511,7 @@ void DbgModule::ParseDebugFrameData() char version = GET(char); commonFrameDescriptor->mDbgModule = this; commonFrameDescriptor->mAugmentation = DataGetString(data); - + if (version >= 4) { commonFrameDescriptor->mPointerSize = GET(int8); @@ -4531,7 +4531,7 @@ void DbgModule::ParseDebugFrameData() commonFrameDescriptorMap[mDebugFrameAddress + relSectionAddr] = commonFrameDescriptor; } else - { + { addr_target lowPC = GET(addr_target); addr_target highPC = lowPC + GET(addr_target); @@ -4546,11 +4546,11 @@ void DbgModule::ParseDebugFrameData() frameDescriptor->mLowPC = lowPC; frameDescriptor->mHighPC = highPC; frameDescriptor->mInstData = data; - frameDescriptor->mInstLen = (int)(dataEnd - data); + frameDescriptor->mInstLen = (int)(dataEnd - data); frameDescriptor->mCommonFrameDescriptor = commonFrameDescriptor; } data = dataEnd; - } + } } void DbgModule::ParseEHFrameData() @@ -4584,40 +4584,40 @@ void DbgModule::ParseEHFrameData() commonFrameDescriptor->mCodeAlignmentFactor = (int)DecodeULEB128(data); commonFrameDescriptor->mDataAlignmentFactor = (int)DecodeSLEB128(data); commonFrameDescriptor->mReturnAddressColumn = (int)DecodeULEB128(data); - commonFrameDescriptor->mAugmentation = augmentation; - + commonFrameDescriptor->mAugmentation = augmentation; + if (*augmentation == 'z') { ++augmentation; - int augLen = (int)DecodeULEB128(data); + int augLen = (int)DecodeULEB128(data); commonFrameDescriptor->mAugmentationLength = augLen; - const uint8* augEnd = data + augLen; + const uint8* augEnd = data + augLen; while (*augmentation != '\0') - { + { if (*augmentation == 'R') commonFrameDescriptor->mAddressPointerEncoding = (int) GET(uint8); else if (*augmentation == 'P') { int encodingType = GET(uint8); BF_ASSERT(encodingType == 0); - commonFrameDescriptor->mLSDARoutine = GET(addr_target); + commonFrameDescriptor->mLSDARoutine = GET(addr_target); } - else if (*augmentation == 'L') - commonFrameDescriptor->mLSDAPointerEncodingFDE = GET(uint8); + else if (*augmentation == 'L') + commonFrameDescriptor->mLSDAPointerEncodingFDE = GET(uint8); else if (*augmentation == 'S') { - // mIsSignalHandler - on return from stack frame, CFA is before next instruction rather than after it + // mIsSignalHandler - on return from stack frame, CFA is before next instruction rather than after it } else BF_FATAL("Unknown CIE augmentation"); ++augmentation; - } + } data = augEnd; } commonFrameDescriptor->mInstData = data; commonFrameDescriptor->mInstLen = (int)(dataEnd - data); - + mDebugTarget->mCommonFrameDescriptors.push_back(commonFrameDescriptor); commonFrameDescriptorMap[sectionAddress] = commonFrameDescriptor; } @@ -4628,7 +4628,7 @@ void DbgModule::ParseEHFrameData() addr_target lowPC; addr_target highPC; - + if (commonFrameDescriptor->mAddressPointerEncoding == (DW_EH_PE_pcrel | DW_EH_PE_sdata4)) { lowPC = GET(int); @@ -4637,7 +4637,7 @@ void DbgModule::ParseEHFrameData() } else { - lowPC = GET(int); + lowPC = GET(int); highPC = lowPC + GET(int); } @@ -4673,8 +4673,8 @@ void DbgModule::ParseEHFrameData() augmentation++; } data = augEnd; - } - + } + frameDescriptor->mLowPC = lowPC; frameDescriptor->mHighPC = highPC; frameDescriptor->mInstData = data; @@ -4686,13 +4686,13 @@ void DbgModule::ParseEHFrameData() } void DbgModule::FlushLineData(DbgSubprogram* curSubprogram, std::list& queuedLineData) -{ - +{ + } DbgSrcFile* DbgModule::AddSrcFile(DbgCompileUnit* compileUnit, const String& srcFilePath) { - DbgSrcFile* dwSrcFile = mDebugTarget->AddSrcFile(srcFilePath); + DbgSrcFile* dwSrcFile = mDebugTarget->AddSrcFile(srcFilePath); if (compileUnit != NULL) { DbgSrcFileReference srcFileRef; @@ -4705,15 +4705,15 @@ DbgSrcFile* DbgModule::AddSrcFile(DbgCompileUnit* compileUnit, const String& src } bool DbgModule::ParseDebugLineInfo(const uint8*& dataPtr, int compileUnitIdx) -{ +{ BP_ZONE("ParseDebugLineInfo"); - + const uint8* data = dataPtr; - const int startOffset = (int)(data - mDebugLineData); + const int startOffset = (int)(data - mDebugLineData); int length = GET(int); if (length == 0) return false; - DbgCompileUnit* dwCompileUnit = mCompileUnits[compileUnitIdx]; + DbgCompileUnit* dwCompileUnit = mCompileUnits[compileUnitIdx]; const uint8* dataEnd = data + length; short version = GET(short); int headerLength = GET(int); @@ -4744,7 +4744,7 @@ bool DbgModule::ParseDebugLineInfo(const uint8*& dataPtr, int compileUnitIdx) int curFileIdx = 0; DbgSubprogram* curSubprogram = NULL; - + #define ADD_LINEDATA(lineData) \ lineBuilder.Add(dwCompileUnit, lineData, dwSrcFileRef->mSrcFile, NULL); @@ -4762,29 +4762,29 @@ bool DbgModule::ParseDebugLineInfo(const uint8*& dataPtr, int compileUnitIdx) filePath = String(directoryNames[directoryIdx - 1]) + "/"; filePath += path; filePath = GetAbsPath(filePath, dwCompileUnit->mCompileDir); - AddSrcFile(dwCompileUnit, filePath.c_str()); + AddSrcFile(dwCompileUnit, filePath.c_str()); } if (dwCompileUnit->mSrcFileRefs.size() > 0) dwSrcFileRef = &dwCompileUnit->mSrcFileRefs.front(); - + DbgLineDataBuilder lineBuilder(this); bool queuedPostPrologue = false; - DbgLineDataState dwLineData; + DbgLineDataState dwLineData; dwLineData.mLine = 0; dwLineData.mRelAddress = 0; dwLineData.mOpIndex = 0; dwLineData.mBasicBlock = false; dwLineData.mDiscriminator = 0; dwLineData.mIsStmt = defaultIsStmt != 0; - dwLineData.mIsa = 0; + dwLineData.mIsa = 0; dwLineData.mColumn = -2; while (data < dataEnd) { - uint8_t opcode = GET(uint8_t); + uint8_t opcode = GET(uint8_t); switch (opcode) { case DW_LNS_extended_op: @@ -4794,26 +4794,26 @@ bool DbgModule::ParseDebugLineInfo(const uint8*& dataPtr, int compileUnitIdx) switch (exOpcode) { case DW_LNE_end_sequence: - { + { ADD_LINEDATA(dwLineData); - + dwSrcFileRef = &dwCompileUnit->mSrcFileRefs[0]; dwLineData.mLine = 0; dwLineData.mRelAddress = 0; dwLineData.mOpIndex = 0; - dwLineData.mBasicBlock = false; - dwLineData.mDiscriminator = 0; + dwLineData.mBasicBlock = false; + dwLineData.mDiscriminator = 0; dwLineData.mIsStmt = defaultIsStmt != 0; dwLineData.mIsa = 0; - dwLineData.mColumn = -2; + dwLineData.mColumn = -2; } break; - case DW_LNE_set_address: + case DW_LNE_set_address: dwLineData.mRelAddress = (uint32)(RemapAddr(GET(addr_target)) - mImageBase); break; case DW_LNE_define_file: { - const char* path = DataGetString(data); + const char* path = DataGetString(data); int directoryIdx = (int)DecodeULEB128(data); int lastModificationTime = (int)DecodeULEB128(data); int fileLength = (int)DecodeULEB128(data); @@ -4825,11 +4825,11 @@ bool DbgModule::ParseDebugLineInfo(const uint8*& dataPtr, int compileUnitIdx) } } break; - case DW_LNS_copy: + case DW_LNS_copy: ADD_LINEDATA(dwLineData); - + dwLineData.mDiscriminator = 0; - dwLineData.mBasicBlock = false; + dwLineData.mBasicBlock = false; break; case DW_LNS_advance_pc: { @@ -4872,7 +4872,7 @@ bool DbgModule::ParseDebugLineInfo(const uint8*& dataPtr, int compileUnitIdx) int opAdvance = adjustedOpcode / lineRange; uint32 newAddress = dwLineData.mRelAddress + minimumInstructionLength * ((dwLineData.mOpIndex + opAdvance) / maximumOperationsPerInstruction); int newOpIndex = (dwLineData.mOpIndex + opAdvance) % maximumOperationsPerInstruction; - + dwLineData.mRelAddress = newAddress; dwLineData.mOpIndex = newOpIndex; } @@ -4884,13 +4884,13 @@ bool DbgModule::ParseDebugLineInfo(const uint8*& dataPtr, int compileUnitIdx) dwLineData.mOpIndex = 0; } break; - case DW_LNS_set_prologue_end: - { + case DW_LNS_set_prologue_end: + { queuedPostPrologue = true; } break; case DW_LNS_set_epilogue_begin: - { + { dwLineData.mColumn = -2; } break; @@ -4899,7 +4899,7 @@ bool DbgModule::ParseDebugLineInfo(const uint8*& dataPtr, int compileUnitIdx) dwLineData.mIsa = (int)DecodeULEB128(data); } break; - default: + default: { // Special opcode int adjustedOpcode = opcode - opcodeBase; @@ -4914,16 +4914,16 @@ bool DbgModule::ParseDebugLineInfo(const uint8*& dataPtr, int compileUnitIdx) dwLineData.mOpIndex = newOpIndex; DbgLineData* lastLineData = NULL; - + if ((newAddress == oldAddress) && (queuedPostPrologue) && (curSubprogram != NULL) && (curSubprogram->mBlock.mLowPC == newAddress)) - { + { // Adjust this line later ADD_LINEDATA(dwLineData); - } + } queuedPostPrologue = false; - + } break; } @@ -4943,7 +4943,7 @@ addr_target DbgModule::GetHotTargetAddress(DbgHotTargetSection* hotTargetSection if (hotTargetSection->mNoTargetAlloc) return 0; - hotTargetSection->mTargetSectionAddr = mDebugger->AllocHotTargetMemory(hotTargetSection->mDataSize, hotTargetSection->mCanExecute, hotTargetSection->mCanWrite, &hotTargetSection->mTargetSectionSize); + hotTargetSection->mTargetSectionAddr = mDebugger->AllocHotTargetMemory(hotTargetSection->mDataSize, hotTargetSection->mCanExecute, hotTargetSection->mCanWrite, &hotTargetSection->mTargetSectionSize); hotTargetSection->mImageOffset = (int)mImageSize; if (mImageBase == NULL) @@ -4998,7 +4998,7 @@ void DbgModule::DoReloc(DbgHotTargetSection* hotTargetSection, COFFRelocation& c else if (coffReloc.mType == IMAGE_REL_I386_SECTION) { // auto linkedModule = GetLinkedModule(); -// addr_target mappedAddr = resolvedSymbolAddr & ~0x7FFFFFF; +// addr_target mappedAddr = resolvedSymbolAddr & ~0x7FFFFFF; // int* encodingPtr = NULL; // if (linkedModule->mSecRelEncodingMap.TryAdd(mappedAddr, NULL, &encodingPtr)) // { @@ -5012,7 +5012,7 @@ void DbgModule::DoReloc(DbgHotTargetSection* hotTargetSection, COFFRelocation& c { //*(uint32*)(hotTargetSection->mData + coffReloc.mVirtualAddress) += symInfo->mValue; *(uint32*)(hotTargetSection->mData + coffReloc.mVirtualAddress) += resolvedSymbolAddr; - } + } else { BF_ASSERT(0=="Invalid COFF reloc type"); @@ -5020,13 +5020,13 @@ void DbgModule::DoReloc(DbgHotTargetSection* hotTargetSection, COFFRelocation& c #else // CodeView uses SECTION:SECREL locations, and we just want to find a mapping such that - // COFF::GetSectionAddr can map it to the 64-bit address. We do this by encoding the + // COFF::GetSectionAddr can map it to the 64-bit address. We do this by encoding the // lower 31 bits in the SECREL (allowing a 31-bit offset at the destination as well) // and then we use a 15-bit key to map the upper bits if (coffReloc.mType == IMAGE_REL_AMD64_REL32) { - addr_target myAddr = GetHotTargetAddress(hotTargetSection) + coffReloc.mVirtualAddress; + addr_target myAddr = GetHotTargetAddress(hotTargetSection) + coffReloc.mVirtualAddress; intptr_target addrOffset = resolvedSymbolAddr - myAddr - sizeof(int32); BF_ASSERT((int64)(int32)addrOffset == addrOffset); @@ -5042,7 +5042,7 @@ void DbgModule::DoReloc(DbgHotTargetSection* hotTargetSection, COFFRelocation& c else*/ { auto linkedModule = GetLinkedModule(); - addr_target mappedAddr = resolvedSymbolAddr & ~0x7FFFFFF; + addr_target mappedAddr = resolvedSymbolAddr & ~0x7FFFFFF; /*auto pair = linkedModule->mSecRelEncodingMap.insert(std::make_pair(mappedAddr, (int)linkedModule->mSecRelEncodingMap.size())); if (pair.second) linkedModule->mSecRelEncodingVec.push_back(mappedAddr);*/ @@ -5058,16 +5058,16 @@ void DbgModule::DoReloc(DbgHotTargetSection* hotTargetSection, COFFRelocation& c } } else if (coffReloc.mType == IMAGE_REL_AMD64_SECREL) - { + { auto linkedModule = GetLinkedModule(); if ((resolvedSymbolAddr >= linkedModule->mTLSAddr) && (resolvedSymbolAddr < linkedModule->mTLSAddr + linkedModule->mTLSSize)) { // Make relative to actual TLS data resolvedSymbolAddr -= linkedModule->mTLSAddr; } - + *(uint32*)(hotTargetSection->mData + coffReloc.mVirtualAddress) += (uint32)(resolvedSymbolAddr & 0x7FFFFFF); - + } else if (coffReloc.mType == IMAGE_REL_AMD64_ADDR64) { @@ -5080,7 +5080,7 @@ void DbgModule::DoReloc(DbgHotTargetSection* hotTargetSection, COFFRelocation& c // It was causing hot-loaded jump tables to have invalid addresses since the need to be relative to __ImageBase *(uint32*)(hotTargetSection->mData + coffReloc.mVirtualAddress) += (uint32)(resolvedSymbolAddr - GetTargetImageBase()); //*(int32*)(hotTargetSection->mData + coffReloc.mVirtualAddress) += secRelAddr; - } + } else { BF_ASSERT(0=="Invalid COFF reloc type"); @@ -5110,7 +5110,7 @@ bool DbgModule::IsHotSwapPreserve(const String& name) } void DbgModule::ParseHotTargetSections(DataStream* stream, addr_target* resolvedSymbolAddrs) -{ +{ auto mainModule = mDebugTarget->mTargetBinary; mainModule->ParseSymbolData(); @@ -5145,7 +5145,7 @@ void DbgModule::ParseHotTargetSections(DataStream* stream, addr_target* resolved name = mStringTable + symInfo->mNameOfs[1]; bool didNameMatch = false; - + addr_target resolvedSymbolAddr = resolvedSymbolAddrs[coffReloc.mSymbolTableIndex]; #ifdef BF_DBG_32 @@ -5154,7 +5154,7 @@ void DbgModule::ParseHotTargetSections(DataStream* stream, addr_target* resolved name.Remove(0, 1); #else bool needsSymbolAddr = (coffReloc.mType == IMAGE_REL_AMD64_ADDR64) || (coffReloc.mType == IMAGE_REL_AMD64_ADDR32) || (coffReloc.mType == IMAGE_REL_AMD64_ADDR32NB) || - ((coffReloc.mType >= IMAGE_REL_AMD64_REL32) || (coffReloc.mType <= IMAGE_REL_AMD64_REL32_5)); + ((coffReloc.mType >= IMAGE_REL_AMD64_REL32) || (coffReloc.mType <= IMAGE_REL_AMD64_REL32_5)); #endif bool isHsPrev = false; @@ -5167,13 +5167,13 @@ void DbgModule::ParseHotTargetSections(DataStream* stream, addr_target* resolved bool deferResolve = false; if ((resolvedSymbolAddr == 0) && (needsSymbolAddr)) - { + { bool isHotSwapPreserve = IsHotSwapPreserve(name); if ((symInfo->mSectionNum == 0) || (isHotSwapPreserve) || (isHsPrev)) - { + { auto origSymbolEntry = mainModule->mSymbolNameMap.Find(name.c_str()); if (origSymbolEntry != NULL) - { + { resolvedSymbolAddr = origSymbolEntry->mValue->mAddress; } else @@ -5182,16 +5182,16 @@ void DbgModule::ParseHotTargetSections(DataStream* stream, addr_target* resolved deferResolve = true; } } - + if ((symInfo->mSectionNum != 0) && (resolvedSymbolAddr == NULL)) - { + { DbgHotTargetSection* refHotTargetSection = mHotTargetSections[symInfo->mSectionNum - 1]; resolvedSymbolAddr = GetHotTargetAddress(refHotTargetSection) + symInfo->mValue; // Using the !hotTargetSection->mNoTargetAlloc check down here caused us to not properly remap reloaded // static members in the debug info. Even though we parse the debug info before we apply the deferred // resolves, the mLocData points into the original data so we still get it remapped when we use that // mLocData - if (/*(!hotTargetSection->mNoTargetAlloc) &&*/ ((refHotTargetSection->mData == NULL) || (refHotTargetSection->mNoTargetAlloc)) && + if (/*(!hotTargetSection->mNoTargetAlloc) &&*/ ((refHotTargetSection->mData == NULL) || (refHotTargetSection->mNoTargetAlloc)) && (!isStaticSymbol)) deferResolve = true; else @@ -5200,13 +5200,13 @@ void DbgModule::ParseHotTargetSections(DataStream* stream, addr_target* resolved } if (deferResolve) - { + { // It's a static field, defer resolution, but don't bother replacing for debug info sections DbgDeferredHotResolve* deferredResolve = mDeferredHotResolveList.Alloc(); deferredResolve->mHotTargetSection = hotTargetSection; deferredResolve->mName = name; deferredResolve->mNewAddr = resolvedSymbolAddr; - deferredResolve->mReloc = coffReloc; + deferredResolve->mReloc = coffReloc; continue; } else @@ -5214,7 +5214,7 @@ void DbgModule::ParseHotTargetSections(DataStream* stream, addr_target* resolved resolvedSymbolAddrs[coffReloc.mSymbolTableIndex] = resolvedSymbolAddr; DoReloc(hotTargetSection, coffReloc, resolvedSymbolAddr, symInfo); } - } + } } } } @@ -5266,7 +5266,7 @@ void DbgModule::CommitHotTargetSections() } void DbgModule::HotReplaceType(DbgType* newType) -{ +{ auto linkedModule = GetLinkedModule(); newType->PopulateType(); @@ -5301,9 +5301,9 @@ void DbgModule::HotReplaceType(DbgType* newType) { linkedModule->MapCompileUnitMethods(methodNameEntry->mCompileUnitId); methodNameEntry->mCompileUnitId = -1; - } + } } - + // Now actually remove the linedata from the defining module HashSet checkedFiles; for (auto method : primaryType->mMethodList) @@ -5319,7 +5319,7 @@ void DbgModule::HotReplaceType(DbgType* newType) checkedFiles.Clear(); int prevCtx = -1; - auto inlineRoot = method->GetRootInlineParent(); + auto inlineRoot = method->GetRootInlineParent(); for (int lineIdx = 0; lineIdx < method->mLineInfo->mLines.mSize; lineIdx++) { auto& lineData = method->mLineInfo->mLines[lineIdx]; @@ -5327,7 +5327,7 @@ void DbgModule::HotReplaceType(DbgType* newType) { auto ctxInfo = inlineRoot->mLineInfo->mContexts[lineData.mCtxIdx]; auto srcFile = ctxInfo.mSrcFile; - prevCtx = lineData.mCtxIdx; + prevCtx = lineData.mCtxIdx; if (srcFile != lastSrcFile) { if (checkedFiles.Add(srcFile)) @@ -5336,7 +5336,7 @@ void DbgModule::HotReplaceType(DbgType* newType) // These go into a hot-replaced list so we can still bind to them -- that is necessary because // we may still have old versions of this method running (and may forever, if its in a loop on some thread) // since we only patch entry points - //srcFile->RemoveLines(primaryType->mCompileUnit->mDbgModule, primaryType->mCompileUnit, true); + //srcFile->RemoveLines(primaryType->mCompileUnit->mDbgModule, primaryType->mCompileUnit, true); //srcFile->RemoveLines(primaryType->mCompileUnit->mDbgModule, method, true); srcFile->RemoveLines(method->mCompileUnit->mDbgModule, method, true); @@ -5349,11 +5349,11 @@ void DbgModule::HotReplaceType(DbgType* newType) } - //DbgType* primaryType = newType->GetPrimaryType(); + //DbgType* primaryType = newType->GetPrimaryType(); // We need to keep a persistent list of hot replaced methods so we can set hot jumps // in old methods that may still be on the callstack. These entries get removed when - // we unload unused hot files in + // we unload unused hot files in while (!primaryType->mMethodList.IsEmpty()) { auto method = primaryType->mMethodList.PopFront(); @@ -5363,7 +5363,7 @@ void DbgModule::HotReplaceType(DbgType* newType) primaryType->mHotReplacedMethodList.PushFront(method); mHotPrimaryTypes.Add(primaryType); } - + Dictionary oldProgramMap; for (auto oldMethod : primaryType->mHotReplacedMethodList) { @@ -5379,13 +5379,13 @@ void DbgModule::HotReplaceType(DbgType* newType) bool setHotJumpFailed = false; while (!newType->mMethodList.IsEmpty()) - { + { DbgSubprogram* newMethod = newType->mMethodList.PopFront(); if (!newMethod->mBlock.IsEmpty()) { BfLogDbg("Hot added new method %p %s Address:%p\n", newMethod, newMethod->mName, newMethod->mBlock.mLowPC); - newMethod->PopulateSubprogram(); + newMethod->PopulateSubprogram(); auto symInfo = mDebugTarget->mSymbolMap.Get(newMethod->mBlock.mLowPC); if (symInfo != NULL) @@ -5401,7 +5401,7 @@ void DbgModule::HotReplaceType(DbgType* newType) } else { - // When mangles match but the actual signatures don't match, that can mean that the call signature was changed + // When mangles match but the actual signatures don't match, that can mean that the call signature was changed // and thus it's actually a different method and shouldn't hot jump OR it could be lambda whose captures changed. // When the lambda captures change, the user didn't actually enter a different signature so we want to do a hard // fail if the old code gets called to avoid confusion of "why aren't my changes working?" @@ -5421,7 +5421,7 @@ void DbgModule::HotReplaceType(DbgType* newType) auto newType = newParam->mType->mTypeParam->GetPrimaryType(); newType->PopulateType(); if ((oldType->IsStruct()) && (newType->IsStruct())) - { + { bool wasMatch = true; auto oldMember = oldType->mMemberList.front(); @@ -5451,7 +5451,7 @@ void DbgModule::HotReplaceType(DbgType* newType) wasMatch = false; break; } - + oldMember = oldMember->mNext; newMember = newMember->mNext; } @@ -5465,9 +5465,9 @@ void DbgModule::HotReplaceType(DbgType* newType) { mDebugTarget->mDebugger->PhysSetBreakpoint(oldMethod->mBlock.mLowPC); oldMethod->mHotReplaceKind = DbgSubprogram::HotReplaceKind_Invalid; - } + } } - } + } if (doHotJump) { @@ -5479,7 +5479,7 @@ void DbgModule::HotReplaceType(DbgType* newType) oldMethod->mHotReplaceKind = DbgSubprogram::HotReplaceKind_Replaced; } } - } + } } newMethod->mParentType = primaryType; primaryType->mMethodList.PushBack(newMethod); @@ -5494,7 +5494,7 @@ void DbgModule::HotReplaceType(DbgType* newType) // if (!newMethod->mBlock.IsEmpty()) // { // newMethod->PopulateSubprogram(); -// +// // bool found = false; // for (auto oldMethod : primaryType->mHotReplacedMethodList) // { @@ -5507,7 +5507,7 @@ void DbgModule::HotReplaceType(DbgType* newType) // if (!mDebugger->SetHotJump(oldMethod, newMethod)) // setHotJumpFailed = true; // oldMethod->mWasHotReplaced = true; -// } +// } // } // } // } @@ -5515,12 +5515,12 @@ void DbgModule::HotReplaceType(DbgType* newType) // primaryType->mMethodList.PushBack(newMethod); // } - primaryType->mCompileUnit->mWasHotReplaced = true; + primaryType->mCompileUnit->mWasHotReplaced = true; primaryType->mNeedsGlobalsPopulated = newType->mNeedsGlobalsPopulated; primaryType->mUsingNamespaces = newType->mUsingNamespaces; primaryType->mMemberList = newType->mMemberList; - primaryType->mCompileUnit = newType->mCompileUnit; + primaryType->mCompileUnit = newType->mCompileUnit; } bool DbgModule::CanRead(DataStream* stream, DebuggerResult* outResult) @@ -5590,7 +5590,7 @@ const char* DbgModule::GetStringTable(DataStream* stream, int stringTablePos) bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) { - BP_ZONE("DbgModule::ReadCOFF"); + BP_ZONE("DbgModule::ReadCOFF"); //if (this == mDebugTarget->mTargetBinary) //mMemReporter = new MemReporter(); @@ -5607,9 +5607,9 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) if (mMemReporter != NULL) mMemReporter->EndSection(); ); - - DbgModule* mainModule = mDebugTarget->mTargetBinary; - + + DbgModule* mainModule = mDebugTarget->mTargetBinary; + MiniDumpDebugger* miniDumpDebugger = NULL; if (mDebugger->IsMiniDumpDebugger()) { @@ -5619,16 +5619,16 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) mModuleKind = moduleKind; bool isHotSwap = mModuleKind == DbgModuleKind_HotObject; bool isObjectFile = mModuleKind != DbgModuleKind_Module; - + auto linkedModule = GetLinkedModule(); if (isObjectFile) linkedModule->PopulateStaticVariableMap(); - + mStartTypeIdx = (int)linkedModule->mTypes.size(); int startSrcFile = (int)mDebugTarget->mSrcFiles.size(); mStartSubprogramIdx = (int)mSubprograms.size(); - + PEHeader hdr; memset(&hdr, 0, sizeof(hdr)); @@ -5639,7 +5639,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) { stream->Read(&hdr, sizeof(PEHeader)); stream->SetPos(hdr.e_lfanew); - + stream->Read(&ntHdr, sizeof(PE_NTHeaders)); mPreferredImageBase = ntHdr.mOptionalHeader.mImageBase; @@ -5650,7 +5650,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) } if ((hdr.e_magic != PE_DOS_SIGNATURE) || (ntHdr.mSignature != PE_NT_SIGNATURE)) - { + { mLoadState = DbgModuleLoadState_Failed; return false; } @@ -5686,8 +5686,8 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) return false; } #endif - } - + } + int sectionStartPos = stream->GetPos(); int sectionDataEndPos = 0; @@ -5704,19 +5704,19 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) { PESectionHeader sectHdr; - char* name = sectHdr.mName; + char* name = sectHdr.mName; stream->Read(§Hdr, sizeof(PESectionHeader)); if (sectHdr.mSizeOfRawData > 0) sectionDataEndPos = BF_MAX(sectionDataEndPos, (int)(sectHdr.mPointerToRawData + sectHdr.mSizeOfRawData)); if (sectHdr.mNumberOfRelocations > 0) sectionDataEndPos = BF_MAX(sectionDataEndPos, (int)(sectHdr.mPointerToRelocations + sectHdr.mNumberOfRelocations * sizeof(COFFRelocation))); - + if (miniDumpDebugger != NULL) { miniDumpDebugger->MapMemory((addr_target)(mImageBase + sectHdr.mVirtualAddress), (uint8*)mMappedImageFile->mData + sectHdr.mPointerToRawData, sectHdr.mSizeOfRawData); } } - + //fseek(fp, sectionDataEndPos + ntHdr.mFileHeader.mNumberOfSymbols * 18, SEEK_SET); stream->SetPos(sectionDataEndPos); @@ -5726,21 +5726,21 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) mSymbolData = symbolData; stream->Read(symbolData, ntHdr.mFileHeader.mNumberOfSymbols * 18); - int curPos = stream->GetPos(); + int curPos = stream->GetPos(); int stringTablePos = curPos; if (isObjectFile) GetStringTable(stream, stringTablePos); - - int mDebugFrameDataLen = 0; - + + int mDebugFrameDataLen = 0; + stream->SetPos(sectionStartPos); - - PEDataDirectory* exportDataDir = &ntHdr.mOptionalHeader.mDataDirectory[0]; - + + PEDataDirectory* exportDataDir = &ntHdr.mOptionalHeader.mDataDirectory[0]; + mHotTargetSections.Resize(ntHdr.mFileHeader.mNumberOfSections); - + Array sectionHeaders; - sectionHeaders.Resize(ntHdr.mFileHeader.mNumberOfSections); + sectionHeaders.Resize(ntHdr.mFileHeader.mNumberOfSections); mSectionRVAs.Resize(sectionHeaders.size() + 1); Array sectionNames; @@ -5752,14 +5752,14 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) { mSectionRVAs[sectNum] = sectionHeaders[sectNum].mVirtualAddress; } - + int tlsSection = -1; for (int sectNum = 0; sectNum < ntHdr.mFileHeader.mNumberOfSections; sectNum++) { //PEDataDirectory* dataDir = &ntHdr.mOptionalHeader.mDataDirectory[dirNum]; PESectionHeader& sectHdr = sectionHeaders[sectNum]; - //stream->Read(§Hdr, sizeof(PESectionHeader)); + //stream->Read(§Hdr, sizeof(PESectionHeader)); const char* name = sectHdr.mName; if (name[0] == '/') @@ -5783,7 +5783,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) targetSection->mNoTargetAlloc = (sectHdr.mCharacteristics & IMAGE_SCN_MEM_DISCARDABLE) != 0; mHotTargetSections[sectNum] = targetSection; } - + DbgSection dwSection; dwSection.mIsExecutable = (sectHdr.mCharacteristics & IMAGE_SCN_MEM_EXECUTE) != 0; dwSection.mAddrStart = sectHdr.mVirtualAddress; @@ -5872,8 +5872,8 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) mTLSIndexAddr = funcAddr; } - //TODO: - //mDeferredSymbols.PushFront(dwSymbol); + //TODO: + //mDeferredSymbols.PushFront(dwSymbol); dwSymbol->mAddress = (addr_target)(dwSymbol->mAddress + mImageBase); mDebugTarget->mSymbolMap.Insert(dwSymbol); @@ -5931,13 +5931,13 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) } } - //stream->SetPos(debugDirEntry.mVirtualAddress); + //stream->SetPos(debugDirEntry.mVirtualAddress); } } // { - PEDataDirectory& tlsDirEntry = ntHdr.mOptionalHeader.mDataDirectory[IMAGE_DIRECTORY_ENTRY_TLS]; + PEDataDirectory& tlsDirEntry = ntHdr.mOptionalHeader.mDataDirectory[IMAGE_DIRECTORY_ENTRY_TLS]; if (tlsDirEntry.mSize > 0) { if ((tlsDirEntry.mVirtualAddress >= sectHdr.mVirtualAddress) && (tlsDirEntry.mVirtualAddress < sectHdr.mVirtualAddress + sectHdr.mSizeOfRawData)) @@ -5950,7 +5950,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) mTLSAddr = (addr_target)(tlsDataStart + mImageBase); mTLSSize = (int)(tlsDataEnd - tlsDataStart); - } + } } } @@ -5958,15 +5958,15 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) { PEDataDirectory& debugDirEntry = ntHdr.mOptionalHeader.mDataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE]; if (debugDirEntry.mSize > 0) - { + { if ((debugDirEntry.mVirtualAddress >= sectHdr.mVirtualAddress) && (debugDirEntry.mVirtualAddress < sectHdr.mVirtualAddress + sectHdr.mSizeOfRawData)) - { + { uint8* relPtr = data + debugDirEntry.mVirtualAddress - sectHdr.mVirtualAddress; uint8* endPtr = relPtr + debugDirEntry.mSize; IMAGE_RESOURCE_DIRECTORY* typeDir = (IMAGE_RESOURCE_DIRECTORY*)(relPtr); - - // Skip named entries + + // Skip named entries for (int typeIdx = 0; typeIdx < typeDir->NumberOfIdEntries; typeIdx++) { IMAGE_RESOURCE_DIRECTORY_ENTRY* typeEntry = (IMAGE_RESOURCE_DIRECTORY_ENTRY*)((uint8*)typeDir + sizeof(IMAGE_RESOURCE_DIRECTORY) + @@ -5988,25 +5988,25 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) IMAGE_RESOURCE_DATA_ENTRY* dataEntry = (IMAGE_RESOURCE_DATA_ENTRY*)(relPtr + (langEntry->OffsetToData & 0x7FFFFFFF)); uint8* versionData = data + dataEntry->OffsetToData - sectHdr.mVirtualAddress; uint8* vPtr = versionData; - + auto vSize = GET_FROM(vPtr, uint16); auto verEnd = vPtr + vSize; auto vLength = GET_FROM(vPtr, uint16); vPtr += 36; // "VS_VERSION_INFO" - auto fixedFileInfo = GET_FROM(vPtr, VS_FIXEDFILEINFO); + auto fixedFileInfo = GET_FROM(vPtr, VS_FIXEDFILEINFO); auto _GetString = [&]() { wchar_t* cPtr = (wchar_t*)vPtr; int len = (int)wcslen(cPtr); vPtr += (len + 1) * 2; - + if (((intptr)vPtr & 3) != 0) vPtr += 2; UTF16String str16(cPtr, len); - return UTF8Encode(str16); + return UTF8Encode(str16); }; while (vPtr < verEnd) @@ -6042,31 +6042,31 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) } vPtr = childEnd; - } + } } - } + } } - //stream->SetPos(debugDirEntry.mVirtualAddress); + //stream->SetPos(debugDirEntry.mVirtualAddress); } } - + bool usedData = true; /*if (isUnwindSection) { mExceptionData = data; - mExceptionDataRVA = sectHdr.mVirtualAddress; + mExceptionDataRVA = sectHdr.mVirtualAddress; }*/ if (strcmp(name, ".pdata") == 0) { DbgSectionData entry; - entry.mData = data; + entry.mData = data; entry.mSize = sectHdr.mSizeOfRawData; mExceptionDirectory.Add(entry); } - + // Old, unsupported DWARF debug info /* else if (strcmp(name, ".debug_info") == 0) @@ -6075,13 +6075,13 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) } else if (strcmp(name, ".debug_line") == 0) { - mDebugLineData = data; + mDebugLineData = data; } else if (strcmp(name, ".debug_str") == 0) { mDebugStrData = data; } - else if (strcmp(name, ".debug_frame") == 0) + else if (strcmp(name, ".debug_frame") == 0) { mDebugFrameAddress = ntHdr.mOptionalHeader.mImageBase + sectHdr.mVirtualAddress; mDebugFrameData = data; @@ -6095,11 +6095,11 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) else if (strcmp(name, ".debug_abbrev") == 0) { mDebugAbbrevData = data; - mDebugAbbrevPtrData = new const uint8*[sectHdr.mSizeOfRawData]; + mDebugAbbrevPtrData = new const uint8*[sectHdr.mSizeOfRawData]; } else if (strcmp(name, ".debug_loc") == 0) { - mDebugLocationData = data; + mDebugLocationData = data; } else if (strcmp(name, ".debug_ranges") == 0) { @@ -6120,7 +6120,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) /*if (isUnwindSection) mOwnsExceptionData = true; else*/ - usedData = false; + usedData = false; } if (!usedData) @@ -6141,17 +6141,17 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) int needHotTargetMemory = 0; if (isObjectFile) - { + { for (int sectNum = 0; sectNum < ntHdr.mFileHeader.mNumberOfSections; sectNum++) { auto targetSection = mHotTargetSections[sectNum]; if (!targetSection->mNoTargetAlloc) needHotTargetMemory += (targetSection->mDataSize + (mDebugger->mPageSize - 1)) & ~(mDebugger->mPageSize - 1); - } + } mDebugger->ReserveHotTargetMemory(needHotTargetMemory); - + // '0' address is temporary - //mOrigImageData = new DbgModuleMemoryCache(0, NULL, needHotTargetMemory, true); + //mOrigImageData = new DbgModuleMemoryCache(0, NULL, needHotTargetMemory, true); mOrigImageData = new DbgModuleMemoryCache(0, needHotTargetMemory); } @@ -6194,7 +6194,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) if (!ParseDebugLineInfo(data, compileUnitIdx)) break; } - + { BP_ZONE("ReadPE_ReadSymbols"); @@ -6224,7 +6224,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) if ((symInfo->mStorageClass == COFF_SYM_CLASS_EXTERNAL) || (symInfo->mStorageClass == COFF_SYM_CLASS_STATIC)) { - // 'static' in the C sense. + // 'static' in the C sense. // It means local to the compile unit, so may have multiple copies of the same symbol name. bool isStaticSymbol = symInfo->mStorageClass == COFF_SYM_CLASS_STATIC; @@ -6232,14 +6232,14 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) continue; if (symInfo->mSectionNum > 0) - { + { bool isTLS = false; addr_target targetAddr = 0; if (isObjectFile) { if (symInfo->mSectionNum - 1 == tlsSection) { - isTLS = true; + isTLS = true; } else { @@ -6249,9 +6249,9 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) } } else - targetAddr = mSectionRVAs[symInfo->mSectionNum - 1] + symInfo->mValue; - - if (((targetAddr != 0) || (isTLS)) && + targetAddr = mSectionRVAs[symInfo->mSectionNum - 1] + symInfo->mValue; + + if (((targetAddr != 0) || (isTLS)) && (name[0] != '.')) { const char* symbolName = name; @@ -6264,13 +6264,13 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) if (strcmp(symbolName, "_tls_index") == 0) { mTLSIndexAddr = (addr_target)(targetAddr + mImageBase); - } - + } + if ((isStaticSymbol) && (IsHotSwapPreserve(symbolName))) isStaticSymbol = false; if ((isObjectFile) && (!isStaticSymbol)) - { + { DbgSymbol* dwSymbol = NULL; linkedModule->ParseSymbolData() ; @@ -6279,15 +6279,15 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) dwSymbol = mAlloc.Alloc(); dwSymbol->mDbgModule = this; dwSymbol->mName = symbolName; - dwSymbol->mAddress = targetAddr; + dwSymbol->mAddress = targetAddr; if (dwSymbol != NULL) - { + { bool isHotSwapPreserve = IsHotSwapPreserve(dwSymbol->mName); bool insertIntoNameMap = true; - + bool oldFound = false; - + auto nameMapEntry = linkedModule->mSymbolNameMap.Find(dwSymbol->mName); if (nameMapEntry != NULL) { @@ -6298,7 +6298,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) } else if (mDbgFlavor == DbgFlavor_MS) { - // Store in our own map - this is needed for storing address of the new vdata + // Store in our own map - this is needed for storing address of the new vdata // so the new values can be copied in mSymbolNameMap.Insert(dwSymbol); } @@ -6352,11 +6352,11 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) } } } - + if (dwSymbol->mAddress != 0) { if (!oldFound) - linkedModule->mSymbolNameMap.Insert(dwSymbol); + linkedModule->mSymbolNameMap.Insert(dwSymbol); mDebugTarget->mSymbolMap.Insert(dwSymbol); } } @@ -6394,14 +6394,14 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) } } - int subProgramSizes = 0; + int subProgramSizes = 0; for (int subProgramIdx = mStartSubprogramIdx; subProgramIdx < mEndSubprogramIdx; subProgramIdx++) { auto dwSubprogram = mSubprograms[subProgramIdx]; subProgramSizes += (int)(dwSubprogram->mBlock.mHighPC - dwSubprogram->mBlock.mLowPC); - + /*for (int i = 0; i < dwSubprogram->mLineDataArray.mSize; i++) - { + { auto lineData = dwSubprogram->mLineDataArray.mData[i]; auto srcFile = lineData->mSrcFileRef->mSrcFile; srcFile->mLineData.push_back(lineData); @@ -6409,7 +6409,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) if ((srcFile->mFirstLineDataDbgModule == NULL) || (srcFile->mFirstLineDataDbgModule == this)) srcFile->mFirstLineDataDbgModule = this; else - srcFile->mHasLineDataFromMultipleModules = true; + srcFile->mHasLineDataFromMultipleModules = true; }*/ } @@ -6418,7 +6418,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) /*for (int srcFileIdx = startSrcFile; srcFileIdx < (int)mDebugTarget->mSrcFiles.size(); srcFileIdx++) { if (!mDebugTarget->mSrcFiles[srcFileIdx]->mHadLineData) - { + { mEmptySrcFiles.push_back(mDebugTarget->mSrcFiles[srcFileIdx]); mDebugTarget->mSrcFiles.erase(mDebugTarget->mSrcFiles.begin() + srcFileIdx); } @@ -6445,10 +6445,10 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) mImageSize = ntHdr.mOptionalHeader.mSizeOfImage; mEntryPoint = ntHdr.mOptionalHeader.mAddressOfEntryPoint; } - - /*OutputDebugStrF("%s:\n CompileUnits:%d DebugLines: %d Types: %d (%d in map) SubPrograms: %d (%dk) AllocSize:%dk\n", mFilePath.c_str(), mCompileUnits.size(), + + /*OutputDebugStrF("%s:\n CompileUnits:%d DebugLines: %d Types: %d (%d in map) SubPrograms: %d (%dk) AllocSize:%dk\n", mFilePath.c_str(), mCompileUnits.size(), lineDataCount, mEndTypeIdx - mStartTypeIdx, (int)linkedModule->mTypes.size() - mStartTypeIdx, mEndSubprogramIdx - mStartSubprogramIdx, subProgramSizes / 1024, mAlloc.GetAllocSize() / 1024);*/ - + if (isHotSwap) { // In COFF, we don't necessarily add an actual primary type during MapCompileUnitMethods, so this fixes that @@ -6469,7 +6469,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) } if (!didReplaceType) break; - } + } BF_ASSERT(mTypes.size() == 0); for (int typeIdx = mStartTypeIdx; typeIdx < (int)linkedModule->mTypes.size(); typeIdx++) @@ -6480,21 +6480,21 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) HotReplaceType(newType); } } - + if (needHotTargetMemory != 0) { BF_ASSERT(needHotTargetMemory >= (int)mImageSize); } //BF_ASSERT(mEndTypeIdx == (int)linkedModule->mTypes.size()); - //BF_ASSERT(mEndSubprogramIdx == (int)mSubprograms.size()); + //BF_ASSERT(mEndSubprogramIdx == (int)mSubprograms.size()); ParseExceptionData(); mLoadState = DbgModuleLoadState_Loaded; if (mMemReporter != NULL) - { + { mMemReporter->BeginSection("Sections"); ParseSymbolData(); @@ -6506,11 +6506,11 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) orderedSyms.Add(dbgSym); } orderedSyms.Sort([](DbgSymbol* lhs, DbgSymbol* rhs) { return lhs->mAddress < rhs->mAddress; }); - + for (int sectNum = 0; sectNum < ntHdr.mFileHeader.mNumberOfSections; sectNum++) - { + { PESectionHeader& sectHdr = sectionHeaders[sectNum]; - + mMemReporter->BeginSection(sectionNames[sectNum]); DbgSymbol* lastSym = NULL; @@ -6522,7 +6522,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) if (dbgSym->mAddress >= mImageBase + sectHdr.mVirtualAddress + sectHdr.mSizeOfRawData) break; - + if (lastSym != NULL) { mMemReporter->Add(lastSym->mName, (int)(dbgSym->mAddress - lastSym->mAddress)); @@ -6533,7 +6533,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) if (startingOffset > 0) mMemReporter->Add("", startingOffset); } - lastSym = dbgSym; + lastSym = dbgSym; } if (lastSym != NULL) @@ -6548,7 +6548,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) mMemReporter->EndSection(); mMemReporter->mShowInKB = false; - mMemReporter->Report(); + mMemReporter->Report(); } return true; } @@ -6558,7 +6558,7 @@ void DbgModule::FinishHotSwap() BF_ASSERT(IsObjectFile()); auto linkedModule = GetLinkedModule(); - auto mainModule = mDebugTarget->mTargetBinary; + auto mainModule = mDebugTarget->mTargetBinary; HashSet failSet; @@ -6581,10 +6581,10 @@ void DbgModule::FinishHotSwap() } else { - auto symbolEntry = mainModule->mSymbolNameMap.Find(findName.c_str()); + auto symbolEntry = mainModule->mSymbolNameMap.Find(findName.c_str()); if (symbolEntry != NULL) - { + { resolveTargetAddr = symbolEntry->mValue->mAddress; } else @@ -6604,9 +6604,9 @@ void DbgModule::FinishHotSwap() } } } - DoReloc(deferredHotResolve->mHotTargetSection, deferredHotResolve->mReloc, resolveTargetAddr, NULL); + DoReloc(deferredHotResolve->mHotTargetSection, deferredHotResolve->mReloc, resolveTargetAddr, NULL); } - mDeferredHotResolveList.Clear(); + mDeferredHotResolveList.Clear(); if (!failSet.IsEmpty()) { @@ -6617,9 +6617,9 @@ void DbgModule::FinishHotSwap() if (str.Contains("failed to resolve")) { for (auto& sym : failSet) - { + { str += ", "; - str += sym; + str += sym; } handled = true; } @@ -6648,13 +6648,13 @@ void DbgModule::FinishHotSwap() // We need this here because vdata gets loaded first, so we need to wait until we have the addrs for the new methods (from other modules) // before we can finalize the class vdata. - ProcessHotSwapVariables(); + ProcessHotSwapVariables(); for (auto hotTargetSection : mHotTargetSections) delete hotTargetSection; mHotTargetSections.Clear(); - mSymbolNameMap.Clear(); + mSymbolNameMap.Clear(); } addr_target DbgModule::ExecuteOps(DbgSubprogram* dwSubprogram, const uint8* locData, int locDataLen, WdStackFrame* stackFrame, CPURegisters* registers, DbgAddrType* outAddrType, DbgEvalLocFlags flags, addr_target* pushValue) @@ -6667,8 +6667,8 @@ addr_target DbgModule::ExecuteOps(DbgSubprogram* dwSubprogram, const uint8* locD addr_target stackFrameData[256]; int stackIdx = 0; - if (pushValue != NULL) - stackFrameData[stackIdx++] = *pushValue; + if (pushValue != NULL) + stackFrameData[stackIdx++] = *pushValue; while (locData < locDataEnd) { @@ -6698,7 +6698,7 @@ addr_target DbgModule::ExecuteOps(DbgSubprogram* dwSubprogram, const uint8* locD break; case DW_OP_stack_value: { - *outAddrType = DbgAddrType_Value; + *outAddrType = DbgAddrType_Value; } break; case DW_OP_addr_noRemap: @@ -6733,7 +6733,7 @@ addr_target DbgModule::ExecuteOps(DbgSubprogram* dwSubprogram, const uint8* locD return 0; BF_ASSERT(dwSubprogram != NULL); DbgSubprogram* nonInlinedSubProgram = dwSubprogram->GetRootInlineParent(); - + if (nonInlinedSubProgram->mFrameBaseData == NULL) { *outAddrType = DbgAddrType_Target; //TODO: why? @@ -6770,7 +6770,7 @@ addr_target DbgModule::ExecuteOps(DbgSubprogram* dwSubprogram, const uint8* locD return 0; BF_ASSERT((opCode - DW_OP_reg0) < CPURegisters::kNumIntRegs); regNum = opCode - DW_OP_reg0; - stackFrameData[stackIdx++] = registers->mIntRegsArray[regNum]; + stackFrameData[stackIdx++] = registers->mIntRegsArray[regNum]; *outAddrType = DbgAddrType_Register; break; @@ -6833,7 +6833,7 @@ addr_target DbgModule::ExecuteOps(DbgSubprogram* dwSubprogram, const uint8* locD } break; case DW_OP_GNU_push_tls_address: - { + { if ((mTLSAddr == 0) || (mTLSIndexAddr == 0)) return 0; @@ -6868,7 +6868,7 @@ addr_target DbgModule::ExecuteOps(DbgSubprogram* dwSubprogram, const uint8* locD intptr DbgModule::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, int locDataLen, WdStackFrame* stackFrame, DbgAddrType* outAddrType, DbgEvalLocFlags flags) { BP_ZONE("DebugTarget::EvaluateLocation"); - + auto dbgModule = this; if (locDataLen == DbgLocationLenKind_SegPlusOffset) @@ -6971,14 +6971,14 @@ void DbgModule::ProcessHotSwapVariables() for (auto staticVariable : mStaticVariables) { bool replaceVariable = false; - + const char* findName = staticVariable->GetMappedName(); auto itr = linkedModule->mStaticVariableMap.find(findName); if (itr != linkedModule->mStaticVariableMap.end()) { DbgVariable* oldVariable = itr->second; // If the old static field has the same type as the new static field then we keep the same - // address, otherwise we use the new (zeroed-out) allocated space + // address, otherwise we use the new (zeroed-out) allocated space auto _GetNewAddress = [&]() { @@ -7001,7 +7001,7 @@ void DbgModule::ProcessHotSwapVariables() if (oldVariable->mType->IsSizedArray()) { mDebugTarget->GetCompilerSettings(); - + bool doMerge = strstr(oldVariable->mName, "sBfClassVData") != NULL; bool keepInPlace = (doMerge) && (strstr(oldVariable->mName, ".vext") == NULL); if (doMerge) @@ -7010,7 +7010,7 @@ void DbgModule::ProcessHotSwapVariables() addr_target newAddress = _GetNewAddress(); if (newAddress == 0) continue; - + uint8* newData = GetHotTargetData(newAddress); int newArraySize = (int)staticVariable->mType->GetByteCount(); int oldArraySize = (int)oldVariable->mType->GetByteCount(); @@ -7069,7 +7069,7 @@ void DbgModule::ProcessHotSwapVariables() // Link the new table to the old extended table addr_target prevLinkage = 0; success = mDebugger->ReadMemory((intptr)oldAddress, sizeof(addr_target), &prevLinkage); - BF_ASSERT(success); + BF_ASSERT(success); success = mDebugger->WriteMemory((intptr)newAddress, &prevLinkage, sizeof(addr_target)); BF_ASSERT(success); @@ -7079,7 +7079,7 @@ void DbgModule::ProcessHotSwapVariables() keepInPlace = true; } - + if (keepInPlace) { // We have to maintain the OLD size because we can't overwrite the original bounds @@ -7088,7 +7088,7 @@ void DbgModule::ProcessHotSwapVariables() staticVariable->mLocationData = oldVariable->mLocationData; staticVariable->mCompileUnit = oldVariable->mCompileUnit; } - } + } else if (oldVariable->mType->Equals(staticVariable->mType)) { if (oldVariable->mType->IsStruct()) @@ -7120,7 +7120,7 @@ void DbgModule::ProcessHotSwapVariables() //staticVariable->mLocationLen = oldVariable->mLocationLen; //staticVariable->mLocationData = oldVariable->mLocationData; replaceVariable = false; - } + } else { BF_ASSERT(!oldVariable->mType->IsSizedArray()); @@ -7136,7 +7136,7 @@ void DbgModule::ProcessHotSwapVariables() if (oldSymbol != NULL) symbolVal->mValue = oldSymbol; } - } + } } else // Not found - new variable replaceVariable = true; @@ -7180,7 +7180,7 @@ DbgFileExistKind DbgModule::CheckSourceFileExist(const StringImpl& path) else existsKind = DbgFileExistKind_HasOldSourceCommand; } - } + } return existsKind; } @@ -7217,7 +7217,7 @@ void DbgModule::RevertWritingEnable() template static void RemoveInvalidRange(TRadixMap& radixMap, addr_target startAddr, int addrLength) -{ +{ radixMap.RemoveRange(startAddr, addrLength); } @@ -7257,7 +7257,7 @@ void DbgModule::RemoveTargetData() RemoveInvalidRange(mDebugTarget->mSubprogramMap, (addr_target)mImageBase, (int32)mImageSize); RemoveInvalidRange(mDebugTarget->mExceptionDirectoryMap, (addr_target)mImageBase, (int32)mImageSize); RemoveInvalidRange(mDebugTarget->mContribMap, (addr_target)mImageBase, (int32)mImageSize); - RemoveInvalidMapRange(mDebugTarget->mDwFrameDescriptorMap, (addr_target)mImageBase, (int32)mImageSize); + RemoveInvalidMapRange(mDebugTarget->mDwFrameDescriptorMap, (addr_target)mImageBase, (int32)mImageSize); RemoveInvalidMapRange(mDebugTarget->mCOFFFrameDescriptorMap, (addr_target)mImageBase, (int32)mImageSize); //mDebugTarget->mDwFrameDescriptorMap.erase() @@ -7294,7 +7294,7 @@ void DbgModule::ReportMemory(MemReporter* memReporter) memReporter->BeginSection("OrigImageData"); mOrigImageData->ReportMemory(memReporter); memReporter->EndSection(); - } + } } DbgType* DbgModule::GetPointerType(DbgType* innerType) @@ -7327,7 +7327,7 @@ DbgType* DbgModule::GetConstType(DbgType* innerType) auto linkedModule = GetLinkedModule(); BF_ASSERT(innerType->GetDbgModule()->GetLinkedModule() == linkedModule); - + /*auto itr = linkedModule->mConstTypes.find(innerType); if (itr != linkedModule->mConstTypes.end()) return itr->second;*/ @@ -7351,15 +7351,15 @@ DbgType* DbgModule::GetConstType(DbgType* innerType) } DbgType* DbgModule::GetPrimaryType(DbgType* dbgType) -{ +{ if (dbgType->mPriority <= DbgTypePriority_Normal) { if ((dbgType->mLanguage == DbgLanguage_Beef) && (dbgType->mName != NULL)) - { + { auto newTypeEntry = FindType(dbgType->mName, dbgType->mLanguage); - if (newTypeEntry != NULL) - { - DbgType* newType = newTypeEntry->mValue; + if (newTypeEntry != NULL) + { + DbgType* newType = newTypeEntry->mValue; if ((newType->mTypeCode == DbgType_Ptr) && (newType->IsBfObjectPtr())) newType = newType->mTypeParam; newType->mPriority = DbgTypePriority_Primary_Implicit; @@ -7370,7 +7370,7 @@ DbgType* DbgModule::GetPrimaryType(DbgType* dbgType) { auto newTypeEntry = FindType(dbgType->mName, dbgType->mLanguage); if (newTypeEntry != NULL) - { + { DbgType* newType = newTypeEntry->mValue; newType = newType->RemoveModifiers(); if (newType != dbgType) @@ -7403,7 +7403,7 @@ DbgType* DbgModule::FindTypeHelper(const String& typeName, DbgType* checkType) auto retType = FindTypeHelper(typeName, baseType->mBaseType); if (retType != NULL) return retType; - } + } return NULL; } @@ -7432,12 +7432,12 @@ DbgType* DbgModule::FindType(const String& typeName, DbgType* contextType, DbgLa } if (contextType != NULL) - { + { DbgType* checkType = contextType; if (checkType->IsPointer()) checkType = checkType->mTypeParam; - return FindTypeHelper(typeName, checkType); + return FindTypeHelper(typeName, checkType); } return NULL; } @@ -7449,7 +7449,7 @@ DbgTypeMap::Entry* DbgModule::FindType(const char* typeName, DbgLanguage languag /*auto& typeMap = GetLinkedModule()->mTypeMap; auto dbgTypeEntry = typeMap.Find(typeName); if (dbgTypeEntry == NULL) - return NULL; + return NULL; if (dbgTypeEntry->mValue->mLanguage == language) return dbgTypeEntry; while (dbgTypeEntry != NULL) @@ -7492,7 +7492,7 @@ DbgType* DbgModule::GetSizedArrayType(DbgType * elementType, int count) entry.mElementType = elementType; entry.mCount = count; if (mSizedArrayTypes.TryAdd(entry, NULL, &sizedArrayTypePtr)) - { + { BP_ALLOC_T(DbgType); auto sizedArrayType = mAlloc.Alloc(); sizedArrayType->mCompileUnit = elementType->mCompileUnit;