From 2a2913f857084da90fa3eda120953c4e6758bbbb Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Sun, 25 Aug 2024 09:30:49 -0400 Subject: [PATCH] Added @Script: support to breakpoints --- IDE/src/IDEApp.bf | 13 +++++++++++ IDE/src/ScriptManager.bf | 49 ++++++++++++++++++++++++++++++++++++--- IDE/src/ui/WatchPanel.bf | 2 +- IDEHelper/WinDebugger.cpp | 37 ++++++++++++++++++----------- 4 files changed, 83 insertions(+), 18 deletions(-) diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index 02f0d900..b5e1b9ec 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -13690,6 +13690,19 @@ namespace IDE { mSymSrvStatus.Set(param); } + else if (cmd == "script") + { + String absTestPath = scope String(); + if (mWorkspace.mDir != null) + Path.GetAbsolutePath(param, mWorkspace.mDir, absTestPath); + else + Path.GetFullPath(param, absTestPath); + if (mScriptManager.mFailed) + mScriptManager.Clear(); + mScriptManager.mSoftFail = true; + mScriptManager.SetTimeoutMS(20*60*1000); // 20 minute timeout + mScriptManager.QueueCommandFile(absTestPath); + } else { Runtime.FatalError("Invalid debugger message type"); diff --git a/IDE/src/ScriptManager.bf b/IDE/src/ScriptManager.bf index 78fee9ee..d4a32683 100644 --- a/IDE/src/ScriptManager.bf +++ b/IDE/src/ScriptManager.bf @@ -1562,6 +1562,15 @@ namespace IDE } } + [IDECommand] + public void PrintEval(String evalStr) + { + String outVal = scope String(); + if (!Evaluate(evalStr, outVal)) + return; + gApp.OutputLineSmart(outVal); + } + [IDECommand] public void AssertTypeInfo(int compilerId, String typeName, String wantTypeInfo) { @@ -1729,7 +1738,29 @@ namespace IDE } [IDECommand] - public void SelectCallStackWithStr(String str) + public void PrintCallStack() + { + gApp.OutputLine("Callstack:"); + int32 stackIdx = 0; + while (true) + { + int stackCount = gApp.mDebugger.GetCallStackCount(); + if (stackIdx >= stackCount) + { + gApp.mDebugger.UpdateCallStack(); + if (stackIdx >= gApp.mDebugger.GetCallStackCount()) + break; + } + + String file = scope .(); + String stackFrameInfo = scope .(); + gApp.mDebugger.GetStackFrameInfo(stackIdx, var addr, file, stackFrameInfo); + gApp.OutputLine(scope $" {stackIdx}: {stackFrameInfo}"); + stackIdx++; + } + } + + public bool DoSelectCallStackWithStr(String str) { int32 stackIdx = 0; while (true) @@ -1748,12 +1779,24 @@ namespace IDE if (stackFrameInfo.Contains(str)) { gApp.mDebugger.mActiveCallStackIdx = (.)stackIdx; - return; + return true; } stackIdx++; } + return false; + } - mScriptManager.Fail("Failed to find stack frame containing string '{}'", str); + [IDECommand] + public void SelectCallStackWithStr(String str) + { + if (!DoSelectCallStackWithStr(str)) + mScriptManager.Fail("Failed to find stack frame containing string '{}'", str); + } + + [IDECommand] + public void TrySelectCallStackWithStr(String str) + { + DoSelectCallStackWithStr(str); } public bool AssertRunning() diff --git a/IDE/src/ui/WatchPanel.bf b/IDE/src/ui/WatchPanel.bf index f77c326b..65205c97 100644 --- a/IDE/src/ui/WatchPanel.bf +++ b/IDE/src/ui/WatchPanel.bf @@ -2859,7 +2859,7 @@ namespace IDE.ui base.UpdateAll(); if (mWantRemoveSelf) - mParentItem.RemoveChildItem(this); + mParentItem?.RemoveChildItem(this); if (mColumnIdx == 0) { diff --git a/IDEHelper/WinDebugger.cpp b/IDEHelper/WinDebugger.cpp index 8c68ba15..a4d65b8d 100644 --- a/IDEHelper/WinDebugger.cpp +++ b/IDEHelper/WinDebugger.cpp @@ -4092,22 +4092,31 @@ bool WinDebugger::CheckConditionalBreakpoint(WdBreakpoint* breakpoint, DbgSubpro String expr; _SplitExpr(headBreakpoint->mLogging, expr, formatInfo.mSubjectExpr); - if (expr.StartsWith("@Beef:")) - { - expr.Remove(0, 6); - formatInfo.mLanguage = DbgLanguage_Beef; - } - else if (expr.StartsWith("@C:")) - { - expr.Remove(0, 3); - formatInfo.mLanguage = DbgLanguage_C; - } - ProcessEvalString(dbgCompileUnit, DbgTypedValue(), expr, displayString, formatInfo, NULL, false); - mRunState = prevRunState; + if (expr.StartsWith("@Script:")) + { + displayString = "script "; + displayString += expr.Substring(8); + } + else + { + if (expr.StartsWith("@Beef:")) + { + expr.Remove(0, 6); + formatInfo.mLanguage = DbgLanguage_Beef; + } + else if (expr.StartsWith("@C:")) + { + expr.Remove(0, 3); + formatInfo.mLanguage = DbgLanguage_C; + } - displayString.Insert(0, "log "); - displayString.Append("\n"); + ProcessEvalString(dbgCompileUnit, DbgTypedValue(), expr, displayString, formatInfo, NULL, false); + mRunState = prevRunState; + + displayString.Insert(0, "log "); + displayString.Append("\n"); + } mDebugManager->mOutMessages.push_back(displayString);