From d237c2aba2b6987c184152732e39d47f35e452c7 Mon Sep 17 00:00:00 2001 From: Hunter Bridges <775593+hunterbridges@users.noreply.github.com> Date: Wed, 14 Apr 2021 11:04:54 -0700 Subject: [PATCH] Only attempt to allocate hot heap when hot swapping is enabled --- IDE/src/Debugger/DebugManager.bf | 4 ++-- IDEHelper/DebugManager.cpp | 4 ++-- IDEHelper/DebugTarget.cpp | 2 +- IDEHelper/Debugger.h | 2 +- IDEHelper/WinDebugger.cpp | 3 ++- IDEHelper/WinDebugger.h | 3 ++- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/IDE/src/Debugger/DebugManager.bf b/IDE/src/Debugger/DebugManager.bf index 046b01c8..d10ef3c3 100644 --- a/IDE/src/Debugger/DebugManager.bf +++ b/IDE/src/Debugger/DebugManager.bf @@ -140,7 +140,7 @@ namespace IDE.Debugger static extern bool Debugger_OpenMiniDump(char8* filename); [CallingConvention(.Stdcall),CLink] - static extern bool Debugger_OpenFile(char8* launchPath, char8* targetPath, char8* args, char8* workingDir, void* envBlockPtr, int32 envBlockLen); + static extern bool Debugger_OpenFile(char8* launchPath, char8* targetPath, char8* args, char8* workingDir, void* envBlockPtr, int32 envBlockLen, bool hotSwapEnabled); [CallingConvention(.Stdcall),CLink] static extern bool Debugger_Attach(int32 processId, AttachFlags attachFlags); @@ -429,7 +429,7 @@ namespace IDE.Debugger mIsRunningCompiled = isCompiled; mIsRunningWithHotSwap = hotSwapEnabled; - return Debugger_OpenFile(launchPath, targetPath, args, workingDir, envBlock.Ptr, (int32)envBlock.Length); + return Debugger_OpenFile(launchPath, targetPath, args, workingDir, envBlock.Ptr, (int32)envBlock.Length, hotSwapEnabled); } public void SetSymSrvOptions(String symCacheDir, String symSrvStr, SymSrvFlags symSrvFlags) diff --git a/IDEHelper/DebugManager.cpp b/IDEHelper/DebugManager.cpp index c7ff3033..580959fb 100644 --- a/IDEHelper/DebugManager.cpp +++ b/IDEHelper/DebugManager.cpp @@ -745,7 +745,7 @@ BF_EXPORT int BF_CALLTYPE Debugger_GetAddrSize() return gDebugger->GetAddrSize(); } -BF_EXPORT bool BF_CALLTYPE Debugger_OpenFile(const char* launchPath, const char* targetPath, const char* args, const char* workingDir, void* envBlockPtr, int envBlockSize) +BF_EXPORT bool BF_CALLTYPE Debugger_OpenFile(const char* launchPath, const char* targetPath, const char* args, const char* workingDir, void* envBlockPtr, int envBlockSize, bool hotSwapEnabled) { BF_ASSERT(gDebugger == NULL); @@ -775,7 +775,7 @@ BF_EXPORT bool BF_CALLTYPE Debugger_OpenFile(const char* launchPath, const char* envBlock.Insert(0, (uint8*)envBlockPtr, envBlockSize); } - gDebugger->OpenFile(launchPath, targetPath, args, workingDir, envBlock); + gDebugger->OpenFile(launchPath, targetPath, args, workingDir, envBlock, hotSwapEnabled); return true; } diff --git a/IDEHelper/DebugTarget.cpp b/IDEHelper/DebugTarget.cpp index ddc24ea5..efe0055a 100644 --- a/IDEHelper/DebugTarget.cpp +++ b/IDEHelper/DebugTarget.cpp @@ -82,7 +82,7 @@ static bool PathEquals(const String& pathA, String& pathB) void DebugTarget::SetupTargetBinary() { - bool wantsHotHeap = mDebugger->mDbgProcessId == 0; + bool wantsHotHeap = (mDebugger->mHotSwapEnabled == true && mDebugger->mDbgProcessId == 0); #ifdef BF_DBG_32 if (wantsHotHeap) diff --git a/IDEHelper/Debugger.h b/IDEHelper/Debugger.h index a9416539..ce603352 100644 --- a/IDEHelper/Debugger.h +++ b/IDEHelper/Debugger.h @@ -257,7 +257,7 @@ public: virtual void OutputRawMessage(const StringImpl& msg) = 0; virtual int GetAddrSize() = 0; virtual bool CanOpen(const StringImpl& fileName, DebuggerResult* outResult) = 0; - virtual void OpenFile(const StringImpl& launchPath, const StringImpl& targetPath, const StringImpl& args, const StringImpl& workingDir, const Array& envBlock) = 0; + virtual void OpenFile(const StringImpl& launchPath, const StringImpl& targetPath, const StringImpl& args, const StringImpl& workingDir, const Array& envBlock, bool hotSwapEnabled) = 0; virtual bool Attach(int processId, BfDbgAttachFlags attachFlags) = 0; virtual void Run() = 0; virtual void HotLoad(const Array& objectFiles, int hotIdx) = 0; diff --git a/IDEHelper/WinDebugger.cpp b/IDEHelper/WinDebugger.cpp index b443c538..e470703f 100644 --- a/IDEHelper/WinDebugger.cpp +++ b/IDEHelper/WinDebugger.cpp @@ -1003,7 +1003,7 @@ bool WinDebugger::CanOpen(const StringImpl& fileName, DebuggerResult* outResult) return canRead; } -void WinDebugger::OpenFile(const StringImpl& launchPath, const StringImpl& targetPath, const StringImpl& args, const StringImpl& workingDir, const Array& envBlock) +void WinDebugger::OpenFile(const StringImpl& launchPath, const StringImpl& targetPath, const StringImpl& args, const StringImpl& workingDir, const Array& envBlock, bool hotSwapEnabled) { BF_ASSERT(!mIsRunning); mLaunchPath = launchPath; @@ -1011,6 +1011,7 @@ void WinDebugger::OpenFile(const StringImpl& launchPath, const StringImpl& targe mArgs = args; mWorkingDir = workingDir; mEnvBlock = envBlock; + mHotSwapEnabled = hotSwapEnabled; mDebugTarget = new DebugTarget(this); } diff --git a/IDEHelper/WinDebugger.h b/IDEHelper/WinDebugger.h index 9ee575f7..8cb9f511 100644 --- a/IDEHelper/WinDebugger.h +++ b/IDEHelper/WinDebugger.h @@ -427,6 +427,7 @@ public: String mTargetPath; String mArgs; String mWorkingDir; + bool mHotSwapEnabled; Array mEnvBlock; DebugTarget* mEmptyDebugTarget; DebugTarget* mDebugTarget; @@ -617,7 +618,7 @@ public: virtual void OutputRawMessage(const StringImpl& msg) override; virtual int GetAddrSize() override; virtual bool CanOpen(const StringImpl& fileName, DebuggerResult* outResult) override; - virtual void OpenFile(const StringImpl& launchPath, const StringImpl& targetPath, const StringImpl& args, const StringImpl& workingDir, const Array& envBlock) override; + virtual void OpenFile(const StringImpl& launchPath, const StringImpl& targetPath, const StringImpl& args, const StringImpl& workingDir, const Array& envBlock, bool hotSwapEnabled) override; virtual bool Attach(int processId, BfDbgAttachFlags attachFlags) override; virtual void Run() override; virtual void HotLoad(const Array& objectFiles, int hotIdx) override;