1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +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

@ -37,6 +37,15 @@ namespace IDE.Debugger
COUNT
}
public enum FloatDisplayType
{
Default,
Minimal,
Full,
Hexadecimal,
COUNT
}
public enum StringDisplayType
{
Default,
@ -190,10 +199,10 @@ namespace IDE.Debugger
static extern void* Debugger_CreateStepFilter(char8* filter, bool isGlobal, StepFilterKind stepFilterKind);
[CallingConvention(.Stdcall),CLink]
static extern void Debugger_SetDisplayTypes(char8* referenceId, IntDisplayType intDisplayType, MmDisplayType mmDisplayType);
static extern void Debugger_SetDisplayTypes(char8* referenceId, IntDisplayType intDisplayType, MmDisplayType mmDisplayType, FloatDisplayType floatDisplayType);
[CallingConvention(.Stdcall),CLink]
static extern bool Debugger_GetDisplayTypes(char8* referenceId, out IntDisplayType intDisplayType, out MmDisplayType mmDisplayType);
static extern bool Debugger_GetDisplayTypes(char8* referenceId, out IntDisplayType intDisplayType, out MmDisplayType mmDisplayType, out FloatDisplayType floatDisplayType);
[CallingConvention(.Stdcall),CLink]
static extern char8* Debugger_GetDisplayTypeNames();
@ -1033,14 +1042,14 @@ namespace IDE.Debugger
Debugger_WriteMemory(addr, size, data.CArray());
}
public void SetDisplayTypes(String referenceId, IntDisplayType intDisplayType, MmDisplayType mmDisplayType)
public void SetDisplayTypes(String referenceId, IntDisplayType intDisplayType, MmDisplayType mmDisplayType, FloatDisplayType floatDisplayType)
{
Debugger_SetDisplayTypes(referenceId, intDisplayType, mmDisplayType);
Debugger_SetDisplayTypes(referenceId, intDisplayType, mmDisplayType, floatDisplayType);
}
public bool GetDisplayTypes(String referenceId, out IntDisplayType intDisplayType, out MmDisplayType mmDisplayType)
public bool GetDisplayTypes(String referenceId, out IntDisplayType intDisplayType, out MmDisplayType mmDisplayType, out FloatDisplayType floatDisplayType)
{
return Debugger_GetDisplayTypes(referenceId, out intDisplayType, out mmDisplayType);
return Debugger_GetDisplayTypes(referenceId, out intDisplayType, out mmDisplayType, out floatDisplayType);
}
public void GetDisplayTypeNames(String outDisplayTypeNames)

View file

@ -1770,11 +1770,13 @@ namespace IDE
{
DebugManager.IntDisplayType intDisplayType;
DebugManager.MmDisplayType mmDisplayType;
mDebugger.GetDisplayTypes(referenceId, out intDisplayType, out mmDisplayType);
DebugManager.FloatDisplayType floatDisplayType;
mDebugger.GetDisplayTypes(referenceId, out intDisplayType, out mmDisplayType, out floatDisplayType);
using (sd.CreateObject(referenceId))
{
sd.Add("IntDisplayType", intDisplayType);
sd.Add("MmDisplayType", mmDisplayType);
sd.ConditionalAdd("IntDisplayType", intDisplayType);
sd.ConditionalAdd("MmDisplayType", mmDisplayType);
sd.ConditionalAdd("FloatDisplayType", floatDisplayType);
}
}
}
@ -2948,7 +2950,8 @@ namespace IDE
var intDisplayType = data.GetEnum<DebugManager.IntDisplayType>("IntDisplayType");
var mmDisplayType = data.GetEnum<DebugManager.MmDisplayType>("MmDisplayType");
mDebugger.SetDisplayTypes(referenceIdStr, intDisplayType, mmDisplayType);
var floatDisplayType = data.GetEnum<DebugManager.FloatDisplayType>("FloatDisplayType");
mDebugger.SetDisplayTypes(referenceIdStr, intDisplayType, mmDisplayType, floatDisplayType);
}
for (data.Enumerate("StepFilters"))
@ -5757,7 +5760,7 @@ namespace IDE
String outKey;
FileEditData editData;
if (mFileEditData.TryGetValue(oldFixedFilePath, out outKey, out editData))
if (mFileEditData.TryGet(oldFixedFilePath, out outKey, out editData))
{
mFileEditData.Remove(oldFixedFilePath);
delete outKey;
@ -7023,7 +7026,7 @@ namespace IDE
KeyState matchedKey;
IDECommandBase commandBase;
if (curKeyMap.mMap.TryGetValue(keyState, out matchedKey, out commandBase))
if (curKeyMap.mMap.TryGet(keyState, out matchedKey, out commandBase))
{
if (var commandMap = commandBase as CommandMap)
{

View file

@ -19,13 +19,14 @@ namespace IDE.ui
None = 0,
Value = 1,
Int = 2,
MM128 = 4,
Object = 8,
Pointer = 0x10,
TypeClass = 0x20,
TypeValueType = 0x40,
Namespace = 0x80,
Text = 0x100
Float = 4,
MM128 = 8,
Object = 0x10,
Pointer = 0x20,
TypeClass = 0x40,
TypeValueType = 0x80,
Namespace = 0x100,
Text = 0x200
}
public class WatchEntry
@ -70,41 +71,44 @@ namespace IDE.ui
{
switch (scope String(cmd[0]))
{
case ":type":
switch (scope String(cmd[1]))
{
case "object":
mResultType |= WatchResultType.Object;
return true;
case "pointer":
mResultType |= WatchResultType.Pointer;
return true;
case "class":
mResultType |= WatchResultType.TypeClass;
return true;
case "valuetype":
mResultType |= WatchResultType.TypeValueType;
return true;
case "namespace":
mResultType |= WatchResultType.Namespace;
return true;
case "int":
mResultType |= WatchResultType.Int;
return true;
case "mm128":
mResultType |= WatchResultType.MM128;
return true;
}
break;
case ":appendAlloc":
mIsAppendAlloc = true;
case ":type":
switch (scope String(cmd[1]))
{
case "object":
mResultType |= WatchResultType.Object;
return true;
case ":stack":
mIsStackAlloc = true;
case "pointer":
mResultType |= WatchResultType.Pointer;
return true;
case ":deleted":
mIsDeleted = true;
case "class":
mResultType |= WatchResultType.TypeClass;
return true;
case "valuetype":
mResultType |= WatchResultType.TypeValueType;
return true;
case "namespace":
mResultType |= WatchResultType.Namespace;
return true;
case "int":
mResultType |= WatchResultType.Int;
return true;
case "float":
mResultType |= WatchResultType.Float;
return true;
case "mm128":
mResultType |= WatchResultType.MM128;
return true;
}
break;
case ":appendAlloc":
mIsAppendAlloc = true;
return true;
case ":stack":
mIsStackAlloc = true;
return true;
case ":deleted":
mIsDeleted = true;
return true;
}
return false;
@ -2626,34 +2630,32 @@ namespace IDE.ui
menuItem.mOnMenuItemSelected.Add(new (imenu) => action() ~ { delete action; });
}
public static void SetDisplayType(String referenceId, DebugManager.IntDisplayType intDisplayType, DebugManager.MmDisplayType mmDisplayType)
public static void SetDisplayType(String referenceId, DebugManager.IntDisplayType intDisplayType, DebugManager.MmDisplayType mmDisplayType, DebugManager.FloatDisplayType floatDisplayType)
{
var debugger = IDEApp.sApp.mDebugger;
debugger.SetDisplayTypes(referenceId, intDisplayType, mmDisplayType);
IDEApp.sApp.RefreshWatches();
gApp.mDebugger.SetDisplayTypes(referenceId, intDisplayType, mmDisplayType, floatDisplayType);
gApp.RefreshWatches();
}
public static bool AddDisplayTypeMenu(String label, Menu menu, WatchResultType watchResultType, String referenceId, bool includeDefault)
{
bool hasInt = watchResultType.HasFlag(WatchResultType.Int);
bool hasFloat = watchResultType.HasFlag(WatchResultType.Float);
bool hasMM128 = watchResultType.HasFlag(WatchResultType.MM128);
bool canSetFormat = hasInt || hasMM128;
bool canSetFormat = hasInt || hasFloat || hasMM128;
var debugger = IDEApp.sApp.mDebugger;
DebugManager.IntDisplayType intDisplayType;
DebugManager.MmDisplayType mmDisplayType;
bool foundSpecific = debugger.GetDisplayTypes(referenceId, out intDisplayType, out mmDisplayType);
bool foundSpecific = debugger.GetDisplayTypes(referenceId, var intDisplayType, var mmDisplayType, var floatDisplayType);
if ((referenceId != null) && (!foundSpecific))
{
intDisplayType = DebugManager.IntDisplayType.Default;
mmDisplayType = DebugManager.MmDisplayType.Default;
intDisplayType = .Default;
mmDisplayType = .Default;
floatDisplayType = .Default;
}
if (!canSetFormat)
return false;
Menu parentItem = menu.AddItem(label);
//anItem.mIconImage = DarkTheme.sDarkTheme.GetImage(DarkTheme.ImageIdx.Check);
if (hasInt)
{
for (DebugManager.IntDisplayType i = default; i < DebugManager.IntDisplayType.COUNT; i++)
@ -2667,17 +2669,34 @@ namespace IDE.ui
var toType = i;
AddSelectableMenuItem(parentItem, ToStackString!(i), intDisplayType == i,
new () => SetDisplayType(referenceId, toType, mmDisplayType));
new () => SetDisplayType(referenceId, toType, mmDisplayType, floatDisplayType));
}
}
if (hasFloat)
{
for (DebugManager.FloatDisplayType i = default; i < DebugManager.FloatDisplayType.COUNT; i++)
{
if ((i == 0) && (!includeDefault))
{
if (floatDisplayType == 0)
floatDisplayType = DebugManager.FloatDisplayType.Minimal;
continue;
}
var toType = i;
AddSelectableMenuItem(parentItem, ToStackString!(i), floatDisplayType == i,
new () => SetDisplayType(referenceId, intDisplayType, mmDisplayType, toType));
}
}
if (hasMM128)
{
for (DebugManager.MmDisplayType i = default; i < DebugManager.MmDisplayType.COUNT; i++)
{
var toType = i;
AddSelectableMenuItem(parentItem, ToStackString!(i), mmDisplayType == i,
new () => SetDisplayType(referenceId, intDisplayType, toType));
new () => SetDisplayType(referenceId, intDisplayType, toType, floatDisplayType));
}
}
return true;

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

@ -6964,12 +6964,34 @@ 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