mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Made $alias$ work for splat parameters to mixins
This commit is contained in:
parent
004d5d8d1c
commit
70e751e718
11 changed files with 228 additions and 92 deletions
|
@ -1229,6 +1229,7 @@ void BeCOFFObject::DbgOutputLocalVar(BeDbgFunction* dbgFunc, BeDbgVariable* dbgV
|
|||
|
||||
bool isConst = false;
|
||||
String varName = dbgVar->mName;
|
||||
|
||||
bool isGlobal = false;
|
||||
//
|
||||
{
|
||||
|
@ -1245,6 +1246,8 @@ void BeCOFFObject::DbgOutputLocalVar(BeDbgFunction* dbgFunc, BeDbgVariable* dbgV
|
|||
if (!isGlobal)
|
||||
{
|
||||
if (auto beConst = BeValueDynCast<BeConstant>(dbgVar->mValue))
|
||||
{
|
||||
if (!beConst->mType->IsPointer())
|
||||
{
|
||||
int64 writeVal = beConst->mInt64;
|
||||
if (beConst->mType->mTypeCode == BfTypeCode_Single)
|
||||
|
@ -1260,6 +1263,7 @@ void BeCOFFObject::DbgOutputLocalVar(BeDbgFunction* dbgFunc, BeDbgVariable* dbgV
|
|||
isConst = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DbgEncodeString(outS, varName);
|
||||
DbgSEndTag();
|
||||
|
|
|
@ -2202,7 +2202,12 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
|
|||
}
|
||||
else
|
||||
{
|
||||
if (unrangedIdx >= deferredVariableLocations.size())
|
||||
if (localVar->mLocationData != NULL)
|
||||
{
|
||||
// Already handled
|
||||
NOP;
|
||||
}
|
||||
else if (unrangedIdx >= deferredVariableLocations.size())
|
||||
{
|
||||
// There was no ranged data, commit just the unranged entry
|
||||
BF_ASSERT(locationDataCount == localVar->mLocationLen);
|
||||
|
@ -2242,6 +2247,11 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
|
|||
if (deferredVariableLocation.mRangedLength == -1)
|
||||
continue;
|
||||
auto deferredVar = deferredVariableLocation.mVariable;
|
||||
if (deferredVar->mLocationData != NULL)
|
||||
{
|
||||
// Already handled
|
||||
continue;
|
||||
}
|
||||
BP_ALLOC("DeferredVarLoc2", deferredVariableLocation.mRangedLength);
|
||||
deferredVar->mLocationData = mAlloc.AllocBytes(deferredVariableLocation.mRangedLength, "DeferredVarLoc2");
|
||||
memcpy((uint8*)deferredVar->mLocationData, deferredVariableLocation.mRangedStart, deferredVariableLocation.mRangedLength);
|
||||
|
@ -3205,6 +3215,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
|
|||
locationDataStart = dataStart;
|
||||
locationDataEnd = dataEnd;
|
||||
locationDataCount++;
|
||||
if (localVar->mLocationData == NULL)
|
||||
localVar->mLocationLen++;
|
||||
}
|
||||
}
|
||||
|
@ -3214,42 +3225,81 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
|
|||
|
||||
if (hasNewLocalVar)
|
||||
{
|
||||
if (localVar->mName != NULL)
|
||||
if ((localVar->mName != NULL) && (localVar->mName[0] == '$'))
|
||||
{
|
||||
char* aliasPos = (char*)strstr(localVar->mName, "$alias$");
|
||||
|
||||
// This $alias$ hack is unfortunate, but LLVM gets confused when we attempt to tie multiple debug variables
|
||||
// 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 (strncmp(localVar->mName, "$alias$", 7) == 0)
|
||||
if (aliasPos != NULL)
|
||||
{
|
||||
localVar->mName += 7;
|
||||
char* dollarPos = (char*)strchr(localVar->mName, '$');
|
||||
if (dollarPos != 0)
|
||||
{
|
||||
*dollarPos = 0;
|
||||
const char* findName = dollarPos + 1;
|
||||
String findName = String(aliasPos + 7);
|
||||
localVar->mName = CvDupString(localVar->mName + 1, aliasPos - localVar->mName - 1);
|
||||
|
||||
bool found = false;
|
||||
for (int blockIdx = (int)blockStack.size() - 1; blockIdx >= 0; blockIdx--)
|
||||
auto curBlock = blockStack.back();
|
||||
localVar->mLocationData = (uint8*)CvDupString(aliasPos + 7, strlen(aliasPos + 7));
|
||||
localVar->mRangeStart = curBlock->mLowPC;
|
||||
localVar->mRangeLen = curBlock->mHighPC - curBlock->mLowPC;
|
||||
|
||||
/*bool found = false;
|
||||
|
||||
auto _CheckBlock = [&](DbgBlock* block)
|
||||
{
|
||||
DbgBlock* block = blockStack[blockIdx];
|
||||
for (auto checkVar : block->mVariables)
|
||||
{
|
||||
if (strcmp(checkVar->mName, findName) == 0)
|
||||
if (checkVar->mName == NULL)
|
||||
continue;
|
||||
|
||||
if (findName == checkVar->mName)
|
||||
{
|
||||
localVar->mConstValue = checkVar->mConstValue;
|
||||
localVar->mType = checkVar->mType;
|
||||
localVar->mLocationData = checkVar->mLocationData;
|
||||
localVar->mLocationLen = checkVar->mLocationLen;
|
||||
|
||||
found = true;
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
for (int blockIdx = (int)blockStack.size() - 1; blockIdx >= 0; blockIdx--)
|
||||
{
|
||||
DbgBlock* block = blockStack[blockIdx];
|
||||
if (_CheckBlock(block))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
addr_target checkAddr = 0;
|
||||
DbgSubprogram* checkSubprogram = curSubprogram;
|
||||
|
||||
while (checkSubprogram != NULL)
|
||||
{
|
||||
auto checkAddr = checkSubprogram->mBlock.mLowPC;
|
||||
if (checkSubprogram->mInlineeInfo == NULL)
|
||||
break;
|
||||
checkSubprogram = checkSubprogram->mInlineeInfo->mInlineParent;
|
||||
|
||||
std::function<void(DbgBlock*)> _RecurseBlock = [&](DbgBlock* block)
|
||||
{
|
||||
if ((checkAddr < block->mLowPC) || (checkAddr >= block->mHighPC))
|
||||
return;
|
||||
|
||||
if (_CheckBlock(block))
|
||||
return;
|
||||
|
||||
for (auto block : block->mSubBlocks)
|
||||
_RecurseBlock(block);
|
||||
};
|
||||
|
||||
_RecurseBlock(&checkSubprogram->mBlock);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if (compileUnit->mLanguage != DbgLanguage_Beef)
|
||||
|
@ -6039,15 +6089,22 @@ void COFF::FinishHotSwap()
|
|||
mTypeMap.Clear();
|
||||
}
|
||||
|
||||
addr_target COFF::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, int locDataLen, WdStackFrame* stackFrame, DbgAddrType* outAddrType, DbgEvalLocFlags flags)
|
||||
intptr COFF::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, int locDataLen, WdStackFrame* stackFrame, DbgAddrType* outAddrType, DbgEvalLocFlags flags)
|
||||
{
|
||||
if (mDbgFlavor == DbgFlavor_GNU)
|
||||
return DbgModule::EvaluateLocation(dwSubprogram, locData, locDataLen, stackFrame, outAddrType, flags);
|
||||
|
||||
if ((locDataLen == 0) && (locData != NULL))
|
||||
{
|
||||
// locData is actually a string, the aliased name
|
||||
*outAddrType = DbgAddrType_Alias;
|
||||
return (intptr)locData;
|
||||
}
|
||||
|
||||
addr_target pc = 0;
|
||||
if (stackFrame != NULL)
|
||||
{
|
||||
// Use 'GetSourcePC', which will offset the RSP when we're not at the top positon 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();
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@ public:
|
|||
virtual void PopulateStaticVariableMap() override;
|
||||
virtual void ProcessDebugInfo() override;
|
||||
virtual void FinishHotSwap() override;
|
||||
virtual addr_target EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, int locDataLen, WdStackFrame* stackFrame, DbgAddrType* outAddrType, DbgEvalLocFlags flags = DbgEvalLocFlag_None) override;
|
||||
virtual intptr EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, int locDataLen, WdStackFrame* stackFrame, DbgAddrType* outAddrType, DbgEvalLocFlags flags = DbgEvalLocFlag_None) override;
|
||||
virtual bool CanGetOldSource() override;
|
||||
virtual String GetOldSourceCommand(const StringImpl& path) override;
|
||||
virtual bool HasPendingDebugInfo() override;
|
||||
|
|
|
@ -12653,18 +12653,26 @@ void BfExprEvaluator::InjectMixin(BfAstNode* targetSrc, BfTypedValue target, boo
|
|||
{
|
||||
if (localVar == newLocalVar)
|
||||
continue;
|
||||
if (newLocalVar->mValue != localVar->mValue)
|
||||
if (!localVar->mIsSplat)
|
||||
continue;
|
||||
if (newLocalVar->mValue != localVar->mAddr)
|
||||
continue;
|
||||
|
||||
String name = newLocalVar->mName;
|
||||
String name = "$";
|
||||
name += newLocalVar->mName;
|
||||
name += "$alias$";
|
||||
name += localVar->mName;
|
||||
|
||||
auto fakeValue = mModule->mBfIRBuilder->CreateConst(BfTypeCode_Int32, 0);
|
||||
auto diType = mModule->mBfIRBuilder->DbgGetType(mModule->GetPrimitiveType(BfTypeCode_Int32));
|
||||
// auto fakeValue = mModule->mBfIRBuilder->CreateConst(BfTypeCode_Int32, 0);
|
||||
// auto diType = mModule->mBfIRBuilder->DbgGetType(mModule->GetPrimitiveType(BfTypeCode_Int32));
|
||||
// auto diVariable = mModule->mBfIRBuilder->DbgCreateAutoVariable(mModule->mCurMethodState->mCurScope->mDIScope,
|
||||
// name, mModule->mCurFilePosition.mFileInstance->mDIFile, mModule->mCurFilePosition.mCurLine, diType);
|
||||
// mModule->mBfIRBuilder->DbgInsertValueIntrinsic(fakeValue, diVariable);
|
||||
|
||||
auto diType = mModule->mBfIRBuilder->DbgGetType(mModule->GetPrimitiveType(BfTypeCode_NullPtr));
|
||||
auto diVariable = mModule->mBfIRBuilder->DbgCreateAutoVariable(mModule->mCurMethodState->mCurScope->mDIScope,
|
||||
newLocalVar->mName, mModule->mCurFilePosition.mFileInstance->mDIFile, mModule->mCurFilePosition.mCurLine, diType);
|
||||
mModule->mBfIRBuilder->DbgInsertValueIntrinsic(fakeValue, diVariable);
|
||||
name, mModule->mCurFilePosition.mFileInstance->mDIFile, mModule->mCurFilePosition.mCurLine, diType);
|
||||
mModule->mBfIRBuilder->DbgInsertValueIntrinsic(mModule->mBfIRBuilder->CreateConstNull(), diVariable);
|
||||
|
||||
found = true;
|
||||
break;
|
||||
|
|
|
@ -1136,7 +1136,7 @@ DbgTypedValue DbgExprEvaluator::GetBeefTypeById(int typeId)
|
|||
{
|
||||
auto stackFrame = GetStackFrame();
|
||||
DbgAddrType addrType;
|
||||
int64 valAddr = member->mCompileUnit->mDbgModule->EvaluateLocation(NULL, member->mLocationData, member->mLocationLen, stackFrame, &addrType);
|
||||
intptr valAddr = member->mCompileUnit->mDbgModule->EvaluateLocation(NULL, member->mLocationData, member->mLocationLen, stackFrame, &addrType);
|
||||
if (valAddr != 0)
|
||||
{
|
||||
DbgTypedValue typedVal;
|
||||
|
@ -1470,12 +1470,12 @@ DbgTypedValue DbgExprEvaluator::GetThis()
|
|||
if (mDebugTarget->GetValueByName(GetCurrentMethod(), findName, stackFrame, &valAddr, &valType, &addrType))
|
||||
{
|
||||
//valType = valType->RemoveModifiers();
|
||||
return FixThis(ReadTypedValue(valType, valAddr, addrType));
|
||||
return FixThis(ReadTypedValue(NULL, valType, valAddr, addrType));
|
||||
}
|
||||
|
||||
if (mDebugTarget->GetValueByName(GetCurrentMethod(), "__closure", stackFrame, &valAddr, &valType, &addrType))
|
||||
{
|
||||
DbgTypedValue result = ReadTypedValue(valType, valAddr, addrType);
|
||||
DbgTypedValue result = ReadTypedValue(NULL, valType, valAddr, addrType);
|
||||
if (!result)
|
||||
return result;
|
||||
SetAndRestoreValue<bool> prevIgnoreError(mIgnoreErrors, true);
|
||||
|
@ -1849,7 +1849,7 @@ DbgTypedValue DbgExprEvaluator::Cast(BfAstNode* srcNode, const DbgTypedValue& ty
|
|||
findName += "$d";
|
||||
if (mDebugTarget->GetValueByName(GetCurrentMethod(), findName, GetStackFrame(), &valAddr, &valType, &addrType))
|
||||
{
|
||||
return ReadTypedValue(valType, valAddr, addrType);
|
||||
return ReadTypedValue(srcNode, valType, valAddr, addrType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2535,7 +2535,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu
|
|||
if (checkMember->mLocationLen != 0)
|
||||
{
|
||||
DbgAddrType addrType;
|
||||
int64 valAddr = checkMember->mCompileUnit->mDbgModule->EvaluateLocation(NULL, checkMember->mLocationData, checkMember->mLocationLen, stackFrame, &addrType);
|
||||
intptr valAddr = checkMember->mCompileUnit->mDbgModule->EvaluateLocation(NULL, checkMember->mLocationData, checkMember->mLocationLen, stackFrame, &addrType);
|
||||
if ((language == DbgLanguage_Beef) && (checkMember->mType->IsConst()) && (checkMember->mType->mTypeParam->IsSizedArray()))
|
||||
{
|
||||
// We need an extra deref
|
||||
|
@ -2544,11 +2544,11 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu
|
|||
|
||||
if (checkMember->mIsConst)
|
||||
addrType = DbgAddrType_Value;
|
||||
return ReadTypedValue(checkMember->mType, valAddr, addrType);
|
||||
return ReadTypedValue(targetSrc, checkMember->mType, valAddr, addrType);
|
||||
}
|
||||
else if (checkMember->mIsConst)
|
||||
{
|
||||
return ReadTypedValue(checkMember->mType, (uint64)&checkMember->mConstValue, DbgAddrType_Local);
|
||||
return ReadTypedValue(targetSrc, checkMember->mType, (uint64)&checkMember->mConstValue, DbgAddrType_Local);
|
||||
}
|
||||
else if (checkMember->mIsStatic)
|
||||
{
|
||||
|
@ -2583,14 +2583,14 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu
|
|||
}
|
||||
else if ((targetPtr == 0) && (target.mPtr != 0) && (!target.mType->HasPointer()))
|
||||
{
|
||||
typedValue = ReadTypedValue(checkMember->mType, (uint64)&target.mPtr + checkMember->mMemberOffset, DbgAddrType_Local);
|
||||
typedValue = ReadTypedValue(targetSrc, checkMember->mType, (uint64)&target.mPtr + checkMember->mMemberOffset, DbgAddrType_Local);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (target.mType->HasPointer())
|
||||
targetPtr = target.mPtr;
|
||||
|
||||
typedValue = ReadTypedValue(checkMember->mType, targetPtr + checkMember->mMemberOffset, DbgAddrType_Target);
|
||||
typedValue = ReadTypedValue(targetSrc, checkMember->mType, targetPtr + checkMember->mMemberOffset, DbgAddrType_Target);
|
||||
}
|
||||
|
||||
if (checkMember->mBitSize != 0)
|
||||
|
@ -2850,10 +2850,44 @@ void DbgExprEvaluator::Visit(BfAstNode* node)
|
|||
Fail("Invalid debug expression", node);
|
||||
}
|
||||
|
||||
DbgTypedValue DbgExprEvaluator::ReadTypedValue(DbgType* dbgType, uint64 valAddr, DbgAddrType addrType)
|
||||
DbgTypedValue DbgExprEvaluator::ReadTypedValue(BfAstNode* targetSrc, DbgType* dbgType, uint64 valAddr, DbgAddrType addrType)
|
||||
{
|
||||
bool failedReadMemory = false;
|
||||
|
||||
if (addrType == DbgAddrType_Alias)
|
||||
{
|
||||
String findName = (const char*)valAddr;
|
||||
|
||||
if (targetSrc == NULL)
|
||||
return DbgTypedValue();
|
||||
|
||||
auto source = targetSrc->GetSourceData();
|
||||
auto bfParser = source->ToParser();
|
||||
if (bfParser == NULL)
|
||||
return DbgTypedValue();
|
||||
|
||||
auto identifierNode = source->mAlloc.Alloc<BfIdentifierNode>();
|
||||
int srcStart = bfParser->AllocChars(findName.length());
|
||||
memcpy((char*)source->mSrc + srcStart, findName.c_str(), findName.length());
|
||||
identifierNode->Init(srcStart, srcStart, srcStart + findName.length());
|
||||
|
||||
SetAndRestoreValue<bool> 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))
|
||||
{
|
||||
SetAndRestoreValue<int> preCallstackIdx(mCallStackIdx);
|
||||
mCallStackIdx++;
|
||||
result = LookupIdentifier(identifierNode);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
if (addrType == DbgAddrType_LocalSplat)
|
||||
{
|
||||
DbgTypedValue val;
|
||||
|
@ -2866,7 +2900,7 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(DbgType* dbgType, uint64 valAddr,
|
|||
|
||||
if (addrType == DbgAddrType_TargetDeref)
|
||||
{
|
||||
DbgTypedValue result = ReadTypedValue(dbgType, valAddr, DbgAddrType_Target);
|
||||
DbgTypedValue result = ReadTypedValue(targetSrc, dbgType, valAddr, DbgAddrType_Target);
|
||||
if ((result.mType != NULL) && (result.mType->IsPointer()))
|
||||
{
|
||||
result.mType = result.mType->mTypeParam;
|
||||
|
@ -2945,7 +2979,7 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(DbgType* dbgType, uint64 valAddr,
|
|||
if (dbgType->mTypeCode == DbgType_Bitfield)
|
||||
{
|
||||
DbgType* underlyingType = dbgType->mTypeParam;
|
||||
DbgTypedValue result = ReadTypedValue(dbgType->mTypeParam, valAddr, addrType);
|
||||
DbgTypedValue result = ReadTypedValue(targetSrc, dbgType->mTypeParam, valAddr, addrType);
|
||||
result.mType = dbgType;
|
||||
|
||||
auto dbgBitfieldType = (DbgBitfieldType*)dbgType;
|
||||
|
@ -3084,7 +3118,7 @@ DbgTypedValue DbgExprEvaluator::ReadTypedValue(DbgType* dbgType, uint64 valAddr,
|
|||
break;
|
||||
|
||||
case DbgType_Enum:
|
||||
result = ReadTypedValue(dbgType->mTypeParam, valAddr, addrType);
|
||||
result = ReadTypedValue(targetSrc, dbgType->mTypeParam, valAddr, addrType);
|
||||
if (result)
|
||||
result.mType = dbgType;
|
||||
break;
|
||||
|
@ -3632,7 +3666,7 @@ DbgTypedValue DbgExprEvaluator::LookupIdentifier(BfAstNode* identifierNode, bool
|
|||
{
|
||||
if (mSubjectValue.mSrcAddress != 0)
|
||||
{
|
||||
auto refreshVal = ReadTypedValue(mSubjectValue.mType, mSubjectValue.mSrcAddress, DbgAddrType_Target);
|
||||
auto refreshVal = ReadTypedValue(identifierNode, mSubjectValue.mType, mSubjectValue.mSrcAddress, DbgAddrType_Target);
|
||||
if (refreshVal)
|
||||
mSubjectValue = refreshVal;
|
||||
}
|
||||
|
@ -3678,7 +3712,7 @@ DbgTypedValue DbgExprEvaluator::LookupIdentifier(BfAstNode* identifierNode, bool
|
|||
//bool isLocal = !valIsAddr;
|
||||
//if (valType->IsCompositeType())
|
||||
//isLocal = false;
|
||||
return ReadTypedValue(valType, valAddr, addrType);
|
||||
return ReadTypedValue(identifierNode, valType, valAddr, addrType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3693,7 +3727,7 @@ DbgTypedValue DbgExprEvaluator::LookupIdentifier(BfAstNode* identifierNode, bool
|
|||
//bool valIsAddr = false;
|
||||
if (mDebugTarget->GetValueByName(GetCurrentMethod(), "__closure", stackFrame, &valAddr, &valType, &addrType))
|
||||
{
|
||||
DbgTypedValue closureValue = ReadTypedValue(valType, valAddr, addrType);
|
||||
DbgTypedValue closureValue = ReadTypedValue(identifierNode, valType, valAddr, addrType);
|
||||
if (closureValue)
|
||||
{
|
||||
SetAndRestoreValue<bool> prevIgnoreError(mIgnoreErrors, true);
|
||||
|
@ -4634,7 +4668,7 @@ void DbgExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
|
|||
return;
|
||||
}
|
||||
|
||||
auto result = ReadTypedValue(typeVariable->mType, collection.mPtr + typeVariable->mMemberOffset + (idx * typeVariable->mType->GetStride()), DbgAddrType_Target);
|
||||
auto result = ReadTypedValue(indexerExpr, typeVariable->mType, collection.mPtr + typeVariable->mMemberOffset + (idx * typeVariable->mType->GetStride()), DbgAddrType_Target);
|
||||
if (mResult.mIsReadOnly)
|
||||
result.mIsReadOnly = true;
|
||||
mResult = result;
|
||||
|
@ -4713,7 +4747,7 @@ void DbgExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
|
|||
}
|
||||
|
||||
auto memberType = collection.mType->mTypeParam;
|
||||
auto result = ReadTypedValue(memberType, target + indexArgument.GetInt64() * memberType->GetStride(), DbgAddrType_Target);
|
||||
auto result = ReadTypedValue(indexerExpr, memberType, target + indexArgument.GetInt64() * memberType->GetStride(), DbgAddrType_Target);
|
||||
if (mResult.mIsReadOnly)
|
||||
result.mIsReadOnly = true;
|
||||
mResult = result;
|
||||
|
@ -4859,19 +4893,21 @@ void DbgExprEvaluator::LookupSplatMember(const DbgTypedValue& target, const Stri
|
|||
{
|
||||
if (mReferenceId != NULL)
|
||||
*mReferenceId = findName;
|
||||
mResult = ReadTypedValue(valType, valAddr, addrType);
|
||||
mResult = ReadTypedValue(NULL, valType, valAddr, addrType);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* lookupNode, const DbgTypedValue& target, const StringImpl& fieldName, String* outFindName, bool* outIsConst)
|
||||
void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* lookupNode, const DbgTypedValue& target, const StringImpl& fieldName, String* outFindName, bool* outIsConst, StringImpl* forceName)
|
||||
{
|
||||
/*DbgVariable* dbgVariable = (DbgVariable*)target.mVariable;
|
||||
if (dbgVariable != NULL)
|
||||
return LookupSplatMember(target, fieldName);*/
|
||||
|
||||
auto curMethod = GetCurrentMethod();
|
||||
|
||||
while (auto parenNode = BfNodeDynCast<BfParenthesizedExpression>(lookupNode))
|
||||
lookupNode = parenNode->mExpression;
|
||||
|
||||
|
@ -4882,7 +4918,7 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku
|
|||
{
|
||||
//
|
||||
}
|
||||
else
|
||||
else if (forceName == NULL)
|
||||
{
|
||||
if (outFindName != NULL)
|
||||
*outFindName = splatLookupEntry->mFindName;
|
||||
|
@ -4939,6 +4975,9 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku
|
|||
return;
|
||||
}
|
||||
|
||||
if (forceName != NULL)
|
||||
findName = *forceName;
|
||||
|
||||
CPUStackFrame* stackFrame = GetStackFrame();
|
||||
intptr valAddr;
|
||||
DbgType* valType = NULL;
|
||||
|
@ -4975,8 +5014,27 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku
|
|||
|
||||
if (!foundParent)
|
||||
{
|
||||
if (!mDebugTarget->GetValueByName(GetCurrentMethod(), findName, stackFrame, &valAddr, &valType, &addrType))
|
||||
if (!mDebugTarget->GetValueByName(curMethod, findName, stackFrame, &valAddr, &valType, &addrType))
|
||||
return;
|
||||
|
||||
if (addrType == DbgAddrType_Alias)
|
||||
{
|
||||
findName = (const char*)valAddr;
|
||||
|
||||
if (!mDebugTarget->GetValueByName(curMethod, findName, stackFrame, &valAddr, &valType, &addrType))
|
||||
{
|
||||
if (curMethod->mInlineeInfo != NULL)
|
||||
{
|
||||
// Look outside to inline
|
||||
SetAndRestoreValue<int> prevStackIdx(mCallStackIdx, mCallStackIdx + 1);
|
||||
LookupSplatMember(targetNode, lookupNode, target, fieldName, outFindName, outIsConst, &findName);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (addrType == DbgAddrType_LocalSplat)
|
||||
{
|
||||
DbgVariable* dbgVariable = (DbgVariable*)valAddr;
|
||||
|
@ -5048,7 +5106,7 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku
|
|||
if (outIsConst != NULL)
|
||||
*outIsConst = wantConst;
|
||||
|
||||
if (mDebugTarget->GetValueByName(GetCurrentMethod(), findName, stackFrame, &valAddr, &valType, &addrType))
|
||||
if (mDebugTarget->GetValueByName(curMethod, findName, stackFrame, &valAddr, &valType, &addrType))
|
||||
{
|
||||
BF_ASSERT(valType != NULL);
|
||||
|
||||
|
@ -5061,7 +5119,7 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku
|
|||
// Set readonly if the original value was const
|
||||
memberType = mDbgModule->GetConstType(valType);
|
||||
}*/
|
||||
mResult = ReadTypedValue(memberType, valAddr, addrType);
|
||||
mResult = ReadTypedValue(targetNode, memberType, valAddr, addrType);
|
||||
if (wantConst)
|
||||
{
|
||||
// Set readonly if the original value was const
|
||||
|
@ -5073,6 +5131,14 @@ void DbgExprEvaluator::LookupSplatMember(BfAstNode* targetNode, BfAstNode* looku
|
|||
{
|
||||
if (target.mSrcAddress == -1)
|
||||
{
|
||||
// if (curMethod->mInlineeInfo != NULL)
|
||||
// {
|
||||
// // Look outside to inline
|
||||
// SetAndRestoreValue<int> prevStackIdx(mCallStackIdx, mCallStackIdx + 1);
|
||||
// LookupSplatMember(targetNode, lookupNode, target, fieldName, outFindName, outIsConst, true);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (!memberType->IsStruct())
|
||||
Fail("Failed to lookup splat member", (lookupNode != NULL) ? lookupNode : targetNode);
|
||||
|
||||
|
@ -6348,7 +6414,7 @@ void DbgExprEvaluator::PerformUnaryExpression(BfAstNode* opToken, BfUnaryOp unar
|
|||
Fail("Operator can only be used on pointer values", opToken);
|
||||
return;
|
||||
}
|
||||
mResult = ReadTypedValue(type->mTypeParam, mResult.mPtr, DbgAddrType_Target);
|
||||
mResult = ReadTypedValue(opToken, type->mTypeParam, mResult.mPtr, DbgAddrType_Target);
|
||||
}
|
||||
break;
|
||||
case BfUnaryOp_AddressOf:
|
||||
|
@ -6529,7 +6595,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, DbgTypedValue
|
|||
auto returnType = method->mReturnType->RemoveModifiers(&hadRef);
|
||||
if (hadRef)
|
||||
{
|
||||
returnVal = ReadTypedValue(returnType, returnVal.mPtr, DbgAddrType_Target);
|
||||
returnVal = ReadTypedValue(NULL, returnType, returnVal.mPtr, DbgAddrType_Target);
|
||||
returnVal.mType = returnType;
|
||||
}
|
||||
}
|
||||
|
@ -6689,7 +6755,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t
|
|||
|
||||
if (!type->IsCompositeType())
|
||||
{
|
||||
auto elemTypedValue = ReadTypedValue(type, typedVal.mSrcAddress, DbgAddrType_Target);
|
||||
auto elemTypedValue = ReadTypedValue(targetSrc, type, typedVal.mSrcAddress, DbgAddrType_Target);
|
||||
DbgMethodArgument methodArg;
|
||||
methodArg.mTypedValue = elemTypedValue;
|
||||
argPushQueue.push_back(methodArg);
|
||||
|
|
|
@ -301,7 +301,7 @@ public:
|
|||
bool mIsComplexExpression;
|
||||
|
||||
public:
|
||||
DbgTypedValue ReadTypedValue(DbgType* type, uint64 valAddr, DbgAddrType addrType);
|
||||
DbgTypedValue ReadTypedValue(BfAstNode* targetSrc, DbgType* type, uint64 valAddr, DbgAddrType addrType);
|
||||
bool CheckTupleCreation(addr_target receiveAddr, BfAstNode* targetSrc, DbgType* tupleType, const BfSizedArray<BfExpression*>& argValues, BfSizedArray<BfTupleNameNode*>* names);
|
||||
DbgTypedValue CheckEnumCreation(BfAstNode* targetSrc, DbgType* enumType, const StringImpl& caseName, const BfSizedArray<BfExpression*>& argValues);
|
||||
void DoInvocation(BfAstNode* target, BfSizedArray<ASTREF(BfExpression*)>& args, BfSizedArray<ASTREF(BfTypeReference*)>* methodGenericArguments);
|
||||
|
@ -369,7 +369,7 @@ public:
|
|||
DbgTypedValue LookupField(BfAstNode* targetSrc, DbgTypedValue target, const StringImpl& fieldName);
|
||||
DbgTypedValue LookupIdentifier(BfAstNode* identifierNode, bool ignoreInitialError = false, bool* hadError = NULL);
|
||||
void LookupSplatMember(const DbgTypedValue& target, const StringImpl& fieldName);
|
||||
void LookupSplatMember(BfAstNode* srcNode, BfAstNode* lookupNode, const DbgTypedValue& target, const StringImpl& fieldName, String* outFindName = NULL, bool* outIsConst = NULL);
|
||||
void LookupSplatMember(BfAstNode* srcNode, BfAstNode* lookupNode, const DbgTypedValue& target, const StringImpl& fieldName, String* outFindName = NULL, bool* outIsConst = NULL, StringImpl* forceName = NULL);
|
||||
void LookupQualifiedName(BfQualifiedNameNode* nameNode, bool ignoreInitialError = false, bool* hadError = NULL);
|
||||
DbgType* FindSubtype(DbgType* type, const StringImpl& name);
|
||||
void LookupQualifiedStaticField(BfQualifiedNameNode* nameNode, bool ignoreIdentifierNotFoundError = false);
|
||||
|
|
|
@ -6705,7 +6705,7 @@ addr_target DbgModule::ExecuteOps(DbgSubprogram* dwSubprogram, const uint8* locD
|
|||
}
|
||||
|
||||
BF_ASSERT(nonInlinedSubProgram->mFrameBaseData != NULL);
|
||||
uint64 loc = EvaluateLocation(nonInlinedSubProgram, nonInlinedSubProgram->mFrameBaseData, nonInlinedSubProgram->mFrameBaseLen, stackFrame, outAddrType, DbgEvalLocFlag_DisallowReg);
|
||||
intptr loc = EvaluateLocation(nonInlinedSubProgram, nonInlinedSubProgram->mFrameBaseData, nonInlinedSubProgram->mFrameBaseLen, stackFrame, outAddrType, DbgEvalLocFlag_DisallowReg);
|
||||
int64 offset = DecodeSLEB128(locData);
|
||||
loc += offset;
|
||||
//loc = BfDebuggerReadMemory(loc);
|
||||
|
@ -6829,7 +6829,7 @@ addr_target DbgModule::ExecuteOps(DbgSubprogram* dwSubprogram, const uint8* locD
|
|||
return stackFrameData[--stackIdx];
|
||||
}
|
||||
|
||||
addr_target DbgModule::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, int locDataLen, WdStackFrame* stackFrame, DbgAddrType* outAddrType, DbgEvalLocFlags flags)
|
||||
intptr DbgModule::EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, int locDataLen, WdStackFrame* stackFrame, DbgAddrType* outAddrType, DbgEvalLocFlags flags)
|
||||
{
|
||||
BP_ZONE("DebugTarget::EvaluateLocation");
|
||||
|
||||
|
|
|
@ -1297,7 +1297,7 @@ public:
|
|||
int64 GetImageSize();
|
||||
virtual void FinishHotSwap();
|
||||
addr_target ExecuteOps(DbgSubprogram* dwSubprogram, const uint8* locData, int locDataLen, WdStackFrame* stackFrame, CPURegisters* registers, DbgAddrType* outAddrType, DbgEvalLocFlags flags, addr_target* pushValue = NULL);
|
||||
virtual addr_target EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, int locDataLen, WdStackFrame* stackFrame, DbgAddrType* outAddrType, DbgEvalLocFlags flags = DbgEvalLocFlag_None);
|
||||
virtual intptr EvaluateLocation(DbgSubprogram* dwSubprogram, const uint8* locData, int locDataLen, WdStackFrame* stackFrame, DbgAddrType* outAddrType, DbgEvalLocFlags flags = DbgEvalLocFlag_None);
|
||||
|
||||
//const uint8* CopyOrigImageData(addr_target address, int length);
|
||||
|
||||
|
|
|
@ -57,7 +57,8 @@ enum DbgAddrType : uint8
|
|||
DbgAddrType_TargetDeref,
|
||||
DbgAddrType_Register,
|
||||
DbgAddrType_OptimizedOut,
|
||||
DbgAddrType_NoValue
|
||||
DbgAddrType_NoValue,
|
||||
DbgAddrType_Alias
|
||||
};
|
||||
|
||||
NS_BF_END
|
|
@ -543,7 +543,7 @@ void DebugTarget::EvaluateAutoStaticVariable(DbgVariable* variable, const String
|
|||
if ((variable->mLocationData != NULL) && (variable->mLocationLen > 0))
|
||||
{
|
||||
DbgAddrType addrType = DbgAddrType_Local;
|
||||
addr_target variableAddr = variable->mStaticCachedAddr;
|
||||
intptr variableAddr = variable->mStaticCachedAddr;
|
||||
if (variableAddr == 0)
|
||||
{
|
||||
addrType = DbgAddrType_Target;
|
||||
|
@ -2198,7 +2198,7 @@ bool DebugTarget::GetVariableIndexRegisterAndOffset(DbgVariable* dwVariable, int
|
|||
addr_target DebugTarget::GetStaticAddress(DbgVariable* dwVariable)
|
||||
{
|
||||
DbgAddrType addrType;
|
||||
return dwVariable->mCompileUnit->mDbgModule->EvaluateLocation(NULL, dwVariable->mLocationData, dwVariable->mLocationLen, NULL, &addrType);
|
||||
return (addr_target)dwVariable->mCompileUnit->mDbgModule->EvaluateLocation(NULL, dwVariable->mLocationData, dwVariable->mLocationLen, NULL, &addrType);
|
||||
}
|
||||
|
||||
bool DebugTarget::GetValueByNameInBlock_Helper(DbgSubprogram* dwSubprogram, DbgBlock* dwBlock, String& name, WdStackFrame* stackFrame, intptr* outAddr, DbgType** outType, DbgAddrType* outAddrType)
|
||||
|
|
|
@ -7033,7 +7033,7 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
|
|||
if (ptrVal != 0)
|
||||
{
|
||||
DbgExprEvaluator dbgExprEvaluator(this, dbgModule, NULL, -1, -1);
|
||||
DbgTypedValue innerTypedVal = dbgExprEvaluator.ReadTypedValue(innerType, typedValue.mPtr, DbgAddrType_Target);
|
||||
DbgTypedValue innerTypedVal = dbgExprEvaluator.ReadTypedValue(NULL, innerType, typedValue.mPtr, DbgAddrType_Target);
|
||||
if (innerTypedVal)
|
||||
{
|
||||
DwFormatInfo defaultFormatInfo;
|
||||
|
@ -9115,7 +9115,7 @@ String WinDebugger::EvaluateContinue(DbgPendingExpr* pendingExpr, BfPassInstance
|
|||
else if ((underlyingType->IsStruct()) && (exprResult.mSrcAddress != 0) && (underlyingType->IsTypedPrimitive()))
|
||||
{
|
||||
auto primType = underlyingType->GetRootBaseType();
|
||||
DbgTypedValue primVal = dbgExprEvaluator.ReadTypedValue(primType, exprResult.mSrcAddress, DbgAddrType_Target);
|
||||
DbgTypedValue primVal = dbgExprEvaluator.ReadTypedValue(NULL, primType, exprResult.mSrcAddress, DbgAddrType_Target);
|
||||
|
||||
String primResult = DbgTypedValueToString(primVal, "", pendingExpr->mFormatInfo, NULL);
|
||||
int crPos = (int)primResult.IndexOf('\n');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue