1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-25 02:58:02 +02:00

Improved debugger side effect handling, auto refresh options

This commit is contained in:
Brian Fiete 2024-12-31 13:17:53 -08:00
parent 7548bf23cd
commit 1484a5f53c
10 changed files with 150 additions and 30 deletions

View file

@ -2977,11 +2977,15 @@ namespace IDE.ui
//insertText = insertText.Substring(0, insertText.Length - 1);
String implText = null;
int tabIdx = insertText.IndexOf('\t');
if (tabIdx != -1)
int splitIdx = tabIdx;
int crIdx = insertText.IndexOf('\r');
if ((crIdx != -1) && (tabIdx != -1) && (crIdx < tabIdx))
splitIdx = crIdx;
if (splitIdx != -1)
{
implText = scope:: String();
implText.Append(insertText, tabIdx);
insertText.RemoveToEnd(tabIdx);
implText.Append(insertText, splitIdx);
insertText.RemoveToEnd(splitIdx);
}
String prevText = scope String();
mTargetEditWidget.Content.ExtractString(editSelection.mStartPos, editSelection.mEndPos - editSelection.mStartPos, prevText);

View file

@ -775,7 +775,7 @@ namespace IDE.ui
flags |= DebugManager.EvalExpressionFlags.DeselectCallStackIdx;
if (mAllowSideEffects)
flags |= .AllowSideEffects | .AllowCalls;
if (gApp.mSettings.mDebuggerSettings.mAutoEvaluateProperties)
if (gApp.mSettings.mDebuggerSettings.mAutoEvaluatePropertiesOnHover)
flags |= .AllowProperties;
if (watch.mResultType == .RawText)
flags |= .RawStr;

View file

@ -347,7 +347,8 @@ namespace IDE.ui
AddPropertiesItem(root, "Symbol File Locations", "mSymbolSearchPath");
AddPropertiesItem(root, "Auto Find Paths", "mAutoFindPaths");
AddPropertiesItem(root, "Profile Sample Rate", "mProfileSampleRate");
AddPropertiesItem(root, "Auto Evaluate Properties", "mAutoEvaluateProperties");
AddPropertiesItem(root, "Auto Eval Properties on Hover", "mAutoEvaluatePropertiesOnHover");
AddPropertiesItem(root, "Auto Refresh Side Effects", "mAutoRefreshWatches");
}
protected override void ResetSettings()

View file

