1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Fixed hot swap type errors for LocateSymbol forced obj loads

This commit is contained in:
Brian Fiete 2019-11-07 13:35:56 -08:00
parent 58bf51f731
commit 810c7b843b
6 changed files with 63 additions and 51 deletions

View file

@ -727,7 +727,7 @@ DbgSubprogram* COFF::CvParseMethod(DbgType* parentType, const char* methodName,
} }
if ((parentType != NULL) && (!mIsHotObjectFile)) if ((parentType != NULL) && (!IsObjectFile()))
{ {
subprogram->mCompileUnit = parentType->mCompileUnit; subprogram->mCompileUnit = parentType->mCompileUnit;
parentType->mMethodList.PushBack(subprogram); parentType->mMethodList.PushBack(subprogram);
@ -1025,7 +1025,7 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi)
} }
} }
if ((isStatic) && (!isConst) && (mIsHotObjectFile)) if ((isStatic) && (!isConst) && (IsObjectFile()))
{ {
// Already has statics filled in // Already has statics filled in
break; break;
@ -2219,7 +2219,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
uint8* dataEnd = data + symLen; uint8* dataEnd = data + symLen;
GET_INTO(uint16, symType); GET_INTO(uint16, symType);
if (!mIsHotObjectFile) if (!IsObjectFile())
BF_ASSERT(symLen % 4 == 2); BF_ASSERT(symLen % 4 == 2);
bool newLocalVarHasLocData = false; bool newLocalVarHasLocData = false;
@ -2320,7 +2320,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
case S_GDATA32: case S_GDATA32:
case S_LDATA32: case S_LDATA32:
// In PDB reads we get this from the symbol stream // In PDB reads we get this from the symbol stream
if ((mIsHotObjectFile) || (curSubprogram != NULL)) if ((IsObjectFile()) || (curSubprogram != NULL))
{ {
auto linkedModule = GetLinkedModule(); auto linkedModule = GetLinkedModule();
DATASYM32& dataSym = *(DATASYM32*)dataStart; DATASYM32& dataSym = *(DATASYM32*)dataStart;
@ -2362,7 +2362,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
if (curSubprogram != NULL) if (curSubprogram != NULL)
{ {
if (!mIsHotObjectFile) if (!IsObjectFile())
{ {
// Copy this, we free the source data // Copy this, we free the source data
variable->mName = DbgDupString(name, "DbgDupString.S_GDATA32"); variable->mName = DbgDupString(name, "DbgDupString.S_GDATA32");
@ -2387,7 +2387,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
case S_GTHREAD32: case S_GTHREAD32:
case S_LTHREAD32: case S_LTHREAD32:
{ {
if ((mIsHotObjectFile) || (curSubprogram != NULL)) if ((IsObjectFile()) || (curSubprogram != NULL))
{ {
auto linkedModule = GetLinkedModule(); auto linkedModule = GetLinkedModule();
THREADSYM32& dataSym = *(THREADSYM32*)dataStart; THREADSYM32& dataSym = *(THREADSYM32*)dataStart;
@ -2429,7 +2429,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
if (curSubprogram != NULL) if (curSubprogram != NULL)
{ {
if (!mIsHotObjectFile) if (!IsObjectFile())
{ {
// Copy this, we free the source data // Copy this, we free the source data
variable->mName = DbgDupString(name, "DbgDupString.S_GTHREAD32"); variable->mName = DbgDupString(name, "DbgDupString.S_GTHREAD32");
@ -2474,7 +2474,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
else else
{ {
bool ipi = false; bool ipi = false;
if ((!mIsHotObjectFile) && if ((!IsObjectFile()) &&
((symType == S_GPROC32_ID) || (symType == S_LPROC32_ID))) ((symType == S_GPROC32_ID) || (symType == S_LPROC32_ID)))
{ {
if (!mCvIPIReader.IsSetup()) if (!mCvIPIReader.IsSetup())
@ -2961,7 +2961,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
DbgSubprogram* inlineParent = curSubprogram; DbgSubprogram* inlineParent = curSubprogram;
DbgSubprogram* subprogram = NULL; DbgSubprogram* subprogram = NULL;
if (mIsHotObjectFile) if (IsObjectFile())
{ {
subprogram = CvParseMethod(NULL, NULL, inlinee, false); subprogram = CvParseMethod(NULL, NULL, inlinee, false);
subprogram->mCompileUnit = compileUnit; subprogram->mCompileUnit = compileUnit;
@ -3990,7 +3990,7 @@ DbgType* COFF::CvGetTypeOrNamespace(char* name, DbgLanguage language)
void COFF::MapCompileUnitMethods(DbgCompileUnit* compileUnit) void COFF::MapCompileUnitMethods(DbgCompileUnit* compileUnit)
{ {
bool addHotTypes = (mIsHotObjectFile) && (mHotPrimaryTypes.size() == 0); bool addHotTypes = (IsObjectFile()) && (mHotPrimaryTypes.size() == 0);
DbgSubprogram* prevDbgMethod = NULL; DbgSubprogram* prevDbgMethod = NULL;
DbgSubprogram* dbgMethod = compileUnit->mOrphanMethods.mHead; DbgSubprogram* dbgMethod = compileUnit->mOrphanMethods.mHead;
@ -4467,7 +4467,7 @@ void COFF::FixTypes(int startingIdx)
if (dbgType->mIsDeclaration) if (dbgType->mIsDeclaration)
continue; continue;
if (mIsHotObjectFile) if (IsObjectFile())
{ {
auto entry = linkedModule->mTypeMap.Find(dbgType->mName, dbgType->mLanguage); auto entry = linkedModule->mTypeMap.Find(dbgType->mName, dbgType->mLanguage);
if (entry != NULL) if (entry != NULL)
@ -5184,7 +5184,7 @@ const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_
// Push front so we will find before the original static declaration (that has no memory associated with it) // 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 (mIsHotObjectFile) if (IsObjectFile())
{ {
if ((variable->mIsExtern) && (variable->mLinkName != NULL)) if ((variable->mIsExtern) && (variable->mLinkName != NULL))
mStaticVariables.push_back(variable); mStaticVariables.push_back(variable);
@ -6406,7 +6406,7 @@ bool COFF::LoadModuleImage(const StringImpl& imagePath)
if (mappedFile != NULL) if (mappedFile != NULL)
{ {
MemStream memStream(mappedFile->mData, mappedFile->mFileSize, false); MemStream memStream(mappedFile->mData, mappedFile->mFileSize, false);
ReadCOFF(&memStream, false); ReadCOFF(&memStream, DbgModuleKind_Module);
mOrigImageData = new DbgModuleMemoryCache(mImageBase, mImageSize); mOrigImageData = new DbgModuleMemoryCache(mImageBase, mImageSize);
} }
@ -6512,7 +6512,7 @@ bool COFF::WantsAutoLoadDebugInfo()
bool COFF::DbgIsStrMutable(const char* str) bool COFF::DbgIsStrMutable(const char* str)
{ {
if (mIsHotObjectFile) if (IsObjectFile())
{ {
return GetLinkedModule()->DbgIsStrMutable(str); return GetLinkedModule()->DbgIsStrMutable(str);
} }
@ -6678,7 +6678,7 @@ addr_target COFF::LocateSymbol(const StringImpl& name)
DbgModule* dbgModule = new COFF(mDebugger->mDebugTarget); DbgModule* dbgModule = new COFF(mDebugger->mDebugTarget);
dbgModule->mHotIdx = mDebugger->mActiveHotIdx; dbgModule->mHotIdx = mDebugger->mActiveHotIdx;
dbgModule->mFilePath = libEntry->mName + "@" + libEntry->mLibFile->mFilePath; dbgModule->mFilePath = libEntry->mName + "@" + libEntry->mLibFile->mFilePath;
bool success = dbgModule->ReadCOFF(&fileStream, true); bool success = dbgModule->ReadCOFF(&fileStream, DbgModuleKind_FromLocateSymbol);
fileStream.mFP = NULL; fileStream.mFP = NULL;
// Mark as loaded // Mark as loaded

View file

@ -597,7 +597,7 @@ bool DwMethodMatcher::CheckType(DbgType* typeInstance, bool isFailurePass)
if ((methodNameEntry->mCompileUnitId != -1) && (methodNameEntry->mName == mMethodName)) if ((methodNameEntry->mCompileUnitId != -1) && (methodNameEntry->mName == mMethodName))
{ {
// If we hot-replaced this type then we replaced and parsed all the methods too // If we hot-replaced this type then we replaced and parsed all the methods too
if (!curType->mCompileUnit->mDbgModule->mIsHotObjectFile) if (!curType->mCompileUnit->mDbgModule->IsObjectFile())
curType->mCompileUnit->mDbgModule->MapCompileUnitMethods(methodNameEntry->mCompileUnitId); curType->mCompileUnit->mDbgModule->MapCompileUnitMethods(methodNameEntry->mCompileUnitId);
methodNameEntry->mCompileUnitId = -1; methodNameEntry->mCompileUnitId = -1;
} }

View file

@ -1982,7 +1982,7 @@ DbgModule::DbgModule(DebugTarget* debugTarget) : mDefaultCompileUnit(this)
mSymbolData = NULL; mSymbolData = NULL;
mCheckedBfObject = false; mCheckedBfObject = false;
mBfObjectHasFlags = false; mBfObjectHasFlags = false;
mIsHotObjectFile = false; mModuleKind = DbgModuleKind_Module;
mStartTypeIdx = 0; mStartTypeIdx = 0;
mEndTypeIdx = 0; mEndTypeIdx = 0;
mHotIdx = 0; mHotIdx = 0;
@ -2042,7 +2042,7 @@ DbgModule::~DbgModule()
delete mOrigImageData; delete mOrigImageData;
if ((mIsHotObjectFile) && (mImageBase != 0)) if ((IsObjectFile()) && (mImageBase != 0))
{ {
mDebugger->ReleaseHotTargetMemory((addr_target)mImageBase, (int)mImageSize); mDebugger->ReleaseHotTargetMemory((addr_target)mImageBase, (int)mImageSize);
} }
@ -2064,7 +2064,7 @@ DbgSubprogram* DbgModule::FindSubprogram(DbgType* dbgType, const char * methodNa
if ((methodNameEntry->mCompileUnitId != -1) && (strcmp(methodNameEntry->mName, methodName) == 0)) if ((methodNameEntry->mCompileUnitId != -1) && (strcmp(methodNameEntry->mName, methodName) == 0))
{ {
// If we hot-replaced this type then we replaced and parsed all the methods too // If we hot-replaced this type then we replaced and parsed all the methods too
if (!dbgType->mCompileUnit->mDbgModule->mIsHotObjectFile) if (!dbgType->mCompileUnit->mDbgModule->IsObjectFile())
dbgType->mCompileUnit->mDbgModule->MapCompileUnitMethods(methodNameEntry->mCompileUnitId); dbgType->mCompileUnit->mDbgModule->MapCompileUnitMethods(methodNameEntry->mCompileUnitId);
methodNameEntry->mCompileUnitId = -1; methodNameEntry->mCompileUnitId = -1;
} }
@ -2108,14 +2108,14 @@ char* DbgModule::DbgDupString(const char* str, const char* allocName)
DbgModule* DbgModule::GetLinkedModule() DbgModule* DbgModule::GetLinkedModule()
{ {
if (mIsHotObjectFile) if (IsObjectFile())
return mDebugTarget->mTargetBinary; return mDebugTarget->mTargetBinary;
return this; return this;
} }
addr_target DbgModule::GetTargetImageBase() addr_target DbgModule::GetTargetImageBase()
{ {
if (mIsHotObjectFile) if (IsObjectFile())
return (addr_target)mDebugTarget->mTargetBinary->mImageBase; return (addr_target)mDebugTarget->mTargetBinary->mImageBase;
return (addr_target)mImageBase; return (addr_target)mImageBase;
} }
@ -2577,7 +2577,7 @@ void DbgModule::MapTypes(int startingTypeIdx)
if (dbgType->mCompileUnit->mDbgModule != prevType->mCompileUnit->mDbgModule) if (dbgType->mCompileUnit->mDbgModule != prevType->mCompileUnit->mDbgModule)
{ {
// Don't replace original types with hot types -- those need to be inserted in the the hot alternates list // Don't replace original types with hot types -- those need to be inserted in the the hot alternates list
BF_ASSERT(dbgType->mCompileUnit->mDbgModule->mIsHotObjectFile); BF_ASSERT(dbgType->mCompileUnit->mDbgModule->IsObjectFile());
prevType->mHotNewType = dbgType; prevType->mHotNewType = dbgType;
continue; continue;
} }
@ -5297,7 +5297,7 @@ bool DbgModule::CanRead(DataStream* stream, DebuggerResult* outResult)
return true; return true;
} }
bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile) bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind)
{ {
BP_ZONE("DbgModule::ReadCOFF"); BP_ZONE("DbgModule::ReadCOFF");
@ -5323,10 +5323,13 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
miniDumpDebugger = (MiniDumpDebugger*)mDebugger; miniDumpDebugger = (MiniDumpDebugger*)mDebugger;
} }
mIsHotObjectFile = isHotObjectFile; mModuleKind = moduleKind;
bool isHotSwap = mModuleKind == DbgModuleKind_HotObject;
bool isObjectFile = mModuleKind != DbgModuleKind_Module;
auto linkedModule = GetLinkedModule(); auto linkedModule = GetLinkedModule();
if (mIsHotObjectFile) if (isObjectFile)
linkedModule->PopulateStaticVariableMap(); linkedModule->PopulateStaticVariableMap();
mStartTypeIdx = (int)linkedModule->mTypes.size(); mStartTypeIdx = (int)linkedModule->mTypes.size();
@ -5339,7 +5342,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
PE_NTHeaders ntHdr; PE_NTHeaders ntHdr;
memset(&ntHdr, 0, sizeof(ntHdr)); memset(&ntHdr, 0, sizeof(ntHdr));
if (!mIsHotObjectFile) if (!isObjectFile)
{ {
stream->Read(&hdr, sizeof(PEHeader)); stream->Read(&hdr, sizeof(PEHeader));
stream->SetPos(hdr.e_lfanew); stream->SetPos(hdr.e_lfanew);
@ -5484,7 +5487,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
sectionNames[sectNum] = name; sectionNames[sectNum] = name;
DbgHotTargetSection* targetSection = NULL; DbgHotTargetSection* targetSection = NULL;
if (mIsHotObjectFile) if (IsObjectFile())
{ {
targetSection = new DbgHotTargetSection(); targetSection = new DbgHotTargetSection();
targetSection->mDataSize = sectHdr.mSizeOfRawData; targetSection->mDataSize = sectHdr.mSizeOfRawData;
@ -5509,7 +5512,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
if (strcmp(name, ".tls") == 0) if (strcmp(name, ".tls") == 0)
mTLSAddr = (addr_target)(sectHdr.mVirtualAddress + mImageBase); mTLSAddr = (addr_target)(sectHdr.mVirtualAddress + mImageBase);
if ((mIsHotObjectFile) && (strcmp(name, ".tls$") == 0)) if ((IsObjectFile()) && (strcmp(name, ".tls$") == 0))
{ {
tlsSection = sectNum; tlsSection = sectNum;
mTLSSize = sectHdr.mSizeOfRawData; mTLSSize = sectHdr.mSizeOfRawData;
@ -5518,7 +5521,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
bool isExportDataDir = ((exportDataDir->mVirtualAddress != 0) && (exportDataDir->mVirtualAddress >= sectHdr.mVirtualAddress) && (exportDataDir->mVirtualAddress < sectHdr.mVirtualAddress + sectHdr.mSizeOfRawData)); bool isExportDataDir = ((exportDataDir->mVirtualAddress != 0) && (exportDataDir->mVirtualAddress >= sectHdr.mVirtualAddress) && (exportDataDir->mVirtualAddress < sectHdr.mVirtualAddress + sectHdr.mSizeOfRawData));
if ((!mIsHotObjectFile) && (!isExportDataDir)) if ((!IsObjectFile()) && (!isExportDataDir))
{ {
if (((strcmp(name, ".text")) == 0) || if (((strcmp(name, ".text")) == 0) ||
((strcmp(name, ".textbss")) == 0) || ((strcmp(name, ".textbss")) == 0) ||
@ -5545,7 +5548,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
memset(data + sectHdr.mSizeOfRawData, 0, 8); memset(data + sectHdr.mSizeOfRawData, 0, 8);
if (mIsHotObjectFile) if (IsObjectFile())
targetSection->mData = data; targetSection->mData = data;
addr_target addrOffset = sectHdr.mVirtualAddress; addr_target addrOffset = sectHdr.mVirtualAddress;
@ -5594,7 +5597,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
} }
} }
if ((mIsHotObjectFile) && (sectHdr.mNumberOfRelocations > 0)) if ((IsObjectFile()) && (sectHdr.mNumberOfRelocations > 0))
{ {
//mDebugger->AllocTargetMemory(sectHdr.mSizeOfRawData, true, true); //mDebugger->AllocTargetMemory(sectHdr.mSizeOfRawData, true, true);
@ -5602,7 +5605,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
if (strcmp(name, ".text") == 0) if (strcmp(name, ".text") == 0)
{ {
if (!mIsHotObjectFile) if (!IsObjectFile())
mCodeAddress = ntHdr.mOptionalHeader.mImageBase + sectHdr.mVirtualAddress; mCodeAddress = ntHdr.mOptionalHeader.mImageBase + sectHdr.mVirtualAddress;
} }
@ -5795,7 +5798,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
{ {
if (mExceptionData != NULL) if (mExceptionData != NULL)
{ {
if (mIsHotObjectFile) if (IsObjectFile())
{ {
mOwnedSectionData.push_back(mExceptionData); mOwnedSectionData.push_back(mExceptionData);
} }
@ -5863,7 +5866,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
if (!usedData) if (!usedData)
{ {
if (mIsHotObjectFile) if (IsObjectFile())
{ {
mOwnedSectionData.push_back(data); mOwnedSectionData.push_back(data);
} }
@ -5878,7 +5881,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
} }
int needHotTargetMemory = 0; int needHotTargetMemory = 0;
if (mIsHotObjectFile) if (isObjectFile)
{ {
for (int sectNum = 0; sectNum < ntHdr.mFileHeader.mNumberOfSections; sectNum++) for (int sectNum = 0; sectNum < ntHdr.mFileHeader.mNumberOfSections; sectNum++)
{ {
@ -5894,7 +5897,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
} }
int numSections = ntHdr.mFileHeader.mNumberOfSections; int numSections = ntHdr.mFileHeader.mNumberOfSections;
if (mIsHotObjectFile) if (isObjectFile)
{ {
addr_target* resolvedSymbolAddrs = new addr_target[ntHdr.mFileHeader.mNumberOfSymbols]; addr_target* resolvedSymbolAddrs = new addr_target[ntHdr.mFileHeader.mNumberOfSymbols];
memset(resolvedSymbolAddrs, 0, ntHdr.mFileHeader.mNumberOfSymbols * sizeof(addr_target)); memset(resolvedSymbolAddrs, 0, ntHdr.mFileHeader.mNumberOfSymbols * sizeof(addr_target));
@ -5973,7 +5976,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
{ {
bool isTLS = false; bool isTLS = false;
addr_target targetAddr = 0; addr_target targetAddr = 0;
if (mIsHotObjectFile) if (isObjectFile)
{ {
if (symInfo->mSectionNum - 1 == tlsSection) if (symInfo->mSectionNum - 1 == tlsSection)
{ {
@ -6007,7 +6010,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
if ((isStaticSymbol) && (IsHotSwapPreserve(symbolName))) if ((isStaticSymbol) && (IsHotSwapPreserve(symbolName)))
isStaticSymbol = false; isStaticSymbol = false;
if ((mIsHotObjectFile) && (!isStaticSymbol)) if ((isObjectFile) && (!isStaticSymbol))
{ {
DbgSymbol* dwSymbol = NULL; DbgSymbol* dwSymbol = NULL;
@ -6109,10 +6112,10 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
dwSymbol->mName = symbolName; dwSymbol->mName = symbolName;
dwSymbol->mAddress = targetAddr; dwSymbol->mAddress = targetAddr;
if (!mIsHotObjectFile) if (!IsObjectFile())
dwSymbol->mAddress += (addr_target)mImageBase; dwSymbol->mAddress += (addr_target)mImageBase;
if (mIsHotObjectFile) if (IsObjectFile())
BF_ASSERT((dwSymbol->mAddress >= mImageBase) && (dwSymbol->mAddress < mImageBase + mImageSize)); BF_ASSERT((dwSymbol->mAddress >= mImageBase) && (dwSymbol->mAddress < mImageBase + mImageSize));
mDebugTarget->mSymbolMap.Insert(dwSymbol); mDebugTarget->mSymbolMap.Insert(dwSymbol);
@ -6178,7 +6181,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
} }
} }
if (!mIsHotObjectFile) if (!isObjectFile)
{ {
mImageSize = ntHdr.mOptionalHeader.mSizeOfImage; mImageSize = ntHdr.mOptionalHeader.mSizeOfImage;
mEntryPoint = ntHdr.mOptionalHeader.mAddressOfEntryPoint; mEntryPoint = ntHdr.mOptionalHeader.mAddressOfEntryPoint;
@ -6187,7 +6190,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
/*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);*/ lineDataCount, mEndTypeIdx - mStartTypeIdx, (int)linkedModule->mTypes.size() - mStartTypeIdx, mEndSubprogramIdx - mStartSubprogramIdx, subProgramSizes / 1024, mAlloc.GetAllocSize() / 1024);*/
if (mIsHotObjectFile) if (isHotSwap)
{ {
// In COFF, we don't necessarily add an actual primary type during MapCompileUnitMethods, so this fixes that // In COFF, we don't necessarily add an actual primary type during MapCompileUnitMethods, so this fixes that
while (true) while (true)
@ -6293,7 +6296,7 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
void DbgModule::FinishHotSwap() void DbgModule::FinishHotSwap()
{ {
BF_ASSERT(mIsHotObjectFile); BF_ASSERT(IsObjectFile());
auto linkedModule = GetLinkedModule(); auto linkedModule = GetLinkedModule();
auto mainModule = mDebugTarget->mTargetBinary; auto mainModule = mDebugTarget->mTargetBinary;

View file

@ -120,6 +120,13 @@ enum DbgFileExistKind : uint8
DbgFileExistKind_Found DbgFileExistKind_Found
}; };
enum DbgModuleKind : uint8
{
DbgModuleKind_Module,
DbgModuleKind_HotObject,
DbgModuleKind_FromLocateSymbol
};
class DbgCompileUnit; class DbgCompileUnit;
struct DbgSectionData struct DbgSectionData
@ -1159,7 +1166,7 @@ public:
Array<addr_target> mSecRelEncodingVec; Array<addr_target> mSecRelEncodingVec;
bool mCheckedBfObject; bool mCheckedBfObject;
bool mBfObjectHasFlags; bool mBfObjectHasFlags;
bool mIsHotObjectFile; DbgModuleKind mModuleKind;
bool mIsDwarf64; bool mIsDwarf64;
HashSet<DbgSrcFile*> mSrcFileDeferredRefs; HashSet<DbgSrcFile*> mSrcFileDeferredRefs;
@ -1237,6 +1244,8 @@ public:
void FixupInnerTypes(int startingTypeIdx); void FixupInnerTypes(int startingTypeIdx);
void MapTypes(int startingTypeIdx); void MapTypes(int startingTypeIdx);
void CreateNamespaces(); void CreateNamespaces();
bool IsObjectFile() { return mModuleKind != DbgModuleKind_Module; }
bool IsHotSwapObjectFile() { return mModuleKind == DbgModuleKind_HotObject; }
bool IsHotSwapPreserve(const String& name); bool IsHotSwapPreserve(const String& name);
addr_target GetHotTargetAddress(DbgHotTargetSection* hotTargetSection); addr_target GetHotTargetAddress(DbgHotTargetSection* hotTargetSection);
uint8* GetHotTargetData(addr_target address); uint8* GetHotTargetData(addr_target address);
@ -1268,7 +1277,7 @@ public:
static bool CanRead(DataStream* stream, DebuggerResult* outResult); static bool CanRead(DataStream* stream, DebuggerResult* outResult);
bool ReadCOFF(DataStream* stream, bool isHotObjectFile); bool ReadCOFF(DataStream* stream, DbgModuleKind dbgModuleKind);
void RemoveTargetData(); void RemoveTargetData();
virtual void ReportMemory(MemReporter* memReporter); virtual void ReportMemory(MemReporter* memReporter);

View file

@ -153,7 +153,7 @@ DbgModule* DebugTarget::Init(const StringImpl& launchPath, const StringImpl& tar
dwarf->mDisplayName = GetFileName(launchPath); dwarf->mDisplayName = GetFileName(launchPath);
dwarf->mFilePath = launchPath; dwarf->mFilePath = launchPath;
dwarf->mImageBase = (intptr)imageBase; dwarf->mImageBase = (intptr)imageBase;
if (!dwarf->ReadCOFF(&fileStream, false)) if (!dwarf->ReadCOFF(&fileStream, DbgModuleKind_Module))
{ {
mDebugger->OutputMessage(StrFormat("Debugger failed to read binary: %s\n", launchPath.c_str())); mDebugger->OutputMessage(StrFormat("Debugger failed to read binary: %s\n", launchPath.c_str()));
delete dwarf; delete dwarf;
@ -191,7 +191,7 @@ DbgModule* DebugTarget::HotLoad(const StringImpl& fileName, int hotIdx)
dwarf->mHotIdx = hotIdx; dwarf->mHotIdx = hotIdx;
dwarf->mDisplayName = GetFileName(fileName); dwarf->mDisplayName = GetFileName(fileName);
dwarf->mFilePath = fileName; dwarf->mFilePath = fileName;
if (!dwarf->ReadCOFF(&fileStream, true)) if (!dwarf->ReadCOFF(&fileStream, DbgModuleKind_HotObject))
{ {
mDebugger->OutputMessage(StrFormat("Debugger failed to read binary: %s\n", fileName.c_str())); mDebugger->OutputMessage(StrFormat("Debugger failed to read binary: %s\n", fileName.c_str()));
delete dwarf; delete dwarf;
@ -210,7 +210,7 @@ DbgModule* DebugTarget::SetupDyn(const StringImpl& filePath, DataStream* stream,
DbgModule* dwarf = new COFF(this); DbgModule* dwarf = new COFF(this);
dwarf->mFilePath = filePath; dwarf->mFilePath = filePath;
dwarf->mImageBase = (intptr)imageBase; dwarf->mImageBase = (intptr)imageBase;
if (!dwarf->ReadCOFF(stream, false)) if (!dwarf->ReadCOFF(stream, DbgModuleKind_Module))
{ {
//mDebugger->OutputMessage(StrFormat("Debugger failed to read binary: %s", fileName.c_str())); //mDebugger->OutputMessage(StrFormat("Debugger failed to read binary: %s", fileName.c_str()));
delete dwarf; delete dwarf;
@ -270,7 +270,7 @@ void DebugTarget::CleanupHotHeap()
for (int dwarfIdx = 0; dwarfIdx < (int)mDbgModules.size(); dwarfIdx++) for (int dwarfIdx = 0; dwarfIdx < (int)mDbgModules.size(); dwarfIdx++)
{ {
DbgModule* dbgModule = mDbgModules[dwarfIdx]; DbgModule* dbgModule = mDbgModules[dwarfIdx];
if (dbgModule->mIsHotObjectFile) if (dbgModule->IsObjectFile())
{ {
if (!mHotHeap->IsReferenced(dbgModule->mImageBase, dbgModule->mImageSize)) if (!mHotHeap->IsReferenced(dbgModule->mImageBase, dbgModule->mImageSize))
{ {
@ -919,7 +919,7 @@ bool DebugTarget::RollBackStackFrame_ExceptionDirectory(addr_target findPC, CPUR
//const uint8* data = dbgModule->mExceptionData + exceptionDirectoryEntry->mExceptionPos; //const uint8* data = dbgModule->mExceptionData + exceptionDirectoryEntry->mExceptionPos;
uint32 exceptionPos = exceptionDirectoryEntry->mExceptionPos; uint32 exceptionPos = exceptionDirectoryEntry->mExceptionPos;
if (dbgModule->mIsHotObjectFile) if (dbgModule->IsObjectFile())
{ {
exceptionPos -= dbgModule->mImageBase - dbgModule->GetLinkedModule()->mImageBase; exceptionPos -= dbgModule->mImageBase - dbgModule->GetLinkedModule()->mImageBase;
} }

View file

@ -1062,7 +1062,7 @@ void WinDebugger::HotLoad(const Array<String>& objectFiles, int hotIdx)
for (int moduleIdx = startingModuleIdx; moduleIdx < (int)mDebugTarget->mDbgModules.size(); moduleIdx++) for (int moduleIdx = startingModuleIdx; moduleIdx < (int)mDebugTarget->mDbgModules.size(); moduleIdx++)
{ {
auto dbgModule = mDebugTarget->mDbgModules[moduleIdx]; auto dbgModule = mDebugTarget->mDbgModules[moduleIdx];
BF_ASSERT(dbgModule->mIsHotObjectFile); BF_ASSERT(dbgModule->IsObjectFile());
BF_ASSERT(dbgModule->mHotIdx == hotIdx); BF_ASSERT(dbgModule->mHotIdx == hotIdx);
dbgModule->FinishHotSwap(); dbgModule->FinishHotSwap();
} }