2017-06-04 20:38:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <cstdint>
|
2018-10-31 23:29:13 +00:00
|
|
|
#include <map>
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2018-01-06 23:19:29 +00:00
|
|
|
#include <EventArgs.h>
|
|
|
|
#include <Signal.h>
|
2017-06-04 20:38:34 +00:00
|
|
|
|
|
|
|
#include "ProfileLineEventArgs.h"
|
|
|
|
#include "ProfileScopeEventArgs.h"
|
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
namespace EightBit {
|
2018-10-31 23:29:13 +00:00
|
|
|
|
|
|
|
class Disassembly;
|
|
|
|
class MOS6502;
|
|
|
|
class Symbols;
|
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
class Profiler {
|
|
|
|
public:
|
|
|
|
std::array<uint64_t, 0x100> instructionCounts;
|
|
|
|
std::array<uint64_t, 0x10000> addressProfiles;
|
|
|
|
std::array<uint64_t, 0x10000> addressCounts;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
std::array<std::string, 0x10000> addressScopes;
|
|
|
|
std::map<std::string, uint64_t> scopeCycles;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
MOS6502& processor;
|
2018-10-20 19:52:41 +00:00
|
|
|
Disassembly& disassembler;
|
2017-07-02 21:03:33 +00:00
|
|
|
const Symbols& symbols;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
Profiler(MOS6502& processor, Disassembly& disassembler, Symbols& symbols);
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
Signal<EventArgs> StartingOutput;
|
|
|
|
Signal<EventArgs> FinishedOutput;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
Signal<EventArgs> StartingLineOutput;
|
|
|
|
Signal<EventArgs> FinishedLineOutput;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
Signal<ProfileLineEventArgs> EmitLine;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
Signal<EventArgs> StartingScopeOutput;
|
|
|
|
Signal<EventArgs> FinishedScopeOutput;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
Signal<ProfileScopeEventArgs> EmitScope;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
void addInstruction(uint8_t instruction);
|
|
|
|
void addAddress(uint16_t address, int cycles);
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
void Generate();
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
private:
|
|
|
|
void EmitProfileInformation();
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
void BuildAddressScopes();
|
|
|
|
};
|
|
|
|
}
|