mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +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,32 +1134,48 @@ DbgTypedValue DbgExprEvaluator::GetBeefTypeById(int typeId)
|
||||||
if (mDebugTarget->mTargetBinary == NULL)
|
if (mDebugTarget->mTargetBinary == NULL)
|
||||||
return DbgTypedValue();
|
return DbgTypedValue();
|
||||||
|
|
||||||
mDebugTarget->mTargetBinary->ParseTypeData();
|
if (mDebugTarget->mTargetBinary->mBfTypesInfoAddr == 0)
|
||||||
auto typeTypeEntry = mDebugTarget->mTargetBinary->FindType("System.Type", DbgLanguage_Beef);
|
|
||||||
if ((typeTypeEntry == NULL) || (typeTypeEntry->mValue == NULL))
|
|
||||||
return DbgTypedValue();
|
|
||||||
|
|
||||||
auto typeType = typeTypeEntry->mValue;
|
|
||||||
if (typeType->mNeedsGlobalsPopulated)
|
|
||||||
typeType->mCompileUnit->mDbgModule->PopulateTypeGlobals(typeType);
|
|
||||||
for (auto member : typeType->mMemberList)
|
|
||||||
{
|
{
|
||||||
if ((member->mIsStatic) && (member->mName != NULL) && (strcmp(member->mName, "sTypes") == 0) && (member->mLocationData != NULL))
|
mDebugTarget->mTargetBinary->mBfTypesInfoAddr = -1;
|
||||||
|
|
||||||
|
mDebugTarget->mTargetBinary->ParseTypeData();
|
||||||
|
auto typeTypeEntry = mDebugTarget->mTargetBinary->FindType("System.Type", DbgLanguage_Beef);
|
||||||
|
if ((typeTypeEntry != NULL) && (typeTypeEntry->mValue != NULL))
|
||||||
{
|
{
|
||||||
auto stackFrame = GetStackFrame();
|
auto typeType = typeTypeEntry->mValue;
|
||||||
DbgAddrType addrType;
|
mDebugTarget->mTargetBinary->mBfTypeType = typeType;
|
||||||
intptr valAddr = member->mCompileUnit->mDbgModule->EvaluateLocation(NULL, member->mLocationData, member->mLocationLen, stackFrame, &addrType);
|
if (typeType->mNeedsGlobalsPopulated)
|
||||||
if (valAddr != 0)
|
typeType->mCompileUnit->mDbgModule->PopulateTypeGlobals(typeType);
|
||||||
|
|
||||||
|
for (auto member : typeType->mMemberList)
|
||||||
{
|
{
|
||||||
DbgTypedValue typedVal;
|
if ((member->mIsStatic) && (member->mName != NULL) && (strcmp(member->mName, "sTypes") == 0) && (member->mLocationData != NULL))
|
||||||
typedVal.mType = typeType;
|
{
|
||||||
addr_target addr = valAddr + typeId * sizeof(addr_target);
|
auto stackFrame = GetStackFrame();
|
||||||
typedVal.mSrcAddress = mDebugger->ReadMemory<addr_target>(addr);
|
DbgAddrType addrType;
|
||||||
return typedVal;
|
mDebugTarget->mTargetBinary->mBfTypesInfoAddr = member->mCompileUnit->mDbgModule->EvaluateLocation(NULL, member->mLocationData, member->mLocationLen, stackFrame, &addrType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
typedVal.mType = mDebugTarget->mTargetBinary->mBfTypeType;
|
||||||
|
addr_target addr = mDebugTarget->mTargetBinary->mBfTypesInfoAddr + typeId * sizeof(addr_target);
|
||||||
|
typedVal.mSrcAddress = mDebugger->ReadMemory<addr_target>(addr);
|
||||||
|
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;
|
||||||
|
|
|
@ -1141,7 +1141,7 @@ public:
|
||||||
bool mParsedSymbolData;
|
bool mParsedSymbolData;
|
||||||
bool mParsedTypeData;
|
bool mParsedTypeData;
|
||||||
bool mPopulatedStaticVariables;
|
bool mPopulatedStaticVariables;
|
||||||
bool mParsedFrameDescriptors;
|
bool mParsedFrameDescriptors;
|
||||||
|
|
||||||
bool mMayBeOld; // If we had to load debug info from the SymCache or a SymServer then it may be old
|
bool mMayBeOld; // If we had to load debug info from the SymCache or a SymServer then it may be old
|
||||||
bool mDeleting;
|
bool mDeleting;
|
||||||
|
@ -1154,7 +1154,7 @@ public:
|
||||||
int mStartSubprogramIdx;
|
int mStartSubprogramIdx;
|
||||||
int mEndSubprogramIdx;
|
int mEndSubprogramIdx;
|
||||||
int mStartTypeIdx;
|
int mStartTypeIdx;
|
||||||
int mEndTypeIdx;
|
int mEndTypeIdx;
|
||||||
uintptr mPreferredImageBase;
|
uintptr mPreferredImageBase;
|
||||||
uintptr mImageBase;
|
uintptr mImageBase;
|
||||||
uint32 mImageSize;
|
uint32 mImageSize;
|
||||||
|
@ -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