1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Changes to improve IDE Module Panel, allowing loading image and pdb

This commit is contained in:
Brian Fiete 2019-09-27 13:05:39 -07:00
parent d41a8c5683
commit bac46ef6e9
10 changed files with 124 additions and 41 deletions

View file

@ -328,6 +328,9 @@ namespace IDE.Debugger
[StdCall,CLink]
static extern bool Debugger_HasPendingDebugLoads();
[StdCall,CLink]
static extern int32 Debugger_LoadImageForModuleWith(char8* moduleName, char8* imageFileName);
[StdCall,CLink]
static extern int32 Debugger_LoadDebugInfoForModule(char8* moduleName);
@ -1089,6 +1092,11 @@ namespace IDE.Debugger
return Debugger_LoadDebugInfoForModule(moduleName);
}
public int32 LoadImageForModule(String moduleName, String debugFileName)
{
return Debugger_LoadImageForModuleWith(moduleName, debugFileName);
}
public int32 LoadDebugInfoForModule(String moduleName, String debugFileName)
{
return Debugger_LoadDebugInfoForModuleWith(moduleName, debugFileName);

View file

@ -223,7 +223,9 @@ uint8* CvStreamReader::GetPermanentPtr(int offset, int size, bool* madeCopy)
COFF::COFF(DebugTarget* debugTarget) : DbgModule(debugTarget)
{
mParseKind = ParseKind_Full;
memset(mWantPDBGuid, 0, 16);
memset(mPDBGuid, 0, 16);
mWantAge = -1;
mDebugAge = -1;
mFileAge = -1;
mCvMinTag = -1;
@ -5824,6 +5826,9 @@ bool COFF::LoadPDB(const String& pdbPath, uint8 wantGuid[16], int32 wantAge)
mDebugTarget->mWasLocallyBuilt = FileExists(pdbPath);
}
memcpy(mWantPDBGuid, wantGuid, 16);
mWantAge = wantAge;
mDbgSymRequest = mDebugger->mDbgSymSrv.CreateRequest(mFilePath, pdbPath, wantGuid, wantAge);
mDbgSymRequest->SearchLocal();
@ -6424,6 +6429,36 @@ void COFF::PreCacheDebugInfo()
}
}
bool COFF::LoadModuleImage(const StringImpl& imagePath)
{
if (!mDebugger->IsMiniDumpDebugger())
return false;
auto miniDumpDebugger = (MiniDumpDebugger*)mDebugger;
if (!imagePath.IsEmpty())
{
MappedFile* mappedFile = miniDumpDebugger->MapModule(this, imagePath);
mMappedImageFile = mappedFile;
if (mappedFile != NULL)
{
MemStream memStream(mappedFile->mData, mappedFile->mFileSize, false);
ReadCOFF(&memStream, false);
mOrigImageData = new DbgModuleMemoryCache(mImageBase, mImageSize);
}
}
if (mOrigImageData == NULL) // Failed?
{
mLoadState = DbgModuleLoadState_Failed;
return false;
}
return true;
}
bool COFF::RequestImage()
{
if (!mDebugger->IsMiniDumpDebugger())
@ -6455,27 +6490,7 @@ bool COFF::RequestImage()
mDebugger->mRunState = prevRunState;
if (!imagePath.IsEmpty())
{
MappedFile* mappedFile = miniDumpDebugger->MapModule(this, imagePath);
mMappedImageFile = mappedFile;
if (mappedFile != NULL)
{
MemStream memStream(mappedFile->mData, mappedFile->mFileSize, false);
ReadCOFF(&memStream, false);
mOrigImageData = new DbgModuleMemoryCache(mImageBase, mImageSize);
}
}
if (mOrigImageData == NULL) // Failed?
{
mLoadState = DbgModuleLoadState_NotLoaded;
return false;
}
return true;
return LoadModuleImage(imagePath);
}
else
{

View file

@ -214,6 +214,9 @@ public:
};
public:
uint8 mWantPDBGuid[16];
int mWantAge;
uint8 mPDBGuid[16];
int mFileAge;
int mDebugAge;
@ -321,6 +324,7 @@ public:
virtual addr_target LocateSymbol(const StringImpl& name) override;
virtual void ParseFrameDescriptors() override;
bool LoadModuleImage(const StringImpl& imagePath);
void FixConstant(DbgVariable* variable);
void MapRanges(DbgVariable* variable, CV_LVAR_ADDR_RANGE* range, CV_LVAR_ADDR_GAP* gaps);
void MakeThis(DbgSubprogram* curSubprogram, DbgVariable*& curParam);

