mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-06 08:15:59 +02:00
Embedded string view in watch window, series watch format
This commit is contained in:
parent
c925d7ccc2
commit
1b9e0490f2
13 changed files with 521 additions and 116 deletions
|
@ -192,6 +192,7 @@ struct DwFormatInfo
|
|||
bool mNoVisualizers;
|
||||
bool mNoMembers;
|
||||
bool mRawString;
|
||||
bool mAllowStringView;
|
||||
bool mNoEdit;
|
||||
DbgTypeKindFlags mTypeKindFlags;
|
||||
intptr mArrayLength;
|
||||
|
@ -213,6 +214,7 @@ struct DwFormatInfo
|
|||
mHidePointers = false;
|
||||
mIgnoreDerivedClassInfo = false;
|
||||
mRawString = false;
|
||||
mAllowStringView = false;
|
||||
mNoVisualizers = false;
|
||||
mNoMembers = false;
|
||||
mNoEdit = false;
|
||||
|
|
|
@ -1168,32 +1168,37 @@ BF_EXPORT void BF_CALLTYPE Debugger_Update()
|
|||
gDebugger->Update();
|
||||
}
|
||||
|
||||
BF_EXPORT void BF_CALLTYPE Debugger_SetDisplayTypes(const char* referenceId, int8 intDisplayType, int8 mmDisplayType, int8 floatDisplayType)
|
||||
BF_EXPORT void BF_CALLTYPE Debugger_SetDisplayTypes(const char* referenceId, const char* formatStr, int8 intDisplayType, int8 mmDisplayType, int8 floatDisplayType)
|
||||
{
|
||||
DwDisplayInfo displayInfo;
|
||||
displayInfo.mIntDisplayType = (DwIntDisplayType)intDisplayType;
|
||||
displayInfo.mMmDisplayType = (DwMmDisplayType)mmDisplayType;
|
||||
displayInfo.mFloatDisplayType = (DwFloatDisplayType)floatDisplayType;
|
||||
AutoCrit autoCrit(gDebugManager->mCritSect);
|
||||
|
||||
DwDisplayInfo* displayInfo = NULL;
|
||||
if (referenceId == NULL)
|
||||
{
|
||||
gDebugManager->mDefaultDisplayInfo = displayInfo;
|
||||
}
|
||||
else if ((displayInfo.mIntDisplayType == DwIntDisplayType_Default) &&
|
||||
(displayInfo.mMmDisplayType == DwMmDisplayType_Default) &&
|
||||
(displayInfo.mFloatDisplayType == DwFloatDisplayType_Default))
|
||||
displayInfo = &gDebugManager->mDefaultDisplayInfo;
|
||||
else
|
||||
gDebugManager->mDisplayInfos.TryAdd(referenceId, NULL, &displayInfo);
|
||||
|
||||
if (formatStr != NULL)
|
||||
displayInfo->mFormatStr = formatStr;
|
||||
displayInfo->mIntDisplayType = (DwIntDisplayType)intDisplayType;
|
||||
displayInfo->mMmDisplayType = (DwMmDisplayType)mmDisplayType;
|
||||
displayInfo->mFloatDisplayType = (DwFloatDisplayType)floatDisplayType;
|
||||
|
||||
if ((referenceId != NULL) &&
|
||||
(displayInfo->mFormatStr.IsEmpty()) &&
|
||||
(displayInfo->mIntDisplayType == DwIntDisplayType_Default) &&
|
||||
(displayInfo->mMmDisplayType == DwMmDisplayType_Default) &&
|
||||
(displayInfo->mFloatDisplayType == DwFloatDisplayType_Default))
|
||||
{
|
||||
gDebugManager->mDisplayInfos.Remove(referenceId);
|
||||
}
|
||||
else
|
||||
{
|
||||
gDebugManager->mDisplayInfos[referenceId] = displayInfo;
|
||||
}
|
||||
}
|
||||
|
||||
BF_EXPORT bool BF_CALLTYPE Debugger_GetDisplayTypes(const char* referenceId, int8* intDisplayType, int8* mmDisplayType, int8* floatDisplayType)
|
||||
BF_EXPORT const char* BF_CALLTYPE Debugger_GetDisplayTypes(const char* referenceId, int8* intDisplayType, int8* mmDisplayType, int8* floatDisplayType, bool* foundSpecific)
|
||||
{
|
||||
bool foundSpecific = false;
|
||||
AutoCrit autoCrit(gDebugManager->mCritSect);
|
||||
|
||||
*foundSpecific = false;
|
||||
DwDisplayInfo* displayInfo = &gDebugManager->mDefaultDisplayInfo;
|
||||
if (referenceId != NULL)
|
||||
{
|
||||
|
@ -1206,18 +1211,20 @@ BF_EXPORT bool BF_CALLTYPE Debugger_GetDisplayTypes(const char* referenceId, int
|
|||
|
||||
if (gDebugManager->mDisplayInfos.TryGetValue(referenceId, &displayInfo))
|
||||
{
|
||||
foundSpecific = true;
|
||||
*foundSpecific = true;
|
||||
}
|
||||
}
|
||||
|
||||
*intDisplayType = (int8)displayInfo->mIntDisplayType;
|
||||
*mmDisplayType = (int8)displayInfo->mMmDisplayType;
|
||||
*floatDisplayType = (int8)displayInfo->mFloatDisplayType;
|
||||
return foundSpecific;
|
||||
return displayInfo->mFormatStr.c_str();
|
||||
}
|
||||
|
||||
BF_EXPORT const char* BF_CALLTYPE Debugger_GetDisplayTypeNames()
|
||||
{
|
||||
AutoCrit autoCrit(gDebugManager->mCritSect);
|
||||
|
||||
String& outString = *gTLStrReturn.Get();
|
||||
outString.clear();
|
||||
for (auto& displayInfoEntry : gDebugManager->mDisplayInfos)
|
||||
|
|
|
@ -127,11 +127,13 @@ enum DwEvalExpressionFlags : int16
|
|||
DwEvalExpressionFlag_MemoryWatch = 0x80,
|
||||
DwEvalExpressionFlag_Symbol = 0x100,
|
||||
DwEvalExpressionFlag_StepIntoCalls = 0x200,
|
||||
DwEvalExpressionFlag_RawStr = 0x400
|
||||
DwEvalExpressionFlag_RawStr = 0x400,
|
||||
DwEvalExpressionFlag_AllowStringView = 0x800
|
||||
};
|
||||
|
||||
struct DwDisplayInfo
|
||||
{
|
||||
String mFormatStr;
|
||||
DwIntDisplayType mIntDisplayType;
|
||||
DwMmDisplayType mMmDisplayType;
|
||||
DwFloatDisplayType mFloatDisplayType;
|
||||
|
|
|
@ -2711,7 +2711,7 @@ bool WinDebugger::DoUpdate()
|
|||
|
||||
DwFormatInfo formatInfo;
|
||||
formatInfo.mRawString = true;
|
||||
String nameStr = ReadString(DbgType_SChar, (intptr)threadNameInfo->szName, false, 1024, formatInfo);
|
||||
String nameStr = ReadString(DbgType_SChar, (intptr)threadNameInfo->szName, false, 1024, formatInfo, false);
|
||||
|
||||
WdThreadInfo* namingThreadInfo = threadInfo;
|
||||
if (threadNameInfo->dwThreadID != (DWORD)-1)
|
||||
|
@ -2739,7 +2739,7 @@ bool WinDebugger::DoUpdate()
|
|||
|
||||
FailMessage failMessage = ReadMemory<FailMessage>(exceptionRecord->ExceptionInformation[2]);
|
||||
DwFormatInfo formatInfo;
|
||||
String failStr = ReadString(DbgType_SChar16, failMessage.mErrorStr, false, 8192, formatInfo);
|
||||
String failStr = ReadString(DbgType_SChar16, failMessage.mErrorStr, false, 8192, formatInfo, false);
|
||||
|
||||
mDebugManager->mOutMessages.push_back(StrFormat("error Run-Time Check Failure %d - %s", exceptionRecord->ExceptionInformation[6], failStr.c_str()));
|
||||
mRunState = RunState_Paused;
|
||||
|
@ -6283,7 +6283,15 @@ DwDisplayInfo* WinDebugger::GetDisplayInfo(const StringImpl& referenceId)
|
|||
DwDisplayInfo* displayInfo = &mDebugManager->mDefaultDisplayInfo;
|
||||
if (!referenceId.empty())
|
||||
{
|
||||
mDebugManager->mDisplayInfos.TryGetValue(referenceId, &displayInfo);
|
||||
if (!mDebugManager->mDisplayInfos.TryGetValue(referenceId, &displayInfo))
|
||||
{
|
||||
int dollarIdx = referenceId.LastIndexOf('$');
|
||||
if ((dollarIdx > 0) && (referenceId[dollarIdx - 1] == ']'))
|
||||
{
|
||||
// Try getting series displayinfo
|
||||
mDebugManager->mDisplayInfos.TryGetValueWith(StringView(referenceId, 0, dollarIdx), &displayInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return displayInfo;
|
||||
}
|
||||
|
@ -6351,7 +6359,7 @@ DebugVisualizerEntry* WinDebugger::FindVisualizerForType(DbgType* dbgType, Array
|
|||
|
||||
#define GET_FROM(ptr, T) *((T*)(ptr += sizeof(T)) - 1)
|
||||
|
||||
String WinDebugger::ReadString(DbgTypeCode charType, intptr addr, bool isLocalAddr, intptr maxLength, DwFormatInfo& formatInfo)
|
||||
String WinDebugger::ReadString(DbgTypeCode charType, intptr addr, bool isLocalAddr, intptr maxLength, DwFormatInfo& formatInfo, bool wantStringView)
|
||||
{
|
||||
int origMaxLength = maxLength;
|
||||
if (addr == 0)
|
||||
|
@ -6364,6 +6372,11 @@ String WinDebugger::ReadString(DbgTypeCode charType, intptr addr, bool isLocalAd
|
|||
String valString;
|
||||
intptr maxShowSize = 255;
|
||||
|
||||
if (wantStringView)
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
if (maxLength == -1)
|
||||
maxLength = formatInfo.mOverrideCount;
|
||||
else if (formatInfo.mOverrideCount != -1)
|
||||
|
@ -6373,9 +6386,15 @@ String WinDebugger::ReadString(DbgTypeCode charType, intptr addr, bool isLocalAd
|
|||
|
||||
if (maxLength == -1)
|
||||
maxLength = 8 * 1024 * 1024; // Is 8MB crazy?
|
||||
if (!formatInfo.mRawString)
|
||||
if ((!formatInfo.mRawString) && (!wantStringView))
|
||||
maxLength = BF_MIN(maxLength, maxShowSize);
|
||||
|
||||
if (wantStringView)
|
||||
{
|
||||
// Limit the original string view to 1MB, reevaluate on "More"
|
||||
maxLength = BF_MIN(maxLength, 1024 * 1024);
|
||||
}
|
||||
|
||||
//EnableMemCache();
|
||||
bool readFailed = false;
|
||||
intptr strPtr = addr;
|
||||
|
@ -6494,7 +6513,7 @@ String WinDebugger::ReadString(DbgTypeCode charType, intptr addr, bool isLocalAd
|
|||
// valString = UTF8Encode(ToWString(valString));
|
||||
// }
|
||||
|
||||
if (formatInfo.mRawString)
|
||||
if ((formatInfo.mRawString) || (wantStringView))
|
||||
{
|
||||
if ((formatInfo.mDisplayType == DwDisplayType_Utf8) || (!hasHighAscii))
|
||||
return valString;
|
||||
|
@ -6520,7 +6539,7 @@ String WinDebugger::ReadString(DbgTypeCode charType, intptr addr, bool isLocalAd
|
|||
retVal += SlashString(valString, true, true, formatInfo.mLanguage == DbgLanguage_Beef);
|
||||
|
||||
// We could go over 'maxShowSize' if we have a lot of slashed chars. An uninitialized string can be filled with '\xcc' chars
|
||||
if ((!formatInfo.mRawString) && ((int)retVal.length() > maxShowSize))
|
||||
if ((!formatInfo.mRawString) && (!wantStringView) && ((int)retVal.length() > maxShowSize))
|
||||
{
|
||||
retVal = retVal.Substring(0, maxShowSize);
|
||||
wasTerminated = false;
|
||||
|
@ -6640,8 +6659,10 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
|
|||
bool isEnum = false;
|
||||
int64 enumVal = 0;
|
||||
String result;
|
||||
String stringViewData;
|
||||
|
||||
DwDisplayInfo* displayInfo = GetDisplayInfo(formatInfo.mReferenceId);
|
||||
bool wantStringView = (displayInfo->mFormatStr == "str") && (formatInfo.mAllowStringView);
|
||||
|
||||
DbgType* origValueType = typedValue.mType;
|
||||
bool origHadRef = false;
|
||||
|
@ -7232,16 +7253,23 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
|
|||
}
|
||||
|
||||
SetAndRestoreValue<intptr> prevOverrideLen(formatInfo.mOverrideCount, strLen);
|
||||
String strResult = ReadString(unmodInnerType->mTypeCode, typedValue.mLocalIntPtr, typedValue.mIsLiteral, strLen, formatInfo);
|
||||
String strResult = ReadString(unmodInnerType->mTypeCode, typedValue.mLocalIntPtr, typedValue.mIsLiteral, strLen, formatInfo, wantStringView);
|
||||
if (formatInfo.mRawString)
|
||||
return strResult;
|
||||
if (!strResult.IsEmpty())
|
||||
{
|
||||
if (!retVal.IsEmpty())
|
||||
retVal += " ";
|
||||
retVal += strResult;
|
||||
if (!wantStringView)
|
||||
retVal += strResult;
|
||||
}
|
||||
retVal += "\n" + origValueType->ToString(language);
|
||||
retVal += "\n:stringView";
|
||||
if (wantStringView)
|
||||
{
|
||||
retVal += "\t";
|
||||
retVal += SlashString(strResult, false, false, true);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
else if ((unmodInnerType != NULL) &&
|
||||
|
@ -7436,7 +7464,7 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
|
|||
|
||||
if (innerType->IsChar(language))
|
||||
{
|
||||
String strVal = ReadString(innerType->mTypeCode, typedValue.mSrcAddress, false, arraySize, formatInfo);
|
||||
String strVal = ReadString(innerType->mTypeCode, typedValue.mSrcAddress, false, arraySize, formatInfo, false);
|
||||
if (formatInfo.mRawString)
|
||||
return strVal;
|
||||
retVal += strVal;
|
||||
|
@ -7927,7 +7955,7 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
|
|||
bool hadCustomDisplayString = false;
|
||||
if (debugVis != NULL)
|
||||
{
|
||||
auto& displayStringList = formatInfo.mRawString ? debugVis->mStringViews : debugVis->mDisplayStrings;
|
||||
auto& displayStringList = (formatInfo.mRawString || wantStringView) ? debugVis->mStringViews : debugVis->mDisplayStrings;
|
||||
|
||||
for (auto displayEntry : displayStringList)
|
||||
{
|
||||
|
@ -7941,7 +7969,15 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
|
|||
String displayStr = mDebugManager->mDebugVisualizers->DoStringReplace(displayEntry->mString, dbgVisWildcardCaptures);
|
||||
if (displayString.length() > 0)
|
||||
displayString += " ";
|
||||
ProcessEvalString(dbgCompileUnit, useTypedValue, displayStr, displayString, formatInfo, debugVis, true);
|
||||
|
||||
if (wantStringView)
|
||||
{
|
||||
DwFormatInfo strFormatInfo = formatInfo;
|
||||
strFormatInfo.mRawString = true;
|
||||
ProcessEvalString(dbgCompileUnit, useTypedValue, displayStr, stringViewData, strFormatInfo, debugVis, true);
|
||||
}
|
||||
else
|
||||
ProcessEvalString(dbgCompileUnit, useTypedValue, displayStr, displayString, formatInfo, debugVis, true);
|
||||
if (formatInfo.mRawString)
|
||||
return displayString;
|
||||
|
||||
|
@ -8309,8 +8345,7 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
|
|||
}
|
||||
|
||||
if (formatInfo.mExpandItemDepth > 0)
|
||||
return retVal;
|
||||
|
||||
return retVal;
|
||||
if (isAppendBfObject)
|
||||
retVal += "\n:appendAlloc";
|
||||
if (isStackBfObject)
|
||||
|
@ -8331,6 +8366,15 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
|
|||
retVal += "\n:editVal\t" + EncodeDataPtr(ptrVal, true);
|
||||
}
|
||||
|
||||
if (((debugVis != NULL) && (!debugVis->mStringViews.IsEmpty())) || (wantStringView))
|
||||
retVal += "\n:stringView";
|
||||
|
||||
if (wantStringView)
|
||||
{
|
||||
retVal += "\t";
|
||||
retVal += SlashString(stringViewData, false, false, true);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
@ -8512,7 +8556,7 @@ void WinDebugger::HandleCustomExpandedItems(String& retVal, DbgCompileUnit* dbgC
|
|||
else
|
||||
{
|
||||
String evalStr = "*(" + debugVisualizers->DoStringReplace(debugVis->mValuePointer, dbgVisWildcardCaptures) + " + {0}), this=" + ptrUseDataStr;
|
||||
evalStr += ", refid=\"" + referenceId + ".[]\"";
|
||||
evalStr += ", refid=\"" + referenceId + ".[]${0}\"";
|
||||
if (isReadOnly)
|
||||
evalStr += ", ne";
|
||||
retVal += "\n:repeat" + StrFormat("\t%d\t%lld\t%d", 0, sizeValue.GetInt64(), 50000) +
|
||||
|
@ -9576,6 +9620,11 @@ String WinDebugger::Evaluate(const StringImpl& expr, DwFormatInfo formatInfo, in
|
|||
formatInfo.mRawString = true;
|
||||
}
|
||||
|
||||
if ((expressionFlags & DwEvalExpressionFlag_AllowStringView) != 0)
|
||||
{
|
||||
formatInfo.mAllowStringView = true;
|
||||
}
|
||||
|
||||
auto dbgModule = GetCallStackDbgModule(callStackIdx);
|
||||
auto dbgSubprogram = GetCallStackSubprogram(callStackIdx);
|
||||
DbgCompileUnit* dbgCompileUnit = NULL;
|
||||
|
|
|
@ -502,7 +502,7 @@ public:
|
|||
bool EvalCondition(DebugVisualizerEntry* debugVis, DbgCompileUnit* dbgCompileUnit, DbgTypedValue typedVal, DwFormatInfo& formatInfo, const StringImpl& condition, const Array<String>& dbgVisWildcardCaptures, String& errorStr);
|
||||
DwDisplayInfo* GetDisplayInfo(const StringImpl& referenceId);
|
||||
void ProcessEvalString(DbgCompileUnit* dbgCompileUnit, DbgTypedValue useTypedValue, String& evalStr, String& displayString, DwFormatInfo& formatInfo, DebugVisualizerEntry* debugVis, bool limitLength);
|
||||
String ReadString(DbgTypeCode charType, intptr addr, bool isLocalAddr, intptr maxLength, DwFormatInfo& formatInfo);
|
||||
String ReadString(DbgTypeCode charType, intptr addr, bool isLocalAddr, intptr maxLength, DwFormatInfo& formatInfo, bool wantStringView);
|
||||
String DbgTypedValueToString(const DbgTypedValue& typedValue, const StringImpl& expr, DwFormatInfo& formatFlags, DbgExprEvaluator* optEvaluator, bool fullPrecision = false);
|
||||
bool ShouldShowStaticMember(DbgType* dbgType, DbgVariable* member);
|
||||
String GetMemberList(DbgType* dbgType, const StringImpl& expr, bool isPtr, bool isStatic, bool forceCast = false, bool isSplat = false, bool isReadOnly = false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue