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; 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) void COFF::CvParseArgList(DbgSubprogram* subprogram, int tagIdx, bool ipi)
{ {
uint8* data = CvGetTagData(tagIdx, ipi); uint8* data = CvGetTagData(tagIdx, ipi);
@ -837,7 +846,7 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi)
if (!parentType->mSizeCalculated) if (!parentType->mSizeCalculated)
{ {
if ((parentType->mSize == 0) && (baseTypeEntry->mBaseType->IsBfObject())) if ((baseTypeEntry->mBaseType->GetByteCount() == 0) && (baseTypeEntry->mBaseType->IsBfObject()))
{ {
parentType->mExtType = DbgExtType_Interface; parentType->mExtType = DbgExtType_Interface;
} }
@ -992,6 +1001,10 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi)
if (strcmp(fieldName, "$prim") == 0) if (strcmp(fieldName, "$prim") == 0)
{ {
parentType->mTypeParam = CvGetType(fieldTypeId); 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)) if ((parentType->mBaseTypes.mHead != NULL) && (strcmp(parentType->mBaseTypes.mHead->mBaseType->mName, "System.Enum") == 0))
parentType->mTypeCode = DbgType_Enum; parentType->mTypeCode = DbgType_Enum;
break; break;
@ -1437,6 +1450,11 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi)
const char* name = _ParseString(); const char* name = _ParseString();
if (strstr(name, "Derived") != NULL)
{
NOP;
}
// if ((strstr(name, "`") != NULL) || (strstr(name, "::__l") != NULL)) // if ((strstr(name, "`") != NULL) || (strstr(name, "::__l") != NULL))
// { // {
// OutputDebugStrF("Local type: %s\n", name); // OutputDebugStrF("Local type: %s\n", name);
@ -1503,8 +1521,10 @@ DbgType* COFF::CvParseType(int tagIdx, bool ipi)
if (strncmp(name, "_bf:", 4) == 0) 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->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->mTagIdx = (int)(dataEnd - sectionData); // Position for method data
subprogram->mIsOptimized = isOptimized; subprogram->mIsOptimized = isOptimized;
subprogram->mCompileUnit = compileUnit; 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) if (procSym->flags.CV_PFLAG_OPTDBGINFO)
{ {
@ -2507,8 +2527,26 @@ void COFF::ParseCompileUnit_Symbols(DbgCompileUnit* compileUnit, uint8* sectionD
localVar = NULL; localVar = NULL;
bool hasColon = false; bool hasColon = false;
for (const char* cPtr = name; *cPtr != 0; cPtr++) for (char* cPtr = name; *cPtr != 0; cPtr++)
hasColon |= *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->mPrologueSize = procSym->DbgStart;
subprogram->mBlock.mLowPC = addr; subprogram->mBlock.mLowPC = addr;
@ -4119,6 +4157,27 @@ void COFF::PopulateSubprogram(DbgSubprogram* dbgSubprogram)
dbgSubprogram->mDeferredInternalsSize = 0; 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) void COFF::FixupInlinee(DbgSubprogram* dbgSubprogram, uint32 ipiTag)
{ {
if (!mCvIPIReader.IsSetup()) if (!mCvIPIReader.IsSetup())
@ -4180,6 +4239,7 @@ void COFF::FixupInlinee(DbgSubprogram* dbgSubprogram, uint32 ipiTag)
lfMFuncId* funcData = (lfMFuncId*)dataStart; lfMFuncId* funcData = (lfMFuncId*)dataStart;
CvParseMethod(NULL, NULL, funcData->type, false, dbgSubprogram); CvParseMethod(NULL, NULL, funcData->type, false, dbgSubprogram);
dbgSubprogram->mName = (const char*)funcData->name; dbgSubprogram->mName = (const char*)funcData->name;
FixSubprogramName(dbgSubprogram);
dbgSubprogram->mParentType = CvGetType(funcData->parentType); dbgSubprogram->mParentType = CvGetType(funcData->parentType);
} }
@ -5247,15 +5307,31 @@ const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_
int moduleId = refSym.imod - 1; int moduleId = refSym.imod - 1;
bool wasBeef = false; bool wasBeef = false;
const char* memberName = CvCheckTargetMatch(name, wasBeef); char* memberName = (char*)CvCheckTargetMatch(name, wasBeef);
if (memberName == NULL) if (memberName == NULL)
break; break;
bool wantsCopy = madeCopy;
bool isIllegal = false; bool isIllegal = false;
for (const char* cPtr = memberName; *cPtr != 0; cPtr++) for (const char* cPtr = memberName; *cPtr != 0; cPtr++)
{ {
char c = *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; isIllegal = true;
} }
@ -5264,7 +5340,7 @@ const char* COFF::CvParseSymbol(int offset, CvSymStreamType symStreamType, addr_
BP_ALLOC_T(DbgMethodNameEntry); BP_ALLOC_T(DbgMethodNameEntry);
auto methodNameEntry = mAlloc.Alloc<DbgMethodNameEntry>(); auto methodNameEntry = mAlloc.Alloc<DbgMethodNameEntry>();
methodNameEntry->mCompileUnitId = moduleId; methodNameEntry->mCompileUnitId = moduleId;
methodNameEntry->mName = madeCopy ? DbgDupString(memberName) : memberName; methodNameEntry->mName = wantsCopy ? DbgDupString(memberName) : memberName;
mGlobalsTargetType->mMethodNameList.PushBack(methodNameEntry); mGlobalsTargetType->mMethodNameList.PushBack(methodNameEntry);
} }
} }

View file

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

View file

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

View file

@ -1936,7 +1936,8 @@ void BfMSMangler::Mangle(StringImpl& name, bool is64Bit, BfMethodInstance* metho
AddStr(mangleContext, name, methodDef->mName); 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; auto declType = methodInst->mMethodDef->mDeclaringType;
BF_ASSERT(methodInst->GetOwner()->mTypeDef->mIsCombinedPartial); 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; methodState.mDIFile = mCurFilePosition.mFileInstance->mDIFile;
// diFunction = mBfIRBuilder->DbgCreateMethod(funcScope, methodName, mangledName, methodState.mDIFile, // diFunction = mBfIRBuilder->DbgCreateMethod(funcScope, methodName, mangledName, methodState.mDIFile,
// defLine + 1, diFuncType, false, true, // defLine + 1, diFuncType, false, true,

View file

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

View file

@ -397,6 +397,12 @@ String DbgSubprogram::ToString()
PopulateSubprogram(); PopulateSubprogram();
String str; String str;
if (mCheckedKind == BfCheckedKind_Checked)
str += "[Checked] ";
else if (mCheckedKind == BfCheckedKind_Unchecked)
str += "[Unchecked] ";
auto language = GetLanguage(); auto language = GetLanguage();
if (mName == NULL) if (mName == NULL)
{ {
@ -1141,7 +1147,7 @@ DbgExtType DbgType::CalcExtType()
} }
auto baseExtType = baseType->CalcExtType(); auto baseExtType = baseType->CalcExtType();
if ((baseExtType == DbgExtType_BfObject) && (mSize == 0)) if ((baseExtType == DbgExtType_BfObject) && (GetByteCount() == 0))
baseExtType = DbgExtType_Interface; baseExtType = DbgExtType_Interface;
return baseExtType; return baseExtType;
} }

View file

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

View file

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