View file

@ -9756,22 +9756,26 @@ BfLambdaInstance* BfExprEvaluator::GetLambdaInstance(BfLambdaBindExpression* lam
auto voidType = mModule->GetPrimitiveType(BfTypeCode_None);
auto dtorFuncType = mModule->mBfIRBuilder->CreateFunctionType(mModule->mBfIRBuilder->MapType(voidType), newTypes, false);
String dtorMangledName = "~" + closureFuncName;
dtorFunc = mModule->mBfIRBuilder->CreateFunction(dtorFuncType, BfIRLinkageType_External, dtorMangledName);
BfMethodDef* dtorMethodDef = new BfMethodDef();
dtorMethodDef->mDeclaringType = mModule->mCurMethodInstance->mMethodDef->mDeclaringType;
dtorMethodDef->mName = "~this";
dtorMethodDef->mName = "~this$";
dtorMethodDef->mName += methodDef->mName;
dtorMethodDef->mMethodType = BfMethodType_Normal;
dtorMethodDef->mBody = lambdaBindExpr->mDtor;
dtorMethodDef->mIdx = mModule->mCurMethodInstance->mMethodDef->mIdx;
BfMethodInstance* dtorMethodInstance = new BfMethodInstance();
//dtorMethodInstance->mMethodInstanceGroup = &methodInstanceGroup;
dtorMethodInstance->mIRFunction = dtorFunc;
dtorMethodInstance->mMethodDef = dtorMethodDef;
dtorMethodInstance->mReturnType = mModule->GetPrimitiveType(BfTypeCode_None);
dtorMethodInstance->mMethodInstanceGroup = &methodInstanceGroup;
StringT<128> dtorMangledName;
BfMangler::Mangle(dtorMangledName, mModule->mCompiler->GetMangleKind(), dtorMethodInstance);
dtorFunc = mModule->mBfIRBuilder->CreateFunction(dtorFuncType, BfIRLinkageType_External, dtorMangledName);
mModule->SetupIRMethod(NULL, dtorFunc, false);
dtorMethodInstance->mIRFunction = dtorFunc;
mModule->mIncompleteMethodCount++;
mModule->mBfIRBuilder->SaveDebugLocation();
//

View file

@ -494,10 +494,11 @@ String DbgSymRequest::SearchForImage(const String& filePath, uint32 fileTime, in
}
}
if ((!mIsPreCache) && (!mDbgSymSrv->mDebugger->mHadImageFindError))
if (!mIsPreCache)
{
mDbgSymSrv->mDebugger->mHadImageFindError = true;
mDbgSymSrv->mDebugger->OutputMessage(StrFormat("ERROR: Unable to locate image '%s'. If this file is located on a symbol server, configure the symbol server location in File\\Preferences\\Settings under Debugger\\Symbol File Locations.\n", GetFileName(filePath).c_str()));
mDbgSymSrv->mDebugger->OutputMessage(StrFormat("ERROR: Unable to locate image '%s' (%08X%x). If this file is located on a symbol server, configure the symbol server location in File\\Preferences\\Settings under Debugger\\Symbol File Locations.\n",
GetFileName(filePath).c_str(), fileTime, size));
}
mFailed = true;

View file

