From 18794e7db6e9e6fe82e175ce261147d5d546deaa Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Mon, 21 Mar 2022 11:14:19 -0700 Subject: [PATCH] Comptime debugging fix with non-incremental builds (ie: Release) --- IDE/src/BuildContext.bf | 1 + IDE/src/IDEApp.bf | 34 +++++++++++++++++++++----------- IDEHelper/Compiler/CeMachine.cpp | 2 ++ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/IDE/src/BuildContext.bf b/IDE/src/BuildContext.bf index 5621d6f4..da4fcf96 100644 --- a/IDE/src/BuildContext.bf +++ b/IDE/src/BuildContext.bf @@ -14,6 +14,7 @@ namespace IDE case Normal; case RunAfter; case DebugAfter; + case DebugComptime; case Test; public bool WantsRunAfter diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index c28a481f..8803076a 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -4282,8 +4282,14 @@ namespace IDE return disassemblyPanel; } + [IDECommand] void Compile() + { + Compile(.Normal); + } + + void Compile(CompileKind compileKind) { CompilerLog("IDEApp.Compile"); for (let project in gApp.mWorkspace.mProjects) @@ -4343,11 +4349,11 @@ namespace IDE if (mExecutionQueue.Count == 0) { mOutputPanel.Clear(); - if (mDebugger?.mIsComptimeDebug == true) + if (compileKind == .DebugComptime) OutputLine("Compiling with comptime debugging..."); else OutputLine("Compiling..."); - Compile(.Normal, null); + Compile(compileKind, null); } } else @@ -4355,7 +4361,7 @@ namespace IDE mOutputPanel.Clear(); OutputLine("Hot Compiling..."); Project runningProject = mWorkspace.mStartupProject; - Compile(.Normal, runningProject); + Compile(compileKind, runningProject); } } @@ -4461,12 +4467,7 @@ namespace IDE return; CheckDebugVisualizers(); - mTargetDidInitBreak = true; - mTargetStartWithStep = false; - mDebugger.ComptimeAttach(mBfBuildCompiler); - mDebugger.RehupBreakpoints(true); - mBfBuildCompiler.ForceRebuild(); - Compile(); + Compile(.DebugComptime); } [IDECommand] @@ -10730,7 +10731,7 @@ namespace IDE mOutputPanel.Clear(); OutputLine("Compiling..."); - if (!Compile(debug ? .DebugAfter : .RunAfter)) + if (!Compile(debug ? .DebugAfter : .RunAfter, null)) return false; return true; } @@ -10905,7 +10906,7 @@ namespace IDE } } - protected bool Compile(CompileKind compileKind = .Normal, Project hotProject = null) + protected bool Compile(CompileKind compileKind, Project hotProject) { Debug.Assert(mBuildContext == null); @@ -11145,6 +11146,15 @@ namespace IDE } } + if (compileKind == .DebugComptime) + { + mTargetDidInitBreak = true; + mTargetStartWithStep = false; + mDebugger.ComptimeAttach(mBfBuildCompiler); + mDebugger.RehupBreakpoints(true); + mBfBuildCompiler.ForceRebuild(); + } + bool lastCompileHadMessages = mLastCompileHadMessages; mLastCompileFailed = false; mLastCompileSucceeded = false; @@ -11164,7 +11174,7 @@ namespace IDE if ((mDebugger != null) && (mDebugger.mIsRunning) && (hotProject == null)) { Debug.Assert(!mDebugger.mIsRunningCompiled); - Debug.Assert(compileKind == .Normal); + Debug.Assert((compileKind == .Normal) || (compileKind == .DebugComptime)); } mHaveSourcesChangedExternallySinceLastCompile = false; diff --git a/IDEHelper/Compiler/CeMachine.cpp b/IDEHelper/Compiler/CeMachine.cpp index 1bc1db80..876063f9 100644 --- a/IDEHelper/Compiler/CeMachine.cpp +++ b/IDEHelper/Compiler/CeMachine.cpp @@ -8487,6 +8487,8 @@ CeMachine::CeMachine(BfCompiler* compiler) CeMachine::~CeMachine() { + BF_ASSERT(mDebugger == NULL); + for (auto context : mContextList) delete context;