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:
parent
17be9daade
commit
64f117b89f
10 changed files with 116 additions and 24 deletions
|
@ -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())
|
||||||
|
@ -4178,8 +4237,9 @@ void COFF::FixupInlinee(DbgSubprogram* dbgSubprogram, uint32 ipiTag)
|
||||||
case LF_MFUNC_ID:
|
case LF_MFUNC_ID:
|
||||||
{
|
{
|
||||||
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,24 +5307,40 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isIllegal)
|
if (!isIllegal)
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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) ||
|
||||||
|
|
|
@ -2615,7 +2615,7 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type)
|
||||||
flags |= llvm::DINode::FlagArtificial;
|
flags |= llvm::DINode::FlagArtificial;
|
||||||
}
|
}
|
||||||
|
|
||||||
String methodName = methodDef->mName;
|
String methodName = methodDef->mName;
|
||||||
llvm::SmallVector<BfIRMDNode, 1> genericArgs;
|
llvm::SmallVector<BfIRMDNode, 1> genericArgs;
|
||||||
llvm::SmallVector<BfIRValue, 1> genericConstValueArgs;
|
llvm::SmallVector<BfIRValue, 1> genericConstValueArgs;
|
||||||
auto diFunction = DbgCreateMethod(funcScope, methodName, mangledName, fileDIScope,
|
auto diFunction = DbgCreateMethod(funcScope, methodName, mangledName, fileDIScope,
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -395,8 +395,14 @@ String DbgSubprogram::ToString()
|
||||||
mCompileUnit->mDbgModule->FixupInlinee(this);
|
mCompileUnit->mDbgModule->FixupInlinee(this);
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -992,7 +998,7 @@ bool DbgType::IsStruct()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DbgType::IsPrimitiveType()
|
bool DbgType::IsPrimitiveType()
|
||||||
{
|
{
|
||||||
return (mTypeCode >= DbgType_i8) && (mTypeCode <= DbgType_Bool);
|
return (mTypeCode >= DbgType_i8) && (mTypeCode <= DbgType_Bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue