Debugger: Fixed empty list after resetting profiler

This commit is contained in:
Souryo 2017-09-28 21:10:48 -04:00
parent 8e37b81d3a
commit f00b4db2bb
3 changed files with 29 additions and 25 deletions

View file

@ -7,20 +7,7 @@
Profiler::Profiler(Debugger * debugger)
{
_debugger = debugger;
_nextFunctionAddr = -1;
_currentCycleCount = 0;
_currentInstruction = 0;
int size = _debugger->GetMemoryDumper()->GetMemorySize(DebugMemoryType::PrgRom);
_resetFunctionIndex = size;
_inMemoryFunctionIndex = size + 1;
_currentFunction = _resetFunctionIndex;
_cyclesByInstruction.insert(_cyclesByInstruction.end(), size + 2, 0);
_cyclesByFunction.insert(_cyclesByFunction.end(), size + 2, 0);
_cyclesByFunctionInclusive.insert(_cyclesByFunctionInclusive.end(), size + 2, 0);
_functionCallCount.insert(_functionCallCount.end(), size + 2, 0);
InternalReset();
}
void Profiler::ProcessCycle()
@ -91,22 +78,33 @@ void Profiler::ProcessInstructionStart(int32_t absoluteAddr)
void Profiler::Reset()
{
DebugBreakHelper helper(_debugger);
InternalReset();
}
void Profiler::InternalReset()
{
_nextFunctionAddr = -1;
_currentCycleCount = 0;
_currentInstruction = 0;
int size = _debugger->GetMemoryDumper()->GetMemorySize(DebugMemoryType::PrgRom);
_resetFunctionIndex = size;
_inMemoryFunctionIndex = size + 1;
_currentFunction = _resetFunctionIndex;
_cyclesByInstruction.clear();
_cyclesByFunction.clear();
_cyclesByFunctionInclusive.clear();
_functionCallCount.clear();
_functionStack = std::stack<int32_t>();
_jsrStack = std::stack<int32_t>();
_cycleCountStack = std::stack<uint64_t>();
_currentCycleCount = 0;
_cyclesByInstruction.insert(_cyclesByInstruction.end(), size + 2, 0);
_cyclesByFunction.insert(_cyclesByFunction.end(), size + 2, 0);
_cyclesByFunctionInclusive.insert(_cyclesByFunctionInclusive.end(), size + 2, 0);
_functionCallCount.insert(_functionCallCount.end(), size + 2, 0);
}
void Profiler::GetProfilerData(int64_t * profilerData, ProfilerDataType type)
{
DebugBreakHelper helper(_debugger);
vector<uint64_t> *dataArray = nullptr;
switch(type) {

View file

@ -36,6 +36,8 @@ private:
uint32_t _resetFunctionIndex;
uint32_t _inMemoryFunctionIndex;
void InternalReset();
public:
Profiler(Debugger* debugger);

View file

@ -18,6 +18,7 @@ namespace Mesen.GUI.Debugger.Controls
private Int64[] _exclusiveTime;
private Int64[] _inclusiveTime;
private Int64[] _callCount;
private object _resetLock = new object();
private int _sortColumn = 5;
private bool _sortOrder = true;
@ -34,10 +35,11 @@ namespace Mesen.GUI.Debugger.Controls
public void RefreshData()
{
_exclusiveTime = InteropEmu.DebugGetProfilerData(ProfilerDataType.FunctionExclusive);
_inclusiveTime = InteropEmu.DebugGetProfilerData(ProfilerDataType.FunctionInclusive);
_callCount = InteropEmu.DebugGetProfilerData(ProfilerDataType.FunctionCallCount);
lock(_resetLock) {
_exclusiveTime = InteropEmu.DebugGetProfilerData(ProfilerDataType.FunctionExclusive);
_inclusiveTime = InteropEmu.DebugGetProfilerData(ProfilerDataType.FunctionInclusive);
_callCount = InteropEmu.DebugGetProfilerData(ProfilerDataType.FunctionCallCount);
}
RefreshList();
}
@ -108,7 +110,9 @@ namespace Mesen.GUI.Debugger.Controls
private void btnReset_Click(object sender, EventArgs e)
{
InteropEmu.DebugResetProfiler();
lock(_resetLock) {
InteropEmu.DebugResetProfiler();
}
RefreshData();
}