mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Added MD5 file hashes to Beef
This commit is contained in:
parent
32c09bf94b
commit
61468d818f
33 changed files with 598 additions and 143 deletions
|
@ -1635,6 +1635,21 @@ void BeCOFFObject::DbgGenerateModuleInfo()
|
|||
}
|
||||
}
|
||||
|
||||
Array<int> fileDataPositions;
|
||||
///
|
||||
{
|
||||
int fileDataPos = 0;
|
||||
for (auto dbgFile : mBeModule->mDbgModule->mFiles)
|
||||
{
|
||||
fileDataPositions.Add(fileDataPos);
|
||||
fileDataPos += 4;
|
||||
if (dbgFile->mMD5Hash.IsZero())
|
||||
fileDataPos += 4;
|
||||
else
|
||||
fileDataPos += 20;
|
||||
}
|
||||
}
|
||||
|
||||
int emissionStartIdx = 0;
|
||||
BeDbgFile* curDbgFile = NULL;
|
||||
for (int emissionIdx = 0; emissionIdx < (int)emissions.size(); emissionIdx++)
|
||||
|
@ -1657,7 +1672,7 @@ void BeCOFFObject::DbgGenerateModuleInfo()
|
|||
curDbgFile = dbgFile;
|
||||
|
||||
lastBlockStartPos = outS.GetPos();
|
||||
outS.Write((int32)dbgFile->mIdx * 8);
|
||||
outS.Write((int32)fileDataPositions[dbgFile->mIdx]);
|
||||
outS.Write((int32)0); // placeholder nLines
|
||||
outS.Write((int32)0); // placeholder cbBlock
|
||||
|
||||
|
@ -1779,7 +1794,19 @@ void BeCOFFObject::DbgGenerateModuleInfo()
|
|||
for (auto dbgFile : mBeModule->mDbgModule->mFiles)
|
||||
{
|
||||
outS.Write((int32)strTable.size());
|
||||
outS.Write((int32)0); // hashLen, hashType, padding
|
||||
|
||||
if (dbgFile->mMD5Hash.IsZero())
|
||||
{
|
||||
outS.Write((int32)0); // hashLen, hashType, padding
|
||||
}
|
||||
else
|
||||
{
|
||||
outS.Write((uint8)16); // hashLen
|
||||
outS.Write((uint8)1); // hashType
|
||||
outS.Write(&dbgFile->mMD5Hash, 16);
|
||||
outS.Write((int8)0); // padding
|
||||
outS.Write((int8)0);
|
||||
}
|
||||
|
||||
String fullPath;
|
||||
dbgFile->ToString(fullPath);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "BeefySysLib/util/BeefPerf.h"
|
||||
|
||||
#include "BeefySysLib/util/AllocDebug.h"
|
||||
#include "BeefySysLib/util/Hash.h"
|
||||
|
||||
USING_NS_BF;
|
||||
|
||||
|
@ -518,6 +519,12 @@ void BeIRCodeGen::Read(int64& i)
|
|||
BE_MEM_END("int64");
|
||||
}
|
||||
|
||||
void BeIRCodeGen::Read(Val128& i)
|
||||
{
|
||||
i.mLow = (uint64)ReadSLEB128();
|
||||
i.mHigh = (uint64)ReadSLEB128();
|
||||
}
|
||||
|
||||
void BeIRCodeGen::Read(bool& val)
|
||||
{
|
||||
BE_MEM_START;
|
||||
|
@ -2362,10 +2369,12 @@ void BeIRCodeGen::HandleNextCmd()
|
|||
{
|
||||
CMD_PARAM(String, fileName);
|
||||
CMD_PARAM(String, directory);
|
||||
CMD_PARAM(Val128, md5Hash);
|
||||
|
||||
auto dbgFile = mBeModule->mDbgModule->mFiles.Alloc();
|
||||
dbgFile->mFileName = fileName;
|
||||
dbgFile->mFileName = fileName;
|
||||
dbgFile->mDirectory = directory;
|
||||
dbgFile->mMD5Hash = md5Hash;
|
||||
dbgFile->mIdx = (int)mBeModule->mDbgModule->mFiles.size() - 1;
|
||||
|
||||
SetResult(curId, dbgFile);
|
||||
|
|
|
@ -95,6 +95,7 @@ public:
|
|||
void Read(StringImpl& str);
|
||||
void Read(int& i);
|
||||
void Read(int64& i);
|
||||
void Read(Val128& i);
|
||||
void Read(bool& val);
|
||||
void Read(BeIRTypeEntry*& type);
|
||||
void Read(BeType*& beType);
|
||||
|
|
|
@ -884,6 +884,38 @@ int BeDbgLoc::GetInlineMatchDepth(BeDbgLoc* other)
|
|||
return matchDepth;
|
||||
}
|
||||
|
||||
void BeDbgFunction::HashContent(BeHashContext& hashCtx)
|
||||
{
|
||||
hashCtx.Mixin(TypeId);
|
||||
if (mFile != NULL)
|
||||
mFile->HashReference(hashCtx);
|
||||
hashCtx.Mixin(mLine);
|
||||
hashCtx.MixinStr(mName);
|
||||
hashCtx.MixinStr(mLinkageName);
|
||||
mType->HashReference(hashCtx);
|
||||
for (auto genericArg : mGenericArgs)
|
||||
genericArg->HashReference(hashCtx);
|
||||
for (auto genericConstValueArgs : mGenericArgs)
|
||||
genericConstValueArgs->HashReference(hashCtx);
|
||||
if (mValue != NULL)
|
||||
mValue->HashReference(hashCtx);
|
||||
hashCtx.Mixin(mIsLocalToUnit);
|
||||
hashCtx.Mixin(mIsStaticMethod);
|
||||
hashCtx.Mixin(mFlags);
|
||||
hashCtx.Mixin(mVK);
|
||||
hashCtx.Mixin(mVIndex);
|
||||
hashCtx.Mixin(mVariables.size());
|
||||
for (auto& variable : mVariables)
|
||||
{
|
||||
if (variable == NULL)
|
||||
hashCtx.Mixin(-1);
|
||||
else
|
||||
variable->HashReference(hashCtx);
|
||||
}
|
||||
hashCtx.Mixin(mPrologSize);
|
||||
hashCtx.Mixin(mCodeLen);
|
||||
}
|
||||
|
||||
void BeDbgStructType::SetMembers(SizedArrayImpl<BeMDNode*>& members)
|
||||
{
|
||||
mIsFullyDefined = true;
|
||||
|
|
|
@ -1847,35 +1847,7 @@ public:
|
|||
}*/
|
||||
}
|
||||
|
||||
virtual void HashContent(BeHashContext& hashCtx) override
|
||||
{
|
||||
hashCtx.Mixin(TypeId);
|
||||
hashCtx.Mixin(mLine);
|
||||
hashCtx.MixinStr(mName);
|
||||
hashCtx.MixinStr(mLinkageName);
|
||||
mType->HashReference(hashCtx);
|
||||
for (auto genericArg : mGenericArgs)
|
||||
genericArg->HashReference(hashCtx);
|
||||
for (auto genericConstValueArgs : mGenericArgs)
|
||||
genericConstValueArgs->HashReference(hashCtx);
|
||||
if (mValue != NULL)
|
||||
mValue->HashReference(hashCtx);
|
||||
hashCtx.Mixin(mIsLocalToUnit);
|
||||
hashCtx.Mixin(mIsStaticMethod);
|
||||
hashCtx.Mixin(mFlags);
|
||||
hashCtx.Mixin(mVK);
|
||||
hashCtx.Mixin(mVIndex);
|
||||
hashCtx.Mixin(mVariables.size());
|
||||
for (auto& variable : mVariables)
|
||||
{
|
||||
if (variable == NULL)
|
||||
hashCtx.Mixin(-1);
|
||||
else
|
||||
variable->HashReference(hashCtx);
|
||||
}
|
||||
hashCtx.Mixin(mPrologSize);
|
||||
hashCtx.Mixin(mCodeLen);
|
||||
}
|
||||
virtual void HashContent(BeHashContext& hashCtx) override;
|
||||
};
|
||||
|
||||
class BeDbgInlinedScope : public BeMDNode
|
||||
|
@ -1982,8 +1954,9 @@ public:
|
|||
BE_VALUE_TYPE(BeDbgFile, BeMDNode);
|
||||
|
||||
public:
|
||||
String mFileName;
|
||||
String mFileName;
|
||||
String mDirectory;
|
||||
Val128 mMD5Hash;
|
||||
int mIdx;
|
||||
|
||||
void ToString(String& str);
|
||||
|
@ -1992,6 +1965,7 @@ public:
|
|||
{
|
||||
hashCtx.Mixin(TypeId);
|
||||
hashCtx.MixinStr(mFileName);
|
||||
hashCtx.Mixin(mMD5Hash);
|
||||
hashCtx.MixinStr(mDirectory);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue