diff --git a/IDEHelper/NetManager.cpp b/IDEHelper/NetManager.cpp index 45faec59..9f68e911 100644 --- a/IDEHelper/NetManager.cpp +++ b/IDEHelper/NetManager.cpp @@ -450,7 +450,7 @@ NetManager::~NetManager() NetRequest* NetManager::CreateGetRequest(const StringImpl& url, const StringImpl& destPath, bool useCache) { AutoCrit autoCrit(mThreadPool.mCritSect); - + NetRequest* netRequest = new NetRequest(); netRequest->mNetManager = this; netRequest->mURL = url; diff --git a/IDEHelper/Profiler.cpp b/IDEHelper/Profiler.cpp index 4a04b0c7..1cca8c3c 100644 --- a/IDEHelper/Profiler.cpp +++ b/IDEHelper/Profiler.cpp @@ -99,10 +99,14 @@ DbgProfiler::DbgProfiler(WinDebugger* debugger) : mShutdownEvent(true) mStartTick = BFTickCount(); mEndTick = 0; + + mDebugger->AddProfiler(this); } DbgProfiler::~DbgProfiler() { + mDebugger->RemoveProfiler(this); + Stop(); DoClear(); diff --git a/IDEHelper/Profiler.h b/IDEHelper/Profiler.h index 817a463a..b8a0a64a 100644 --- a/IDEHelper/Profiler.h +++ b/IDEHelper/Profiler.h @@ -117,7 +117,7 @@ class DbgProfiler : public Profiler { public: WinDebugger* mDebugger; - bool mIsRunning; + volatile bool mIsRunning; bool mWantsClear; SyncEvent mShutdownEvent; bool mNeedsProcessing; diff --git a/IDEHelper/WinDebugger.cpp b/IDEHelper/WinDebugger.cpp index deed3005..c1eed6c8 100644 --- a/IDEHelper/WinDebugger.cpp +++ b/IDEHelper/WinDebugger.cpp @@ -924,6 +924,7 @@ void WinDebugger::DebugThreadProc() { DoUpdate(); } + mIsRunning = false; for (int i = 0; i < (int) mBreakpoints.size(); i++) @@ -1314,6 +1315,11 @@ void WinDebugger::Detach() Sleep(1); } + for (auto profiler : mProfilerSet) + profiler->Stop(); + + BfLogDbg("Debugger Detach - thread finished\n"); + mPendingProfilerMap.Clear(); for (auto profiler : mNewProfilerList) delete profiler; @@ -1407,6 +1413,18 @@ Profiler* WinDebugger::PopProfiler() return profiler; } +void WinDebugger::AddProfiler(DbgProfiler * profiler) +{ + AutoCrit autoCrit(mDebugManager->mCritSect); + mProfilerSet.Add(profiler); +} + +void WinDebugger::RemoveProfiler(DbgProfiler * profiler) +{ + AutoCrit autoCrit(mDebugManager->mCritSect); + mProfilerSet.Remove(profiler); +} + void WinDebugger::ReportMemory(MemReporter* memReporter) { mEmptyDebugTarget->ReportMemory(memReporter); diff --git a/IDEHelper/WinDebugger.h b/IDEHelper/WinDebugger.h index c4b15ec6..df25f368 100644 --- a/IDEHelper/WinDebugger.h +++ b/IDEHelper/WinDebugger.h @@ -21,6 +21,7 @@ namespace Beefy NS_BF_DBG_BEGIN +class DbgProfiler; class DbgModule; class DbgSrcFile; class DbgLineData; @@ -467,6 +468,7 @@ public: Dictionary mPendingProfilerMap; Array mNewProfilerList; + HashSet mProfilerSet; addr_target mMemCacheAddr; uint8 mMemCacheData[WD_MEMCACHE_SIZE]; @@ -660,7 +662,10 @@ public: virtual void Detach() override; virtual Profiler* StartProfiling() override; virtual Profiler* PopProfiler() override; - virtual void ReportMemory(MemReporter* memReporter) override; + void AddProfiler(DbgProfiler* profiler); + void RemoveProfiler(DbgProfiler* profiler); + + virtual void ReportMemory(MemReporter* memReporter) override; virtual bool IsOnDemandDebugger() override { return false; } virtual bool IsMiniDumpDebugger() { return false; }