@ -1532,6 +1532,11 @@ BF_EXPORT void BF_CALLTYPE Debugger_CancelSymSrv()
gDebugger->CancelSymSrv();
}
BF_EXPORT int BF_CALLTYPE Debugger_LoadImageForModuleWith(const char* moduleName, const char* debugFilePath) // 0 = No Change, 1 = Loaded, 2 = Loading in background
{
return gDebugger->LoadImageForModule(moduleName, debugFilePath);
}
BF_EXPORT int BF_CALLTYPE Debugger_LoadDebugInfoForModule(const char* moduleName) // 0 = No Change, 1 = Loaded, 2 = Loading in background
{
return gDebugger->LoadDebugInfoForModule(moduleName);

View file

@ -304,6 +304,7 @@ public:
virtual void SetAliasPath(const StringImpl& origPath, const StringImpl& localPath) = 0;
virtual void CancelSymSrv() = 0;
virtual bool HasPendingDebugLoads() = 0;
virtual int LoadImageForModule(const StringImpl& moduleName, const StringImpl& debugFileName) = 0;
virtual int LoadDebugInfoForModule(const StringImpl& moduleName) = 0;
virtual int LoadDebugInfoForModule(const StringImpl& moduleName, const StringImpl& debugFileName) = 0;
virtual void StopDebugging() = 0;

View file

@ -11920,7 +11920,28 @@ String WinDebugger::GetModulesInfo()
str += module->mDisplayName;
str += "\t";
if (module->mLoadState == DbgModuleLoadState_Loaded)
{
str += module->mFilePath;
}
else if (module->mLoadState == DbgModuleLoadState_NotLoaded)
{
str += module->mFilePath;
str += " (Loading...)";
}
else if (module->mLoadState == DbgModuleLoadState_Failed)
{
str += "!";
str += module->mFilePath;
}
if (module->mMappedImageFile != NULL)
{
str += " (";
str += module->mMappedImageFile->mFileName;
str += ")";
}
str += "\t";
str += coff->mPDBPath;
str += "\t";
@ -11957,6 +11978,29 @@ bool WinDebugger::HasPendingDebugLoads()
return (!mPendingImageLoad.IsEmpty()) || (!mPendingDebugInfoLoad.IsEmpty());
}
int WinDebugger::LoadImageForModule(const StringImpl &modulePath, const StringImpl& imagePath)
{
AutoCrit autoCrit(mDebugManager->mCritSect);
for (auto dbgModule : mDebugTarget->mDbgModules)
{
if (modulePath.Equals(dbgModule->mFilePath, StringImpl::CompareKind_OrdinalIgnoreCase))
{
auto coff = (COFF*)dbgModule;
if (!coff->LoadModuleImage(imagePath))
{
mDebugManager->mOutMessages.push_back("error Failed to load image " + imagePath);
}
ModuleChanged(dbgModule);
return 0;
}
}
return 0;
}
int WinDebugger::LoadDebugInfoForModule(DbgModule* dbgModule)
{
if (!dbgModule->HasPendingDebugInfo())
@ -12007,10 +12051,10 @@ int WinDebugger::LoadDebugInfoForModule(const StringImpl& modulePath, const Stri
auto coff = (COFF*)dbgModule;
String err;
if (coff->mDbgSymRequest != NULL)
if (!coff->mPDBLoaded)
{
dbgModule->mFailMsgPtr = &err;
if (coff->TryLoadPDB(debugFileName, coff->mDbgSymRequest->mWantGuid, coff->mDbgSymRequest->mWantAge))
if (coff->TryLoadPDB(debugFileName, coff->mWantPDBGuid, coff->mWantAge))
{
ModuleChanged(dbgModule);
}

View file

@ -560,8 +560,7 @@ public:
void CleanupDebugEval(bool restoreRegisters = true);
bool FixCallStackIdx(int& callStackIdx);
virtual int LoadDebugInfoForModule(DbgModule* dbgModule);
virtual int LoadDebugInfoForModule(const StringImpl& moduleName, const StringImpl& debugFileName);
int LoadDebugInfoForModule(DbgModule* dbgModule);
public:
WinDebugger(DebugManager* debugManager);
@ -643,6 +642,8 @@ public:
virtual String GetModulesInfo() override;
virtual void CancelSymSrv() override;
virtual bool HasPendingDebugLoads() override;
virtual int LoadImageForModule(const StringImpl& moduleName, const StringImpl& debugFileName) override;
virtual int LoadDebugInfoForModule(const StringImpl& moduleName, const StringImpl& debugFileName) override;
virtual int LoadDebugInfoForModule(const StringImpl& moduleName) override;
virtual void StopDebugging() override;
virtual void Terminate() override;