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 COUNT
} }
public enum FloatDisplayType
{
Default,
Minimal,
Full,
Hexadecimal,
COUNT
}
public enum StringDisplayType public enum StringDisplayType
{ {
Default, Default,
@ -190,10 +199,10 @@ namespace IDE.Debugger
static extern void* Debugger_CreateStepFilter(char8* filter, bool isGlobal, StepFilterKind stepFilterKind); static extern void* Debugger_CreateStepFilter(char8* filter, bool isGlobal, StepFilterKind stepFilterKind);
[CallingConvention(.Stdcall),CLink] [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] [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] [CallingConvention(.Stdcall),CLink]
static extern char8* Debugger_GetDisplayTypeNames(); static extern char8* Debugger_GetDisplayTypeNames();
@ -1033,14 +1042,14 @@ namespace IDE.Debugger
Debugger_WriteMemory(addr, size, data.CArray()); 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) public void GetDisplayTypeNames(String outDisplayTypeNames)

View file

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

View file

@ -19,13 +19,14 @@ namespace IDE.ui
None = 0, None = 0,
Value = 1, Value = 1,
Int = 2, Int = 2,
MM128 = 4, Float = 4,
Object = 8, MM128 = 8,
Pointer = 0x10, Object = 0x10,
TypeClass = 0x20, Pointer = 0x20,
TypeValueType = 0x40, TypeClass = 0x40,
Namespace = 0x80, TypeValueType = 0x80,
Text = 0x100 Namespace = 0x100,
Text = 0x200
} }
public class WatchEntry public class WatchEntry
@ -91,6 +92,9 @@ namespace IDE.ui
case "int": case "int":
mResultType |= WatchResultType.Int; mResultType |= WatchResultType.Int;
return true; return true;
case "float":
mResultType |= WatchResultType.Float;
return true;
case "mm128": case "mm128":
mResultType |= WatchResultType.MM128; mResultType |= WatchResultType.MM128;
return true; return true;
@ -2626,34 +2630,32 @@ namespace IDE.ui
menuItem.mOnMenuItemSelected.Add(new (imenu) => action() ~ { delete action; }); 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; gApp.mDebugger.SetDisplayTypes(referenceId, intDisplayType, mmDisplayType, floatDisplayType);
debugger.SetDisplayTypes(referenceId, intDisplayType, mmDisplayType); gApp.RefreshWatches();
IDEApp.sApp.RefreshWatches();
} }
public static bool AddDisplayTypeMenu(String label, Menu menu, WatchResultType watchResultType, String referenceId, bool includeDefault) public static bool AddDisplayTypeMenu(String label, Menu menu, WatchResultType watchResultType, String referenceId, bool includeDefault)
{ {
bool hasInt = watchResultType.HasFlag(WatchResultType.Int); bool hasInt = watchResultType.HasFlag(WatchResultType.Int);
bool hasFloat = watchResultType.HasFlag(WatchResultType.Float);
bool hasMM128 = watchResultType.HasFlag(WatchResultType.MM128); bool hasMM128 = watchResultType.HasFlag(WatchResultType.MM128);
bool canSetFormat = hasInt || hasMM128; bool canSetFormat = hasInt || hasFloat || hasMM128;
var debugger = IDEApp.sApp.mDebugger; var debugger = IDEApp.sApp.mDebugger;
DebugManager.IntDisplayType intDisplayType; bool foundSpecific = debugger.GetDisplayTypes(referenceId, var intDisplayType, var mmDisplayType, var floatDisplayType);
DebugManager.MmDisplayType mmDisplayType;
bool foundSpecific = debugger.GetDisplayTypes(referenceId, out intDisplayType, out mmDisplayType);
if ((referenceId != null) && (!foundSpecific)) if ((referenceId != null) && (!foundSpecific))
{ {
intDisplayType = DebugManager.IntDisplayType.Default; intDisplayType = .Default;
mmDisplayType = DebugManager.MmDisplayType.Default; mmDisplayType = .Default;
floatDisplayType = .Default;
} }
if (!canSetFormat) if (!canSetFormat)
return false; return false;
Menu parentItem = menu.AddItem(label); Menu parentItem = menu.AddItem(label);
//anItem.mIconImage = DarkTheme.sDarkTheme.GetImage(DarkTheme.ImageIdx.Check);
if (hasInt) if (hasInt)
{ {
for (DebugManager.IntDisplayType i = default; i < DebugManager.IntDisplayType.COUNT; i++) for (DebugManager.IntDisplayType i = default; i < DebugManager.IntDisplayType.COUNT; i++)
@ -2667,7 +2669,24 @@ namespace IDE.ui
var toType = i; var toType = i;
AddSelectableMenuItem(parentItem, ToStackString!(i), intDisplayType == 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));
} }
} }
@ -2677,7 +2696,7 @@ namespace IDE.ui
{ {
var toType = i; var toType = i;
AddSelectableMenuItem(parentItem, ToStackString!(i), mmDisplayType == i, AddSelectableMenuItem(parentItem, ToStackString!(i), mmDisplayType == i,
new () => SetDisplayType(referenceId, intDisplayType, toType)); new () => SetDisplayType(referenceId, intDisplayType, toType, floatDisplayType));
} }
} }
return true; return true;

