Added api for getting breakpoints and cpu flags.
This commit is contained in:
parent
a91ddf8c51
commit
320371740d
8 changed files with 74 additions and 0 deletions
|
@ -54,6 +54,30 @@ void BreakpointManager::SetBreakpoints(Breakpoint breakpoints[], uint32_t count)
|
|||
}
|
||||
}
|
||||
|
||||
void BreakpointManager::GetBreakpoints(Breakpoint* breakpoints, int& execs, int& reads, int& writes)
|
||||
{
|
||||
execs = _breakpoints[static_cast<int>(BreakpointType::Execute)].size();
|
||||
reads = _breakpoints[static_cast<int>(BreakpointType::Read)].size();
|
||||
writes = _breakpoints[static_cast<int>(BreakpointType::Write)].size();
|
||||
|
||||
if (breakpoints == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
for (auto it = _breakpoints[static_cast<int>(BreakpointType::Execute)].cbegin(); it != _breakpoints[static_cast<int>(BreakpointType::Execute)].cend(); it++) {
|
||||
breakpoints[offset++] = it->second;
|
||||
}
|
||||
|
||||
for (auto it = _breakpoints[static_cast<int>(BreakpointType::Read)].cbegin(); it != _breakpoints[static_cast<int>(BreakpointType::Read)].cend(); it++) {
|
||||
breakpoints[offset++] = it->second;
|
||||
}
|
||||
|
||||
for (auto it = _breakpoints[static_cast<int>(BreakpointType::Write)].cbegin(); it != _breakpoints[static_cast<int>(BreakpointType::Write)].cend(); it++) {
|
||||
breakpoints[offset++] = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
BreakpointType BreakpointManager::GetBreakpointType(MemoryOperationType type)
|
||||
{
|
||||
switch(type) {
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
BreakpointManager(Debugger *debugger, CpuType cpuType, IEventManager* eventManager = nullptr);
|
||||
|
||||
void SetBreakpoints(Breakpoint breakpoints[], uint32_t count);
|
||||
void GetBreakpoints(Breakpoint* breakpoints, int& execs, int& reads, int& writes);
|
||||
__forceinline int CheckBreakpoint(MemoryOperationInfo operationInfo, AddressInfo &address);
|
||||
};
|
||||
|
||||
|
|
|
@ -134,6 +134,10 @@ void Cpu::SetReg(CpuRegister reg, uint16_t value)
|
|||
}
|
||||
}
|
||||
|
||||
bool Cpu::GetCpuProcFlag(ProcFlags::ProcFlags flag) {
|
||||
return _state.PS & static_cast<uint8_t>(flag);
|
||||
}
|
||||
|
||||
void Cpu::SetCpuProcFlag(ProcFlags::ProcFlags flag, bool set)
|
||||
{
|
||||
_state.PS = set ? (_state.PS | static_cast<uint8_t>(flag)) : (_state.PS & ~static_cast<uint8_t>(flag));
|
||||
|
|
|
@ -331,6 +331,7 @@ public:
|
|||
void Exec();
|
||||
|
||||
CpuState GetState();
|
||||
bool GetCpuProcFlag(ProcFlags::ProcFlags flag);
|
||||
uint64_t GetCycleCount();
|
||||
|
||||
template<uint64_t value>
|
||||
|
|
|
@ -511,6 +511,11 @@ void Debugger::GetState(DebugState &state, bool partialPpuState)
|
|||
}
|
||||
}
|
||||
|
||||
bool Debugger::GetCpuProcFlag(ProcFlags::ProcFlags flag)
|
||||
{
|
||||
return _cpu->GetCpuProcFlag(flag);
|
||||
}
|
||||
|
||||
void Debugger::SetCpuRegister(CpuRegister reg, uint16_t value)
|
||||
{
|
||||
_cpu->SetReg(reg, value);
|
||||
|
@ -716,6 +721,39 @@ void Debugger::SetBreakpoints(Breakpoint breakpoints[], uint32_t length)
|
|||
}
|
||||
}
|
||||
|
||||
void Debugger::GetBreakpoints(CpuType cpuType, Breakpoint* breakpoints, int& execs, int& reads, int& writes)
|
||||
{
|
||||
switch (cpuType) {
|
||||
case CpuType::Cpu: return _cpuDebugger->GetBreakpointManager()->GetBreakpoints(breakpoints, reads, writes, execs);
|
||||
case CpuType::Spc: return _spcDebugger->GetBreakpointManager()->GetBreakpoints(breakpoints, reads, writes, execs);
|
||||
case CpuType::Gsu: {
|
||||
if (_gsuDebugger) {
|
||||
return _gsuDebugger->GetBreakpointManager()->GetBreakpoints(breakpoints, reads, writes, execs);
|
||||
}
|
||||
} break;
|
||||
case CpuType::Sa1: {
|
||||
if (_sa1Debugger) {
|
||||
return _sa1Debugger->GetBreakpointManager()->GetBreakpoints(breakpoints, reads, writes, execs);
|
||||
}
|
||||
} break;
|
||||
case CpuType::NecDsp: {
|
||||
if (_necDspDebugger) {
|
||||
return _necDspDebugger->GetBreakpointManager()->GetBreakpoints(breakpoints, reads, writes, execs);
|
||||
}
|
||||
} break;
|
||||
case CpuType::Cx4: {
|
||||
if (_cx4Debugger) {
|
||||
return _cx4Debugger->GetBreakpointManager()->GetBreakpoints(breakpoints, reads, writes, execs);
|
||||
}
|
||||
} break;
|
||||
case CpuType::Gameboy: {
|
||||
if (_gbDebugger) {
|
||||
return _gbDebugger->GetBreakpointManager()->GetBreakpoints(breakpoints, reads, writes, execs);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void Debugger::Log(string message)
|
||||
{
|
||||
auto lock = _logLock.AcquireSafe();
|
||||
|
|
|
@ -128,6 +128,7 @@ public:
|
|||
void SleepUntilResume(BreakSource source, MemoryOperationInfo* operation = nullptr, int breakpointId = -1);
|
||||
|
||||
void GetState(DebugState& state, bool partialPpuState);
|
||||
bool GetCpuProcFlag(ProcFlags::ProcFlags flag);
|
||||
|
||||
void SetCpuRegister(CpuRegister reg, uint16_t value);
|
||||
void SetCpuProcFlag(ProcFlags::ProcFlags flag, bool set);
|
||||
|
@ -149,6 +150,7 @@ public:
|
|||
void RebuildPrgCache(CpuType cpuType);
|
||||
|
||||
void SetBreakpoints(Breakpoint breakpoints[], uint32_t length);
|
||||
void GetBreakpoints(CpuType cpuType, Breakpoint* breakpoints, int& execs, int& reads, int& writes);
|
||||
|
||||
void Log(string message);
|
||||
string GetLog();
|
||||
|
|
|
@ -61,12 +61,15 @@ extern "C"
|
|||
DllExport const char* GetExecutionTrace(uint32_t lineCount) { return GetDebugger()->GetTraceLogger()->GetExecutionTrace(lineCount); }
|
||||
|
||||
DllExport void __stdcall SetBreakpoints(Breakpoint breakpoints[], uint32_t length) { GetDebugger()->SetBreakpoints(breakpoints, length); }
|
||||
DllExport void __stdcall GetBreakpoints(CpuType cpuType, Breakpoint* breakpoints, int& execs, int& reads, int& writes) { GetDebugger()->GetBreakpoints(cpuType, breakpoints, execs, reads, writes); }
|
||||
|
||||
DllExport int32_t __stdcall EvaluateExpression(char* expression, CpuType cpuType, EvalResultType *resultType, bool useCache) { return GetDebugger()->EvaluateExpression(expression, cpuType, *resultType, useCache); }
|
||||
DllExport void __stdcall GetCallstack(CpuType cpuType, StackFrameInfo *callstackArray, uint32_t &callstackSize) { GetDebugger()->GetCallstackManager(cpuType)->GetCallstack(callstackArray, callstackSize); }
|
||||
DllExport void __stdcall GetProfilerData(CpuType cpuType, ProfiledFunction* profilerData, uint32_t& functionCount) { GetDebugger()->GetCallstackManager(cpuType)->GetProfiler()->GetProfilerData(profilerData, functionCount); }
|
||||
DllExport void __stdcall ResetProfiler(CpuType cpuType) { GetDebugger()->GetCallstackManager(cpuType)->GetProfiler()->Reset(); }
|
||||
|
||||
DllExport void __stdcall GetState(DebugState& state) { GetDebugger()->GetState(state, false); }
|
||||
DllExport bool __stdcall GetCpuProcFlag(ProcFlags::ProcFlags flag) { return GetDebugger()->GetCpuProcFlag(flag); }
|
||||
|
||||
DllExport void __stdcall SetCpuRegister(CpuRegister reg, uint16_t value) { GetDebugger()->SetCpuRegister(reg, value); }
|
||||
DllExport void __stdcall SetCpuProcFlag(ProcFlags::ProcFlags flag, bool set) { GetDebugger()->SetCpuProcFlag(flag, set); };
|
||||
|
|
|
@ -89,6 +89,7 @@ namespace Mesen.GUI
|
|||
[DllImport(DllPath)] public static extern void ClearLabels();
|
||||
|
||||
[DllImport(DllPath)] public static extern void SetBreakpoints([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]InteropBreakpoint[] breakpoints, UInt32 length);
|
||||
[DllImport(DllPath)] public static extern void GetBreakpoints(CpuType cpuType, [In, Out] Breakpoint[] breakpoints, ref Int32 execs, ref Int32 reads, ref Int32 writes);
|
||||
|
||||
[DllImport(DllPath)] public static extern void SaveRomToDisk([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string filename, [MarshalAs(UnmanagedType.I1)]bool saveAsIps, CdlStripOption cdlStripOption);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue