2020-02-08 17:08:33 -05:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "DebugTypes.h"
|
|
|
|
|
|
|
|
class Debugger;
|
|
|
|
class MemoryManager;
|
|
|
|
|
|
|
|
struct ProfiledFunction
|
|
|
|
{
|
|
|
|
uint64_t ExclusiveCycles = 0;
|
|
|
|
uint64_t InclusiveCycles = 0;
|
|
|
|
uint64_t CallCount = 0;
|
|
|
|
uint64_t MinCycles = UINT64_MAX;
|
|
|
|
uint64_t MaxCycles = 0;
|
|
|
|
AddressInfo Address;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Profiler
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
Debugger* _debugger;
|
|
|
|
MemoryManager* _memoryManager;
|
|
|
|
|
|
|
|
unordered_map<int32_t, ProfiledFunction> _functions;
|
|
|
|
|
|
|
|
deque<int32_t> _functionStack;
|
|
|
|
deque<StackFrameFlags> _stackFlags;
|
2020-02-09 09:26:03 -05:00
|
|
|
deque<uint64_t> _cycleCountStack;
|
2020-02-08 17:08:33 -05:00
|
|
|
|
|
|
|
uint64_t _currentCycleCount;
|
|
|
|
uint64_t _prevMasterClock;
|
|
|
|
int32_t _currentFunction;
|
|
|
|
|
|
|
|
void InternalReset();
|
|
|
|
void UpdateCycles();
|
|
|
|
|
|
|
|
public:
|
|
|
|
Profiler(Debugger* debugger);
|
|
|
|
~Profiler();
|
|
|
|
|
|
|
|
void StackFunction(AddressInfo& addr, StackFrameFlags stackFlag);
|
|
|
|
void UnstackFunction();
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
void GetProfilerData(ProfiledFunction* profilerData, uint32_t& functionCount);
|
|
|
|
};
|