View file

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

View file

@ -1147,22 +1147,21 @@ BF_EXPORT void BF_CALLTYPE Debugger_Update()
gDebugger->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; DwDisplayInfo displayInfo;
displayInfo.mIntDisplayType = (DwIntDisplayType)intDisplayType; displayInfo.mIntDisplayType = (DwIntDisplayType)intDisplayType;
displayInfo.mMmDisplayType = (DwMmDisplayType)mmDisplayType; displayInfo.mMmDisplayType = (DwMmDisplayType)mmDisplayType;
displayInfo.mFloatDisplayType = (DwFloatDisplayType)floatDisplayType;
if (referenceId == NULL) if (referenceId == NULL)
{ {
gDebugManager->mDefaultDisplayInfo = displayInfo; gDebugManager->mDefaultDisplayInfo = displayInfo;
} }
else if ((displayInfo.mIntDisplayType == DwIntDisplayType_Default) && 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); gDebugManager->mDisplayInfos.Remove(referenceId);
} }
else 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; bool foundSpecific = false;
DwDisplayInfo* displayInfo = &gDebugManager->mDefaultDisplayInfo; DwDisplayInfo* displayInfo = &gDebugManager->mDefaultDisplayInfo;
@ -1190,8 +1189,9 @@ BF_EXPORT bool BF_CALLTYPE Debugger_GetDisplayTypes(const char* referenceId, int
} }
} }
*intDisplayType = (int)displayInfo->mIntDisplayType; *intDisplayType = (int8)displayInfo->mIntDisplayType;
*mmDisplayType = (int)displayInfo->mMmDisplayType; *mmDisplayType = (int8)displayInfo->mMmDisplayType;
*floatDisplayType = (int8)displayInfo->mFloatDisplayType;
return foundSpecific; return foundSpecific;
} }

View file

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

View file

@ -6964,12 +6964,34 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c
break; break;
case DbgType_Single: case DbgType_Single:
{ {
DwFloatDisplayType floatDisplayType = displayInfo->mFloatDisplayType;
if (floatDisplayType == DwFloatDisplayType_Default)
floatDisplayType = DwFloatDisplayType_Minimal;
if (floatDisplayType == DwFloatDisplayType_Minimal)
ExactMinimalFloatToStr(typedValue.mSingle, str); 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()); return StrFormat("%s\n%s", str, WrapWithModifiers("float", origValueType, language).c_str());
} }
case DbgType_Double: case DbgType_Double:
{
DwFloatDisplayType floatDisplayType = displayInfo->mFloatDisplayType;
if (floatDisplayType == DwFloatDisplayType_Default)
floatDisplayType = DwFloatDisplayType_Minimal;
if (floatDisplayType == DwFloatDisplayType_Minimal)
ExactMinimalDoubleToStr(typedValue.mDouble, str); 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()); return StrFormat("%s\n%s", str, WrapWithModifiers("double", origValueType, language).c_str());
}
case DbgType_Subroutine: case DbgType_Subroutine:
if (typedValue.mCharPtr != NULL) if (typedValue.mCharPtr != NULL)
return StrFormat("%s\nfunc", typedValue.mCharPtr); return StrFormat("%s\nfunc", typedValue.mCharPtr);
@ -9170,6 +9192,8 @@ String WinDebugger::EvaluateContinue(DbgPendingExpr* pendingExpr, BfPassInstance
val += "\n:type\tpointer"; val += "\n:type\tpointer";
else if (checkType->IsInteger()) else if (checkType->IsInteger())
val += "\n:type\tint"; val += "\n:type\tint";
else if (checkType->IsFloat())
val += "\n:type\tfloat";
else if ((exprResult.mRegNum >= X64Reg_M128_XMM0) && (exprResult.mRegNum <= X64Reg_M128_XMM15)) else if ((exprResult.mRegNum >= X64Reg_M128_XMM0) && (exprResult.mRegNum <= X64Reg_M128_XMM15))
val += "\n:type\tmm128"; val += "\n:type\tmm128";
else else