1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-22 09:38:01 +02:00

Added float format flags

This commit is contained in:
Brian Fiete 2020-06-19 06:42:52 -07:00
parent 82a108714d
commit 271d88f261
7 changed files with 146 additions and 79 deletions

View file

@ -39,7 +39,7 @@ public:
int32 mInt32;
uint32 mUInt32;
int64 mInt64;
int64 mUInt64;
uint64 mUInt64;
float mSingle;
double mDouble;
const char* mCharPtr;

View file

@ -1147,22 +1147,21 @@ BF_EXPORT void BF_CALLTYPE Debugger_Update()
gDebugger->Update();
}
BF_EXPORT void BF_CALLTYPE Debugger_SetDisplayTypes(const char* referenceId, int8 intDisplayType, int8 mmDisplayType)
BF_EXPORT void BF_CALLTYPE Debugger_SetDisplayTypes(const char* referenceId, int8 intDisplayType, int8 mmDisplayType, int8 floatDisplayType)
{
DwDisplayInfo displayInfo;
displayInfo.mIntDisplayType = (DwIntDisplayType)intDisplayType;
displayInfo.mMmDisplayType = (DwMmDisplayType)mmDisplayType;
displayInfo.mFloatDisplayType = (DwFloatDisplayType)floatDisplayType;
if (referenceId == NULL)
{
gDebugManager->mDefaultDisplayInfo = displayInfo;
}
else if ((displayInfo.mIntDisplayType == DwIntDisplayType_Default) &&
(displayInfo.mMmDisplayType == DwMmDisplayType_Default))
(displayInfo.mMmDisplayType == DwMmDisplayType_Default) &&
(displayInfo.mFloatDisplayType == DwFloatDisplayType_Default))
{
/*auto itr = gDebugManager->mDisplayInfos.find(referenceId);
if (itr != gDebugManager->mDisplayInfos.end())
gDebugManager->mDisplayInfos.erase(itr);*/
gDebugManager->mDisplayInfos.Remove(referenceId);
}
else
@ -1171,7 +1170,7 @@ BF_EXPORT void BF_CALLTYPE Debugger_SetDisplayTypes(const char* referenceId, int
}
}
BF_EXPORT bool BF_CALLTYPE Debugger_GetDisplayTypes(const char* referenceId, int8* intDisplayType, int8* mmDisplayType)
BF_EXPORT bool BF_CALLTYPE Debugger_GetDisplayTypes(const char* referenceId, int8* intDisplayType, int8* mmDisplayType, int8* floatDisplayType)
{
bool foundSpecific = false;
DwDisplayInfo* displayInfo = &gDebugManager->mDefaultDisplayInfo;
@ -1190,8 +1189,9 @@ BF_EXPORT bool BF_CALLTYPE Debugger_GetDisplayTypes(const char* referenceId, int
}
}
*intDisplayType = (int)displayInfo->mIntDisplayType;
*mmDisplayType = (int)displayInfo->mMmDisplayType;
*intDisplayType = (int8)displayInfo->mIntDisplayType;
*mmDisplayType = (int8)displayInfo->mMmDisplayType;
*floatDisplayType = (int8)displayInfo->mFloatDisplayType;
return foundSpecific;
}

View file

@ -86,6 +86,16 @@ enum DwIntDisplayType : int8
DwIntDisplayType_HexadecimalLower,
};
enum DwFloatDisplayType : int8
{
DwFloatDisplayType_Default,
DwFloatDisplayType_Minimal,
DwFloatDisplayType_Full,
DwFloatDisplayType_HexUpper,
DwFloatDisplayType_HexLower,
};
enum DwMmDisplayType : int8
{
DwMmDisplayType_Default,
@ -116,11 +126,13 @@ struct DwDisplayInfo
{
DwIntDisplayType mIntDisplayType;
DwMmDisplayType mMmDisplayType;
DwFloatDisplayType mFloatDisplayType;
DwDisplayInfo()
{
mIntDisplayType = DwIntDisplayType_Default;
mMmDisplayType = DwMmDisplayType_Default;
mFloatDisplayType = DwFloatDisplayType_Default;
}
};

View file

@ -6963,13 +6963,35 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
}
break;
case DbgType_Single:
{
ExactMinimalFloatToStr(typedValue.mSingle, str);
{
DwFloatDisplayType floatDisplayType = displayInfo->mFloatDisplayType;
if (floatDisplayType == DwFloatDisplayType_Default)
floatDisplayType = DwFloatDisplayType_Minimal;
if (floatDisplayType == DwFloatDisplayType_Minimal)
ExactMinimalFloatToStr(typedValue.mSingle, str);
else if (floatDisplayType == DwFloatDisplayType_Full)
sprintf(str, "%1.9g", (float)typedValue.mDouble);
else if (floatDisplayType == DwFloatDisplayType_HexUpper)
sprintf(str, "0x%04X", typedValue.mUInt32);
else //if (floatDisplayType == DwFloatDisplayType_HexLower)
sprintf(str, "0x%04x", typedValue.mUInt32);
return StrFormat("%s\n%s", str, WrapWithModifiers("float", origValueType, language).c_str());
}
case DbgType_Double:
ExactMinimalDoubleToStr(typedValue.mDouble, str);
return StrFormat("%s\n%s", str, WrapWithModifiers("double", origValueType, language).c_str());
{
DwFloatDisplayType floatDisplayType = displayInfo->mFloatDisplayType;
if (floatDisplayType == DwFloatDisplayType_Default)
floatDisplayType = DwFloatDisplayType_Minimal;
if (floatDisplayType == DwFloatDisplayType_Minimal)
ExactMinimalDoubleToStr(typedValue.mDouble, str);
else if (floatDisplayType == DwFloatDisplayType_Full)
sprintf(str, "%1.17g", typedValue.mDouble);
else if (floatDisplayType == DwFloatDisplayType_HexUpper)
sprintf(str, "0x%08llX", typedValue.mUInt64);
else //if (floatDisplayType == DwFloatDisplayType_HexLower)
sprintf(str, "0x%08llx", typedValue.mUInt64);
return StrFormat("%s\n%s", str, WrapWithModifiers("double", origValueType, language).c_str());
}
case DbgType_Subroutine:
if (typedValue.mCharPtr != NULL)
return StrFormat("%s\nfunc", typedValue.mCharPtr);
@ -9170,6 +9192,8 @@ String WinDebugger::EvaluateContinue(DbgPendingExpr* pendingExpr, BfPassInstance
val += "\n:type\tpointer";
else if (checkType->IsInteger())
val += "\n:type\tint";
else if (checkType->IsFloat())
val += "\n:type\tfloat";
else if ((exprResult.mRegNum >= X64Reg_M128_XMM0) && (exprResult.mRegNum <= X64Reg_M128_XMM15))
val += "\n:type\tmm128";
else