mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Changes to improve IDE Module Panel, allowing loading image and pdb
This commit is contained in:
parent
d41a8c5683
commit
bac46ef6e9
10 changed files with 124 additions and 41 deletions
|
@ -328,6 +328,9 @@ namespace IDE.Debugger
|
||||||
[StdCall,CLink]
|
[StdCall,CLink]
|
||||||
static extern bool Debugger_HasPendingDebugLoads();
|
static extern bool Debugger_HasPendingDebugLoads();
|
||||||
|
|
||||||
|
[StdCall,CLink]
|
||||||
|
static extern int32 Debugger_LoadImageForModuleWith(char8* moduleName, char8* imageFileName);
|
||||||
|
|
||||||
[StdCall,CLink]
|
[StdCall,CLink]
|
||||||
static extern int32 Debugger_LoadDebugInfoForModule(char8* moduleName);
|
static extern int32 Debugger_LoadDebugInfoForModule(char8* moduleName);
|
||||||
|
|
||||||
|
@ -1089,6 +1092,11 @@ namespace IDE.Debugger
|
||||||
return Debugger_LoadDebugInfoForModule(moduleName);
|
return Debugger_LoadDebugInfoForModule(moduleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int32 LoadImageForModule(String moduleName, String debugFileName)
|
||||||
|
{
|
||||||
|
return Debugger_LoadImageForModuleWith(moduleName, debugFileName);
|
||||||
|
}
|
||||||
|
|
||||||
public int32 LoadDebugInfoForModule(String moduleName, String debugFileName)
|
public int32 LoadDebugInfoForModule(String moduleName, String debugFileName)
|
||||||
{
|
{
|
||||||
return Debugger_LoadDebugInfoForModuleWith(moduleName, debugFileName);
|
return Debugger_LoadDebugInfoForModuleWith(moduleName, debugFileName);
|
||||||
|
|
|
@ -223,7 +223,9 @@ uint8* CvStreamReader::GetPermanentPtr(int offset, int size, bool* madeCopy)
|
||||||
COFF::COFF(DebugTarget* debugTarget) : DbgModule(debugTarget)
|
COFF::COFF(DebugTarget* debugTarget) : DbgModule(debugTarget)
|
||||||
{
|
{
|
||||||
mParseKind = ParseKind_Full;
|
mParseKind = ParseKind_Full;
|
||||||
|
memset(mWantPDBGuid, 0, 16);
|
||||||
memset(mPDBGuid, 0, 16);
|
memset(mPDBGuid, 0, 16);
|
||||||
|
mWantAge = -1;
|
||||||
mDebugAge = -1;
|
mDebugAge = -1;
|
||||||
mFileAge = -1;
|
mFileAge = -1;
|
||||||
mCvMinTag = -1;
|
mCvMinTag = -1;
|
||||||
|
@ -5824,6 +5826,9 @@ bool COFF::LoadPDB(const String& pdbPath, uint8 wantGuid[16], int32 wantAge)
|
||||||
mDebugTarget->mWasLocallyBuilt = FileExists(pdbPath);
|
mDebugTarget->mWasLocallyBuilt = FileExists(pdbPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memcpy(mWantPDBGuid, wantGuid, 16);
|
||||||
|
mWantAge = wantAge;
|
||||||
|
|
||||||
mDbgSymRequest = mDebugger->mDbgSymSrv.CreateRequest(mFilePath, pdbPath, wantGuid, wantAge);
|
mDbgSymRequest = mDebugger->mDbgSymSrv.CreateRequest(mFilePath, pdbPath, wantGuid, wantAge);
|
||||||
mDbgSymRequest->SearchLocal();
|
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()
|
bool COFF::RequestImage()
|
||||||
{
|
{
|
||||||
if (!mDebugger->IsMiniDumpDebugger())
|
if (!mDebugger->IsMiniDumpDebugger())
|
||||||
|
@ -6455,27 +6490,7 @@ bool COFF::RequestImage()
|
||||||
|
|
||||||
mDebugger->mRunState = prevRunState;
|
mDebugger->mRunState = prevRunState;
|
||||||
|
|
||||||
if (!imagePath.IsEmpty())
|
return LoadModuleImage(imagePath);
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -214,6 +214,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
uint8 mWantPDBGuid[16];
|
||||||
|
int mWantAge;
|
||||||
|
|
||||||
uint8 mPDBGuid[16];
|
uint8 mPDBGuid[16];
|
||||||
int mFileAge;
|
int mFileAge;
|
||||||
int mDebugAge;
|
int mDebugAge;
|
||||||
|
@ -321,6 +324,7 @@ public:
|
||||||
virtual addr_target LocateSymbol(const StringImpl& name) override;
|
virtual addr_target LocateSymbol(const StringImpl& name) override;
|
||||||
virtual void ParseFrameDescriptors() override;
|
virtual void ParseFrameDescriptors() override;
|
||||||
|
|
||||||
|
bool LoadModuleImage(const StringImpl& imagePath);
|
||||||
void FixConstant(DbgVariable* variable);
|
void FixConstant(DbgVariable* variable);
|
||||||
void MapRanges(DbgVariable* variable, CV_LVAR_ADDR_RANGE* range, CV_LVAR_ADDR_GAP* gaps);
|
void MapRanges(DbgVariable* variable, CV_LVAR_ADDR_RANGE* range, CV_LVAR_ADDR_GAP* gaps);
|
||||||
void MakeThis(DbgSubprogram* curSubprogram, DbgVariable*& curParam);
|
void MakeThis(DbgSubprogram* curSubprogram, DbgVariable*& curParam);
|
||||||
|
|
|
@ -9756,22 +9756,26 @@ BfLambdaInstance* BfExprEvaluator::GetLambdaInstance(BfLambdaBindExpression* lam
|
||||||
auto voidType = mModule->GetPrimitiveType(BfTypeCode_None);
|
auto voidType = mModule->GetPrimitiveType(BfTypeCode_None);
|
||||||
auto dtorFuncType = mModule->mBfIRBuilder->CreateFunctionType(mModule->mBfIRBuilder->MapType(voidType), newTypes, false);
|
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();
|
BfMethodDef* dtorMethodDef = new BfMethodDef();
|
||||||
dtorMethodDef->mDeclaringType = mModule->mCurMethodInstance->mMethodDef->mDeclaringType;
|
dtorMethodDef->mDeclaringType = mModule->mCurMethodInstance->mMethodDef->mDeclaringType;
|
||||||
dtorMethodDef->mName = "~this";
|
dtorMethodDef->mName = "~this$";
|
||||||
|
dtorMethodDef->mName += methodDef->mName;
|
||||||
|
|
||||||
dtorMethodDef->mMethodType = BfMethodType_Normal;
|
dtorMethodDef->mMethodType = BfMethodType_Normal;
|
||||||
dtorMethodDef->mBody = lambdaBindExpr->mDtor;
|
dtorMethodDef->mBody = lambdaBindExpr->mDtor;
|
||||||
dtorMethodDef->mIdx = mModule->mCurMethodInstance->mMethodDef->mIdx;
|
dtorMethodDef->mIdx = mModule->mCurMethodInstance->mMethodDef->mIdx;
|
||||||
|
|
||||||
BfMethodInstance* dtorMethodInstance = new BfMethodInstance();
|
BfMethodInstance* dtorMethodInstance = new BfMethodInstance();
|
||||||
//dtorMethodInstance->mMethodInstanceGroup = &methodInstanceGroup;
|
|
||||||
dtorMethodInstance->mIRFunction = dtorFunc;
|
|
||||||
dtorMethodInstance->mMethodDef = dtorMethodDef;
|
dtorMethodInstance->mMethodDef = dtorMethodDef;
|
||||||
dtorMethodInstance->mReturnType = mModule->GetPrimitiveType(BfTypeCode_None);
|
dtorMethodInstance->mReturnType = mModule->GetPrimitiveType(BfTypeCode_None);
|
||||||
dtorMethodInstance->mMethodInstanceGroup = &methodInstanceGroup;
|
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->mIncompleteMethodCount++;
|
||||||
mModule->mBfIRBuilder->SaveDebugLocation();
|
mModule->mBfIRBuilder->SaveDebugLocation();
|
||||||
//
|
//
|
||||||
|
|
|
@ -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->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;
|
mFailed = true;
|
||||||
|
|
|
@ -1532,6 +1532,11 @@ BF_EXPORT void BF_CALLTYPE Debugger_CancelSymSrv()
|
||||||
gDebugger->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
|
BF_EXPORT int BF_CALLTYPE Debugger_LoadDebugInfoForModule(const char* moduleName) // 0 = No Change, 1 = Loaded, 2 = Loading in background
|
||||||
{
|
{
|
||||||
return gDebugger->LoadDebugInfoForModule(moduleName);
|
return gDebugger->LoadDebugInfoForModule(moduleName);
|
||||||
|
|
|
@ -304,6 +304,7 @@ public:
|
||||||
virtual void SetAliasPath(const StringImpl& origPath, const StringImpl& localPath) = 0;
|
virtual void SetAliasPath(const StringImpl& origPath, const StringImpl& localPath) = 0;
|
||||||
virtual void CancelSymSrv() = 0;
|
virtual void CancelSymSrv() = 0;
|
||||||
virtual bool HasPendingDebugLoads() = 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) = 0;
|
||||||
virtual int LoadDebugInfoForModule(const StringImpl& moduleName, const StringImpl& debugFileName) = 0;
|
virtual int LoadDebugInfoForModule(const StringImpl& moduleName, const StringImpl& debugFileName) = 0;
|
||||||
virtual void StopDebugging() = 0;
|
virtual void StopDebugging() = 0;
|
||||||
|
|
|
@ -11920,7 +11920,28 @@ String WinDebugger::GetModulesInfo()
|
||||||
|
|
||||||
str += module->mDisplayName;
|
str += module->mDisplayName;
|
||||||
str += "\t";
|
str += "\t";
|
||||||
|
if (module->mLoadState == DbgModuleLoadState_Loaded)
|
||||||
|
{
|
||||||
str += module->mFilePath;
|
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 += "\t";
|
||||||
str += coff->mPDBPath;
|
str += coff->mPDBPath;
|
||||||
str += "\t";
|
str += "\t";
|
||||||
|
@ -11957,6 +11978,29 @@ bool WinDebugger::HasPendingDebugLoads()
|
||||||
return (!mPendingImageLoad.IsEmpty()) || (!mPendingDebugInfoLoad.IsEmpty());
|
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)
|
int WinDebugger::LoadDebugInfoForModule(DbgModule* dbgModule)
|
||||||
{
|
{
|
||||||
if (!dbgModule->HasPendingDebugInfo())
|
if (!dbgModule->HasPendingDebugInfo())
|
||||||
|
@ -12007,10 +12051,10 @@ int WinDebugger::LoadDebugInfoForModule(const StringImpl& modulePath, const Stri
|
||||||
auto coff = (COFF*)dbgModule;
|
auto coff = (COFF*)dbgModule;
|
||||||
|
|
||||||
String err;
|
String err;
|
||||||
if (coff->mDbgSymRequest != NULL)
|
if (!coff->mPDBLoaded)
|
||||||
{
|
{
|
||||||
dbgModule->mFailMsgPtr = &err;
|
dbgModule->mFailMsgPtr = &err;
|
||||||
if (coff->TryLoadPDB(debugFileName, coff->mDbgSymRequest->mWantGuid, coff->mDbgSymRequest->mWantAge))
|
if (coff->TryLoadPDB(debugFileName, coff->mWantPDBGuid, coff->mWantAge))
|
||||||
{
|
{
|
||||||
ModuleChanged(dbgModule);
|
ModuleChanged(dbgModule);
|
||||||
}
|
}
|
||||||
|
|
|
@ -560,8 +560,7 @@ public:
|
||||||
void CleanupDebugEval(bool restoreRegisters = true);
|
void CleanupDebugEval(bool restoreRegisters = true);
|
||||||
bool FixCallStackIdx(int& callStackIdx);
|
bool FixCallStackIdx(int& callStackIdx);
|
||||||
|
|
||||||
virtual int LoadDebugInfoForModule(DbgModule* dbgModule);
|
int LoadDebugInfoForModule(DbgModule* dbgModule);
|
||||||
virtual int LoadDebugInfoForModule(const StringImpl& moduleName, const StringImpl& debugFileName);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WinDebugger(DebugManager* debugManager);
|
WinDebugger(DebugManager* debugManager);
|
||||||
|
@ -643,6 +642,8 @@ public:
|
||||||
virtual String GetModulesInfo() override;
|
virtual String GetModulesInfo() override;
|
||||||
virtual void CancelSymSrv() override;
|
virtual void CancelSymSrv() override;
|
||||||
virtual bool HasPendingDebugLoads() 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 int LoadDebugInfoForModule(const StringImpl& moduleName) override;
|
||||||
virtual void StopDebugging() override;
|
virtual void StopDebugging() override;
|
||||||
virtual void Terminate() override;
|
virtual void Terminate() override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue