1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Fixes to enum changes, fixed [Checked] debugger interaction

This commit is contained in:
Brian Fiete 2019-11-29 09:21:51 -08:00
parent 17be9daade
commit 64f117b89f
10 changed files with 116 additions and 24 deletions

View file

@ -597,6 +597,15 @@ const char* COFF::CvParseAndDupString(uint8*& data)
return dupStr;
}
const char* COFF::CvDupString(const char* str, int strLen)
{
BP_ALLOC("CvDupString", strLen + 1);
char* dupStr = (char*)mAlloc.AllocBytes(strLen + 1, "CvParseAndDupString");
memcpy(dupStr, str, strLen);
dupStr[strLen] = 0;
return dupStr;
}
void COFF::CvParseArgList(DbgSubprogram* subprogram, int tagIdx, bool ipi)
{
uint8* data = CvGetTagData(tagIdx, ipi);
@ -837,7 +846,7 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi)
if (!parentType->mSizeCalculated)
{
if ((parentType->mSize == 0) && (baseTypeEntry->mBaseType->IsBfObject()))
if ((baseTypeEntry->mBaseType->GetByteCount() == 0) && (baseTypeEntry->mBaseType->IsBfObject()))
{
parentType->mExtType = DbgExtType_Interface;
}
@ -992,6 +1001,10 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi)
if (strcmp(fieldName, "$prim") == 0)
{
parentType->mTypeParam = CvGetType(fieldTypeId);
parentType->mTypeParam = GetPrimitiveType(parentType->mTypeParam->mTypeCode, DbgLanguage_Beef);
parentType->mSize = parentType->mTypeParam->mSize;
parentType->mAlign = parentType->mTypeParam->mAlign;
if ((parentType->mBaseTypes.mHead != NULL) && (strcmp(parentType->mBaseTypes.mHead->mBaseType->mName, "System.Enum") == 0))
parentType->mTypeCode = DbgType_Enum;
break;
@ -1437,6 +1450,11 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi)
const char* name = _ParseString();
if (strstr(name, "Derived") != NULL)
{
NOP;
}
// if ((strstr(name, "`") != NULL) || (strstr(name, "::__l") != NULL))
// {
// OutputDebugStrF("Local type: %s\n", name);
@ -1503,8 +1521,10 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi)
if (strncmp(name, "_bf:", 4) == 0)
{
// Beef types have different strides from size
// Beef types have different strides from size. Note we MUST set size to zero here, because there are
// some BF_MAX calculations we perform on it
dbgType->mSizeCalculated = false;
dbgType->mSize = 0;
}
}
@ -2487,7 +2507,7 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
subprogram->mTagIdx = (int)(dataEnd - sectionData); // Position for method data
subprogram->mIsOptimized = isOptimized;
subprogram->mCompileUnit = compileUnit;
const char* name = DbgDupString((const char*)procSym->name, "DbgDupString.S_GPROC32");
char* name = DbgDupString((const char*)procSym->name, "DbgDupString.S_GPROC32");
if (procSym->flags.CV_PFLAG_OPTDBGINFO)
{
@ -2507,8 +2527,26 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
localVar = NULL;
bool hasColon = false;
for (const char* cPtr = name; *cPtr != 0; cPtr++)
hasColon |= *cPtr == ':';
for (char* cPtr = name; *cPtr != 0; cPtr++)
{
char c = *cPtr;
hasColon |= c == ':';
if (c == '$')
{
if (strcmp(cPtr, "$CHK") == 0)
{
subprogram->mCheckedKind = BfCheckedKind_Checked;
*cPtr = NULL;
break;
}
else if (strcmp(cPtr, "$UCHK") == 0)
{
subprogram->mCheckedKind = BfCheckedKind_Unchecked;
*cPtr = NULL;
break;
}
}
}
subprogram->mPrologueSize = procSym->DbgStart;
subprogram->mBlock.mLowPC = addr;
@ -4119,6 +4157,27 @@ void COFF::PopulateSubprogram(DbgSubprogram* dbgSubprogram)
dbgSubprogram->mDeferredInternalsSize = 0;
}
void COFF::FixSubprogramName(DbgSubprogram* dbgSubprogram)
{
const char* name = dbgSubprogram->mName;
for (const char* cPtr = name; *cPtr != 0; cPtr++)
{
char c = *cPtr;
if (c == '$')
{
bool isChecked = strcmp(cPtr, "$CHK") == 0;
bool isUnchecked = strcmp(cPtr, "$UCHK") == 0;
if (isChecked || isUnchecked)
{
dbgSubprogram->mCheckedKind = isChecked ? BfCheckedKind_Checked : BfCheckedKind_Unchecked;
dbgSubprogram->mName = CvDupString(name, cPtr - name);
return;
}
}
}
}
void COFF::FixupInlinee(DbgSubprogram* dbgSubprogram, uint32 ipiTag)
{
if (!mCvIPIReader.IsSetup())
@ -4178,8 +4237,9 @@ void COFF::FixupInlinee(DbgSubprogram* dbgSubprogram, uint32 ipiTag)
case LF_MFUNC_ID:
{
lfMFuncId* funcData = (lfMFuncId*)dataStart;
CvParseMethod(NULL, NULL, funcData->type, false, dbgSubprogram);
CvParseMethod(NULL, NULL, funcData->type, false, dbgSubprogram);
dbgSubprogram->mName = (const char*)funcData->name;
FixSubprogramName(dbgSubprogram);
dbgSubprogram->mParentType = CvGetType(funcData->parentType);
}
@ -5247,24 +5307,40 @@ const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_
int moduleId = refSym.imod - 1;
bool wasBeef = false;
const char* memberName = CvCheckTargetMatch(name, wasBeef);
char* memberName = (char*)CvCheckTargetMatch(name, wasBeef);
if (memberName == NULL)
break;
bool wantsCopy = madeCopy;
bool isIllegal = false;
for (const char* cPtr = memberName; *cPtr != 0; cPtr++)
{
char c = *cPtr;
if ((c == '<') || (c == '`') || (c == '$'))
if (c == '$')
{
if ((strcmp(cPtr, "$CHK") == 0) || (strcmp(cPtr, "$UCHK") == 0))
{
auto prevName = memberName;
memberName = DbgDupString(prevName);
memberName[cPtr - prevName] = 0;
wantsCopy = false;
break;
}
else
isIllegal = true;
}
if ((c == '<') || (c == '`'))
isIllegal = true;
}
}
if (!isIllegal)
{
BP_ALLOC_T(DbgMethodNameEntry);
auto methodNameEntry = mAlloc.Alloc<DbgMethodNameEntry>();
methodNameEntry->mCompileUnitId = moduleId;
methodNameEntry->mName = madeCopy ? DbgDupString(memberName) : memberName;
methodNameEntry->mName = wantsCopy ? DbgDupString(memberName) : memberName;
mGlobalsTargetType->mMethodNameList.PushBack(methodNameEntry);
}
}

