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

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

View file

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

View file

@ -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);

View file

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