mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Fixed sTypes lookups with LLVM debug info
This commit is contained in:
parent
78cdfd5d24
commit
dbbbed4528
4 changed files with 44 additions and 22 deletions
|
@ -1134,31 +1134,47 @@ DbgTypedValue DbgExprEvaluator::GetBeefTypeById(int typeId)
|
||||||
if (mDebugTarget->mTargetBinary == NULL)
|
if (mDebugTarget->mTargetBinary == NULL)
|
||||||
return DbgTypedValue();
|
return DbgTypedValue();
|
||||||
|
|
||||||
|
if (mDebugTarget->mTargetBinary->mBfTypesInfoAddr == 0)
|
||||||
|
{
|
||||||
|
mDebugTarget->mTargetBinary->mBfTypesInfoAddr = -1;
|
||||||
|
|
||||||
mDebugTarget->mTargetBinary->ParseTypeData();
|
mDebugTarget->mTargetBinary->ParseTypeData();
|
||||||
auto typeTypeEntry = mDebugTarget->mTargetBinary->FindType("System.Type", DbgLanguage_Beef);
|
auto typeTypeEntry = mDebugTarget->mTargetBinary->FindType("System.Type", DbgLanguage_Beef);
|
||||||
if ((typeTypeEntry == NULL) || (typeTypeEntry->mValue == NULL))
|
if ((typeTypeEntry != NULL) && (typeTypeEntry->mValue != NULL))
|
||||||
return DbgTypedValue();
|
{
|
||||||
|
|
||||||
auto typeType = typeTypeEntry->mValue;
|
auto typeType = typeTypeEntry->mValue;
|
||||||
|
mDebugTarget->mTargetBinary->mBfTypeType = typeType;
|
||||||
if (typeType->mNeedsGlobalsPopulated)
|
if (typeType->mNeedsGlobalsPopulated)
|
||||||
typeType->mCompileUnit->mDbgModule->PopulateTypeGlobals(typeType);
|
typeType->mCompileUnit->mDbgModule->PopulateTypeGlobals(typeType);
|
||||||
|
|
||||||
for (auto member : typeType->mMemberList)
|
for (auto member : typeType->mMemberList)
|
||||||
{
|
{
|
||||||
if ((member->mIsStatic) && (member->mName != NULL) && (strcmp(member->mName, "sTypes") == 0) && (member->mLocationData != NULL))
|
if ((member->mIsStatic) && (member->mName != NULL) && (strcmp(member->mName, "sTypes") == 0) && (member->mLocationData != NULL))
|
||||||
{
|
{
|
||||||
auto stackFrame = GetStackFrame();
|
auto stackFrame = GetStackFrame();
|
||||||
DbgAddrType addrType;
|
DbgAddrType addrType;
|
||||||
intptr valAddr = 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 (valAddr != 0)
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mDebugTarget->mTargetBinary->mBfTypesInfoAddr <= 0)
|
||||||
|
{
|
||||||
|
mDebugTarget->mTargetBinary->ParseSymbolData();
|
||||||
|
auto entry = mDebugTarget->mTargetBinary->mSymbolNameMap.Find("?sTypes@Type@System@bf@@2PEAPEAV123@A");
|
||||||
|
if (entry)
|
||||||
|
mDebugTarget->mTargetBinary->mBfTypesInfoAddr = entry->mValue->mAddress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mDebugTarget->mTargetBinary->mBfTypesInfoAddr > 0)
|
||||||
{
|
{
|
||||||
DbgTypedValue typedVal;
|
DbgTypedValue typedVal;
|
||||||
typedVal.mType = typeType;
|
typedVal.mType = mDebugTarget->mTargetBinary->mBfTypeType;
|
||||||
addr_target addr = valAddr + typeId * sizeof(addr_target);
|
addr_target addr = mDebugTarget->mTargetBinary->mBfTypesInfoAddr + typeId * sizeof(addr_target);
|
||||||
typedVal.mSrcAddress = mDebugger->ReadMemory<addr_target>(addr);
|
typedVal.mSrcAddress = mDebugger->ReadMemory<addr_target>(addr);
|
||||||
return typedVal;
|
return typedVal;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return DbgTypedValue();
|
return DbgTypedValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2196,6 +2196,8 @@ DbgModule::DbgModule(DebugTarget* debugTarget) : mDefaultCompileUnit(this)
|
||||||
mMayBeOld = false;
|
mMayBeOld = false;
|
||||||
mTimeStamp = 0;
|
mTimeStamp = 0;
|
||||||
mExpectedFileSize = 0;
|
mExpectedFileSize = 0;
|
||||||
|
mBfTypeType = NULL;
|
||||||
|
mBfTypesInfoAddr = 0;
|
||||||
|
|
||||||
mImageBase = 0;
|
mImageBase = 0;
|
||||||
mPreferredImageBase = 0;
|
mPreferredImageBase = 0;
|
||||||
|
|
|
@ -1162,6 +1162,9 @@ public:
|
||||||
String mVersion;
|
String mVersion;
|
||||||
String* mFailMsgPtr;
|
String* mFailMsgPtr;
|
||||||
|
|
||||||
|
DbgType* mBfTypeType;
|
||||||
|
intptr mBfTypesInfoAddr;
|
||||||
|
|
||||||
DbgModuleMemoryCache* mOrigImageData;
|
DbgModuleMemoryCache* mOrigImageData;
|
||||||
DbgCompileUnit* mMasterCompileUnit;
|
DbgCompileUnit* mMasterCompileUnit;
|
||||||
StrHashMap<DbgVariable*> mGlobalVarMap; // Dedups entries into mMasterCompileUnit
|
StrHashMap<DbgVariable*> mGlobalVarMap; // Dedups entries into mMasterCompileUnit
|
||||||
|
|
|
@ -1234,7 +1234,8 @@ String WinDebugger::GetDbgAllocInfo()
|
||||||
auto type = exprEvaluator.GetBeefTypeById(typeId);
|
auto type = exprEvaluator.GetBeefTypeById(typeId);
|
||||||
typeName.Clear();
|
typeName.Clear();
|
||||||
exprEvaluator.BeefTypeToString(type, typeName);
|
exprEvaluator.BeefTypeToString(type, typeName);
|
||||||
|
if (typeName.IsEmpty())
|
||||||
|
typeName = StrFormat("Type #%d", typeId);
|
||||||
result += StrFormat("type\t%d\t%s\t%lld\t%lld\n", typeId, typeName.c_str(), typeData.mCount, typeData.mSize);
|
result += StrFormat("type\t%d\t%s\t%lld\t%lld\n", typeId, typeName.c_str(), typeData.mCount, typeData.mSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue