mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-05 07:45:59 +02:00
Added Diagnostics panel
This commit is contained in:
parent
015470203b
commit
86a41649ec
12 changed files with 150 additions and 76 deletions
|
@ -3825,64 +3825,9 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
}
|
||||
|
||||
if ((mResultLocalVar != NULL) && (fieldInstance->mMergedDataIdx != -1))
|
||||
{
|
||||
int minMergedDataIdx = fieldInstance->mMergedDataIdx;
|
||||
int maxMergedDataIdx = minMergedDataIdx + 1;
|
||||
if (resolvedFieldType->IsStruct())
|
||||
maxMergedDataIdx = minMergedDataIdx + resolvedFieldType->ToTypeInstance()->mMergedFieldDataCount;
|
||||
|
||||
if (curCheckType->mIsUnion)
|
||||
{
|
||||
for (auto& checkFieldInstance : curCheckType->mFieldInstances)
|
||||
{
|
||||
if (&checkFieldInstance == fieldInstance)
|
||||
continue;
|
||||
|
||||
if (checkFieldInstance.mDataIdx == fieldInstance->mDataIdx)
|
||||
{
|
||||
int checkMinMergedDataIdx = checkFieldInstance.mMergedDataIdx;
|
||||
int checkMaxMergedDataIdx = checkMinMergedDataIdx + 1;
|
||||
if (checkFieldInstance.GetResolvedType()->IsStruct())
|
||||
checkMaxMergedDataIdx = checkMinMergedDataIdx + checkFieldInstance.mResolvedType->ToTypeInstance()->mMergedFieldDataCount;
|
||||
|
||||
minMergedDataIdx = BF_MIN(minMergedDataIdx, checkMinMergedDataIdx);
|
||||
maxMergedDataIdx = BF_MAX(maxMergedDataIdx, checkMaxMergedDataIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int fieldIdx = mResultLocalVarField - 1;
|
||||
if (fieldIdx == -1)
|
||||
{
|
||||
mResultLocalVarField = minMergedDataIdx + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldIdx += minMergedDataIdx;
|
||||
mResultLocalVarField = fieldIdx + 1;
|
||||
}
|
||||
mResultLocalVarFieldCount = maxMergedDataIdx - minMergedDataIdx;
|
||||
mResultLocalVarRefNode = targetSrc;
|
||||
|
||||
/*int fieldIdx = (mResultLocalVarIdx >> 16) - 1;
|
||||
if (fieldIdx == -1)
|
||||
{
|
||||
mResultLocalVarField = fieldInstance->mMergedDataIdx + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldIdx += fieldInstance->mMergedDataIdx;
|
||||
mResultLocalVarField = fieldIdx + 1;
|
||||
}
|
||||
mResultLocalVarFieldCount = 1;
|
||||
if (fieldInstance->mType->IsStruct())
|
||||
{
|
||||
auto fieldTypeInstance = fieldInstance->mType->ToTypeInstance();
|
||||
mResultLocalVarFieldCount = fieldTypeInstance->mMergedFieldDataCount;
|
||||
}
|
||||
mResultLocalVarRefNode = targetSrc;*/
|
||||
|
||||
|
||||
{
|
||||
fieldInstance->GetDataRange(mResultLocalVarField, mResultLocalVarFieldCount);
|
||||
mResultLocalVarRefNode = targetSrc;
|
||||
}
|
||||
|
||||
if ((curCheckType->IsIncomplete()) && (!curCheckType->mNeedsMethodProcessing))
|
||||
|
@ -15135,7 +15080,7 @@ void BfExprEvaluator::MarkResultAssigned()
|
|||
//return;
|
||||
|
||||
auto localVar = mResultLocalVar;
|
||||
int fieldIdx = mResultLocalVarField - 1;
|
||||
int fieldIdx = mResultLocalVarField - 1;
|
||||
int count = mResultLocalVarFieldCount;
|
||||
if (fieldIdx == -1)
|
||||
count = 1;
|
||||
|
|
|
@ -1098,7 +1098,7 @@ void BfModule::EnsureIRBuilder(bool dbgVerifyCodeGen)
|
|||
//mBfIRBuilder->mDbgVerifyCodeGen = true;
|
||||
if (
|
||||
(mModuleName == "-")
|
||||
//|| (mModuleName == "Tests_FuncRefs_Class")
|
||||
//|| (mModuleName == "BeefTest2_ClearColorValue")
|
||||
//|| (mModuleName == "Tests_FuncRefs")
|
||||
)
|
||||
mBfIRBuilder->mDbgVerifyCodeGen = true;
|
||||
|
@ -3744,19 +3744,21 @@ void BfModule::MarkFieldInitialized(BfFieldInstance* fieldInstance)
|
|||
auto fieldType = fieldInstance->GetResolvedType();
|
||||
if ((fieldInstance->mMergedDataIdx != -1) && (mCurMethodState != NULL))
|
||||
{
|
||||
int fieldDataCount = 1;
|
||||
if (fieldType->IsStruct())
|
||||
{
|
||||
auto structTypeInst = fieldType->ToTypeInstance();
|
||||
fieldDataCount = structTypeInst->mMergedFieldDataCount;
|
||||
}
|
||||
int fieldIdx = 0;
|
||||
int fieldCount = 0;
|
||||
fieldInstance->GetDataRange(fieldIdx, fieldCount);
|
||||
fieldIdx--;
|
||||
|
||||
int count = fieldCount;
|
||||
if (fieldIdx == -1)
|
||||
count = 1;
|
||||
|
||||
//TODO: Under what circumstances could 'thisVariable' be NULL?
|
||||
auto thisVariable = GetThisVariable();
|
||||
if (thisVariable != NULL)
|
||||
{
|
||||
for (int i = 0; i < fieldDataCount; i++)
|
||||
mCurMethodState->LocalDefined(thisVariable, fieldInstance->mMergedDataIdx + i);
|
||||
for (int i = 0; i < count; i++)
|
||||
mCurMethodState->LocalDefined(thisVariable, fieldIdx + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14979,7 +14981,14 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
|||
{
|
||||
// Failed
|
||||
}
|
||||
auto assignValue = GetFieldInitializerValue(fieldInst);
|
||||
auto assignValue = GetFieldInitializerValue(fieldInst);
|
||||
|
||||
if (mCurTypeInstance->IsUnion())
|
||||
{
|
||||
auto fieldPtrType = CreatePointerType(fieldInst->mResolvedType);
|
||||
fieldAddr = mBfIRBuilder->CreateBitCast(fieldAddr, mBfIRBuilder->MapType(fieldPtrType));
|
||||
}
|
||||
|
||||
if ((fieldAddr) && (assignValue))
|
||||
mBfIRBuilder->CreateStore(assignValue.mValue, fieldAddr);
|
||||
}
|
||||
|
|
|
@ -1299,16 +1299,23 @@ BF_EXPORT void BF_CALLTYPE Debugger_ForegroundTarget()
|
|||
//BF_ASSERT(worked);
|
||||
}
|
||||
|
||||
BF_EXPORT const char* BF_CALLTYPE Debugger_GetProcessInfo()
|
||||
{
|
||||
String& outString = *gTLStrReturn.Get();
|
||||
outString = gDebugger->GetProcessInfo();
|
||||
return outString.c_str();
|
||||
}
|
||||
|
||||
BF_EXPORT const char* BF_CALLTYPE Debugger_GetThreadInfo()
|
||||
{
|
||||
String& outString = *gTLStrReturn.Get();
|
||||
String& outString = *gTLStrReturn.Get();
|
||||
outString = gDebugger->GetThreadInfo();
|
||||
return outString.c_str();
|
||||
}
|
||||
|
||||
BF_EXPORT void BF_CALLTYPE Debugger_SetActiveThread(int threadId)
|
||||
{
|
||||
gDebugger->SetActiveThread(threadId);
|
||||
gDebugger->SetActiveThread(threadId);
|
||||
}
|
||||
|
||||
BF_EXPORT int BF_CALLTYPE Debugger_GetActiveThread()
|
||||
|
|
|
@ -283,6 +283,7 @@ public:
|
|||
virtual String GetAutoExpressions(int callStackIdx, uint64 memoryRangeStart, uint64 memoryRangeLen) = 0;
|
||||
virtual String GetAutoLocals(int callStackIdx, bool showRegs) = 0;
|
||||
virtual String CompactChildExpression(const StringImpl& expr, const StringImpl& parentExpr, int callStackIdx) = 0;
|
||||
virtual String GetProcessInfo() = 0;
|
||||
virtual String GetThreadInfo() = 0;
|
||||
virtual void SetActiveThread(int threadId) = 0;
|
||||
virtual int GetActiveThread() = 0;
|
||||
|
|
|
@ -10201,6 +10201,31 @@ String WinDebugger::CompactChildExpression(const StringImpl& expr, const StringI
|
|||
return result;
|
||||
}
|
||||
|
||||
String WinDebugger::GetProcessInfo()
|
||||
{
|
||||
AutoCrit autoCrit(mDebugManager->mCritSect);
|
||||
|
||||
if ((mActiveThread == NULL) && (!mIsRunning))
|
||||
return "";
|
||||
|
||||
FILETIME creationTime = { 0 };
|
||||
FILETIME exitTime = { 0 };
|
||||
FILETIME kernelTime = { 0 };
|
||||
FILETIME userTime = { 0 };
|
||||
GetProcessTimes(mProcessInfo.hProcess, &creationTime, &exitTime, &kernelTime, &userTime);
|
||||
|
||||
String retStr;
|
||||
PROCESS_MEMORY_COUNTERS memInfo = { 0 };
|
||||
GetProcessMemoryInfo(mProcessInfo.hProcess, &memInfo, sizeof(PROCESS_MEMORY_COUNTERS));
|
||||
|
||||
retStr += StrFormat("VirtualMemory\t%d\n", memInfo.PagefileUsage);
|
||||
retStr += StrFormat("WorkingMemory\t%d\n", memInfo.WorkingSetSize);
|
||||
retStr += StrFormat("KernelTime\t%lld\n", *(int64*)&kernelTime);
|
||||
retStr += StrFormat("UserTime\t%lld\n", *(int64*)&userTime);
|
||||
|
||||
return retStr;
|
||||
}
|
||||
|
||||
String WinDebugger::GetThreadInfo()
|
||||
{
|
||||
AutoCrit autoCrit(mDebugManager->mCritSect);
|
||||
|
|
|
@ -626,6 +626,7 @@ public:
|
|||
virtual String GetAutoExpressions(int callStackIdx, uint64 memoryRangeStart, uint64 memoryRangeLen) override;
|
||||
virtual String GetAutoLocals(int callStackIdx, bool showRegs) override;
|
||||
virtual String CompactChildExpression(const StringImpl& expr, const StringImpl& parentExpr, int callStackIdx) override;
|
||||
virtual String GetProcessInfo() override;
|
||||
virtual String GetThreadInfo() override;
|
||||
virtual void SetActiveThread(int threadId) override;
|
||||
virtual int GetActiveThread() override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue