1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 03:28:20 +02:00

Fixed some profiler shutdown issues

This commit is contained in:
Brian Fiete 2020-04-16 10:46:58 -07:00
parent 6434676134
commit 9eb5280170
5 changed files with 30 additions and 3 deletions

View file

@ -450,7 +450,7 @@ NetManager::~NetManager()
NetRequest* NetManager::CreateGetRequest(const StringImpl& url, const StringImpl& destPath, bool useCache) NetRequest* NetManager::CreateGetRequest(const StringImpl& url, const StringImpl& destPath, bool useCache)
{ {
AutoCrit autoCrit(mThreadPool.mCritSect); AutoCrit autoCrit(mThreadPool.mCritSect);
NetRequest* netRequest = new NetRequest(); NetRequest* netRequest = new NetRequest();
netRequest->mNetManager = this; netRequest->mNetManager = this;
netRequest->mURL = url; netRequest->mURL = url;

View file

@ -99,10 +99,14 @@ DbgProfiler::DbgProfiler(WinDebugger* debugger) : mShutdownEvent(true)
mStartTick = BFTickCount(); mStartTick = BFTickCount();
mEndTick = 0; mEndTick = 0;
mDebugger->AddProfiler(this);
} }
DbgProfiler::~DbgProfiler() DbgProfiler::~DbgProfiler()
{ {
mDebugger->RemoveProfiler(this);
Stop(); Stop();
DoClear(); DoClear();

View file

@ -117,7 +117,7 @@ class DbgProfiler : public Profiler
{ {
public: public:
WinDebugger* mDebugger; WinDebugger* mDebugger;
bool mIsRunning; volatile bool mIsRunning;
bool mWantsClear; bool mWantsClear;
SyncEvent mShutdownEvent; SyncEvent mShutdownEvent;
bool mNeedsProcessing; bool mNeedsProcessing;

View file

@ -924,6 +924,7 @@ void WinDebugger::DebugThreadProc()
{ {
DoUpdate(); DoUpdate();
} }
mIsRunning = false; mIsRunning = false;
for (int i = 0; i < (int) mBreakpoints.size(); i++) for (int i = 0; i < (int) mBreakpoints.size(); i++)
@ -1314,6 +1315,11 @@ void WinDebugger::Detach()
Sleep(1); Sleep(1);
} }
for (auto profiler : mProfilerSet)
profiler->Stop();
BfLogDbg("Debugger Detach - thread finished\n");
mPendingProfilerMap.Clear(); mPendingProfilerMap.Clear();
for (auto profiler : mNewProfilerList) for (auto profiler : mNewProfilerList)
delete profiler; delete profiler;
@ -1407,6 +1413,18 @@ Profiler* WinDebugger::PopProfiler()
return profiler; 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) void WinDebugger::ReportMemory(MemReporter* memReporter)
{ {
mEmptyDebugTarget->ReportMemory(memReporter); mEmptyDebugTarget->ReportMemory(memReporter);

View file

@ -21,6 +21,7 @@ namespace Beefy
NS_BF_DBG_BEGIN NS_BF_DBG_BEGIN
class DbgProfiler;
class DbgModule; class DbgModule;
class DbgSrcFile; class DbgSrcFile;
class DbgLineData; class DbgLineData;
@ -467,6 +468,7 @@ public:
Dictionary<int, Profiler*> mPendingProfilerMap; Dictionary<int, Profiler*> mPendingProfilerMap;
Array<Profiler*> mNewProfilerList; Array<Profiler*> mNewProfilerList;
HashSet<Profiler*> mProfilerSet;
addr_target mMemCacheAddr; addr_target mMemCacheAddr;
uint8 mMemCacheData[WD_MEMCACHE_SIZE]; uint8 mMemCacheData[WD_MEMCACHE_SIZE];
@ -660,7 +662,10 @@ public:
virtual void Detach() override; virtual void Detach() override;
virtual Profiler* StartProfiling() override; virtual Profiler* StartProfiling() override;
virtual Profiler* PopProfiler() 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 IsOnDemandDebugger() override { return false; }
virtual bool IsMiniDumpDebugger() { return false; } virtual bool IsMiniDumpDebugger() { return false; }