@ -54,6 +54,8 @@ namespace IDE.ui
public bool mIsNewExpression;
public bool mIsPending;
public bool mUsedLock;
public bool? mAutoRefresh;
public int32 mDebuggerStateIdx;
public int32 mCurStackIdx;
public int mMemoryBreakpointAddr;
public int32 mHadStepCount;
@ -66,6 +68,24 @@ namespace IDE.ui
public int32 mSeriesFirstVersion = -1;
public int32 mSeriesVersion = -1;
public bool AutoRefresh
{
get
{
if (mAutoRefresh != null)
return mAutoRefresh.Value;
return gApp.mSettings.mDebuggerSettings.mAutoRefreshWatches;
}
set
{
if (value == gApp.mSettings.mDebuggerSettings.mAutoRefreshWatches)
mAutoRefresh = null;
else
mAutoRefresh = value;
}
}
public bool IsConstant
{
get
@ -1968,7 +1988,32 @@ namespace IDE.ui
{
mWatchRefreshButton = new WatchRefreshButton();
mWatchRefreshButton.Resize(GS!(-16), 0, GS!(20), GS!(20));
mWatchRefreshButton.mOnMouseDown.Add(new (evt) => RefreshWatch());
mWatchRefreshButton.mOnMouseDown.Add(new (evt) =>
{
if (evt.mBtn == 0)
RefreshWatch();
if (evt.mBtn == 1)
{
Menu menu = new Menu();
Menu anItem;
anItem = menu.AddItem("Refresh");
anItem.mOnMenuItemSelected.Add(new (item) => { RefreshWatch(); });
anItem = menu.AddItem("Auto Refresh");
if (mWatchEntry.AutoRefresh)
anItem.mIconImage = DarkTheme.sDarkTheme.GetImage(.Check);
anItem.mOnMenuItemSelected.Add(new (item) =>
{
mWatchEntry.AutoRefresh = !mWatchEntry.AutoRefresh;
if (mWatchEntry.AutoRefresh)
RefreshWatch();
});
MenuWidget menuWidget = ThemeFactory.mDefault.CreateMenuWidget(menu);
menuWidget.Init(mWatchRefreshButton, evt.mX, mHeight + GS!(2));
}
});
var typeSubItem = GetSubItem(columnIdx);
typeSubItem.AddWidget(mWatchRefreshButton);
mListView.mListSizeDirty = true;
@ -2024,7 +2069,7 @@ namespace IDE.ui
if ((mDisabled) && (allowRefresh))
{
AddRefreshButton();
AddRefreshButton();
}
else if (mWatchRefreshButton != null)
{
@ -2061,7 +2106,7 @@ namespace IDE.ui
return retVal;
}
void RefreshWatch()
public void RefreshWatch()
{
var parentWatchListViewItem = mParentItem as WatchListViewItem;
if (parentWatchListViewItem != null)
@ -2997,7 +3042,12 @@ namespace IDE.ui
for (WatchListViewItem watchListViewItem in childItems)
{
var watchEntry = watchListViewItem.mWatchEntry;
data.Add(watchEntry.mEvalStr);
using (data.CreateObject())
{
data.Add("EvalStr", watchEntry.mEvalStr);
if (watchEntry.mAutoRefresh != null)
data.Add("AutoRefresh", watchEntry.mAutoRefresh.Value);
}
}
}
}
@ -3017,14 +3067,23 @@ namespace IDE.ui
IDEUtils.DeserializeListViewState(data, mListView);
for (let itemKey in data.Enumerate("Items"))
{
//for (int32 watchIdx = 0; watchIdx < data.Count; watchIdx++)
//for (var watchKV in data)
{
String watchEntry = scope String();
//data.GetString(watchIdx, watchEntry);
data.GetCurString(watchEntry);
AddWatch(watchEntry);
}
String watchEntry = scope String();
data.GetCurString(watchEntry);
WatchListViewItem watchItem;
if (!watchEntry.IsEmpty)
{
watchItem = AddWatch(watchEntry);
}
else
{
data.GetString("EvalStr", watchEntry);
watchItem = AddWatch(watchEntry);
if (data.Contains("AutoRefresh"))
{
watchItem.mWatchEntry.mAutoRefresh = data.GetBool("AutoRefresh");
}
}
}
return true;
@ -3622,6 +3681,12 @@ namespace IDE.ui
}
else if (watch.mEvalStr.Length > 0)
{
if (!gApp.mDebugger.IsPaused())
{
// Keep waiting
return;
}
String evalStr = scope String(1024);
if (watch.mStackFrameId != null)
{
@ -3637,6 +3702,7 @@ namespace IDE.ui
DebugManager.EvalExpressionFlags flags = .AllowStringView;
if (watch.mIsNewExpression)
flags |= .AllowSideEffects | .AllowCalls;
gApp.DebugEvaluate(null, evalStr, val, -1, watch.mLanguage, flags);
watch.mIsNewExpression = false;
}
@ -3666,6 +3732,14 @@ namespace IDE.ui
if (((!valueSubItem.mFailed) && (watch.mHadValue)) || (hadSideEffects) || (hadPropertyEval))
{
watch.mHasValue = true;
if ((hadSideEffects) && (watch.AutoRefresh))
{
if (watch.mDebuggerStateIdx != gApp.mDebugger.mStateIdx)
listViewItem.RefreshWatch();
return;
}
listViewItem.SetDisabled(true, hadSideEffects);
return;
}
@ -3730,6 +3804,7 @@ namespace IDE.ui
watch.mIsStackAlloc = false;
watch.mUsedLock = false;
watch.mCurStackIdx = -1;
watch.mDebuggerStateIdx = gApp.mDebugger.mStateIdx;
watch.mLanguage = .NotSet;
DeleteAndNullify!(watch.mEditInitialize);
DeleteAndNullify!(watch.mAction);