View file

@ -305,6 +305,7 @@ public:
virtual void PopulateType(DbgType* dbgType) override;
virtual void PopulateTypeGlobals(DbgType* dbgType) override;
virtual void PopulateSubprogram(DbgSubprogram* dbgSubprogram) override;
void FixSubprogramName(DbgSubprogram * dbgSubprogram);
int MapImport(CvCompileUnit* compileUnit, int Id);
void FixupInlinee(DbgSubprogram* dbgSubprogram, uint32 ipiTag);
virtual void FixupInlinee(DbgSubprogram* dbgSubprogram) override;
@ -340,6 +341,7 @@ public:
uint8* HandleSymStreamEntries(CvSymStreamType symStreamType, uint8* data, uint8* addrMap);
const char* CvParseString(uint8*& data);
const char* CvParseAndDupString(uint8*& data);
const char* CvDupString(const char* str, int strLen);
void CvReadStream(int sectionIdx, CvStreamReader& streamReader);
void CvInitStreamRaw(CvStreamReader& streamReader, uint8* data, int size);

View file

@ -56,6 +56,13 @@ enum BfProtection : uint8
BfProtection_Public,
};
enum BfCheckedKind : int8
{
BfCheckedKind_NotSet,
BfCheckedKind_Checked,
BfCheckedKind_Unchecked
};
static bool CheckProtection(BfProtection protection, bool allowProtected, bool allowPrivate)
{
return (protection == BfProtection_Public) ||

View file

@ -2615,7 +2615,7 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type)
flags |= llvm::DINode::FlagArtificial;
}
String methodName = methodDef->mName;
String methodName = methodDef->mName;
llvm::SmallVector<BfIRMDNode, 1> genericArgs;
llvm::SmallVector<BfIRValue, 1> genericConstValueArgs;
auto diFunction = DbgCreateMethod(funcScope, methodName, mangledName, fileDIScope,

View file

@ -1936,7 +1936,8 @@ void BfMSMangler::Mangle(StringImpl& name, bool is64Bit, BfMethodInstance* metho
AddStr(mangleContext, name, methodDef->mName);
}
if ((methodInst->mMethodDef->mDeclaringType->mPartialIdx != -1) && (!methodInst->mIsForeignMethodDef))
if ((methodInst->mMethodDef->mDeclaringType->mPartialIdx != -1) && (methodInst->mMethodDef->mDeclaringType->IsExtension()) &&
(!methodInst->mIsForeignMethodDef) && (!methodInst->mMethodDef->mIsExtern))
{
auto declType = methodInst->mMethodDef->mDeclaringType;
BF_ASSERT(methodInst->GetOwner()->mTypeDef->mIsCombinedPartial);

View file

@ -16187,6 +16187,11 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
}
}
if (methodDef->mCheckedKind == BfCheckedKind_Checked)
methodName += "$CHK";
else if (methodDef->mCheckedKind == BfCheckedKind_Unchecked)
methodName += "$UCHK";
methodState.mDIFile = mCurFilePosition.mFileInstance->mDIFile;
// diFunction = mBfIRBuilder->DbgCreateMethod(funcScope, methodName, mangledName, methodState.mDIFile,
// defLine + 1, diFuncType, false, true,

View file

@ -669,13 +669,6 @@ enum BfImportKind : int8
BfImportKind_Export
};
enum BfCheckedKind : int8
{
BfCheckedKind_NotSet,
BfCheckedKind_Checked,
BfCheckedKind_Unchecked
};
enum BfCommutableKind : int8
{
BfCommutableKind_None,

View file

@ -395,8 +395,14 @@ String DbgSubprogram::ToString()
mCompileUnit->mDbgModule->FixupInlinee(this);
PopulateSubprogram();
String str;
if (mCheckedKind == BfCheckedKind_Checked)
str += "[Checked] ";
else if (mCheckedKind == BfCheckedKind_Unchecked)
str += "[Unchecked] ";
auto language = GetLanguage();
if (mName == NULL)
{
@ -992,7 +998,7 @@ bool DbgType::IsStruct()
}
bool DbgType::IsPrimitiveType()
{
{
return (mTypeCode >= DbgType_i8) && (mTypeCode <= DbgType_Bool);
}
@ -1141,7 +1147,7 @@ DbgExtType DbgType::CalcExtType()
}
auto baseExtType = baseType->CalcExtType();
if ((baseExtType == DbgExtType_BfObject) && (mSize == 0))
if ((baseExtType == DbgExtType_BfObject) && (GetByteCount() == 0))
baseExtType = DbgExtType_Interface;
return baseExtType;
}

View file

@ -400,6 +400,7 @@ public:
DbgType* mReturnType;
DbgMethodType mMethodType;
BfProtection mProtection;
BfCheckedKind mCheckedKind;
SLIList<DbgVariable*> mParams;
DbgSubprogram* mNext;
@ -424,6 +425,7 @@ public:
mNext = NULL;
mMethodType = DbgMethodType_Normal;
mProtection = BfProtection_Public;
mCheckedKind = BfCheckedKind_NotSet;
mVTableLoc = -1;
mStepFilterVersion = -1;
}

View file

@ -7673,7 +7673,7 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
{
summaryType->PopulateType();
if (summaryType->IsPrimitiveType())
if (summaryType->IsTypedPrimitive())
{
if (formatInfo.mTotalSummaryLength + (int)displayString.length() > 255)
{
@ -7688,7 +7688,7 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
displayStrFormatInfo.mTotalSummaryLength += (int)displayString.length();
displayStrFormatInfo.mHidePointers = false;
auto primType = dwUseType->GetDbgModule()->GetPrimitiveType(summaryType->mTypeCode, dwUseType->GetLanguage());
DbgType* primType = summaryType->mTypeParam;
String result;
if ((dataPtr != 0) && (dataPtr != -1))