2015-07-01 23:17:14 -04:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "../Core/Console.h"
|
|
|
|
#include "../Core/Debugger.h"
|
2015-08-17 19:32:10 -04:00
|
|
|
#include "../Core/CodeDataLogger.h"
|
2016-11-22 22:38:14 -05:00
|
|
|
#include "../Core/LabelManager.h"
|
2016-12-01 19:38:48 -05:00
|
|
|
#include "../Core/MemoryDumper.h"
|
|
|
|
#include "../Core/MemoryAccessCounter.h"
|
2016-12-08 19:30:41 -05:00
|
|
|
#include "../Core/Profiler.h"
|
2015-07-01 23:17:14 -04:00
|
|
|
|
2015-08-21 22:42:44 -04:00
|
|
|
shared_ptr<Debugger> GetDebugger()
|
|
|
|
{
|
2016-06-04 08:55:52 -04:00
|
|
|
return Console::GetInstance()->GetDebugger();
|
2015-08-21 22:42:44 -04:00
|
|
|
}
|
2015-07-01 23:17:14 -04:00
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
//Debugger wrapper
|
|
|
|
DllExport void __stdcall DebugInitialize()
|
|
|
|
{
|
2016-06-04 08:55:52 -04:00
|
|
|
Console::GetInstance()->GetDebugger();
|
2015-07-01 23:17:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
DllExport void __stdcall DebugRelease()
|
|
|
|
{
|
2015-08-21 22:42:44 -04:00
|
|
|
Console::GetInstance()->StopDebugger();
|
2015-07-01 23:17:14 -04:00
|
|
|
}
|
|
|
|
|
2016-08-25 19:02:33 -04:00
|
|
|
DllExport bool __stdcall DebugIsDebuggerRunning()
|
|
|
|
{
|
|
|
|
return Console::GetInstance()->GetDebugger(false).get() != nullptr;
|
|
|
|
}
|
|
|
|
|
2016-06-05 10:26:05 -04:00
|
|
|
DllExport void __stdcall DebugSetFlags(uint32_t flags) { GetDebugger()->SetFlags(flags); }
|
|
|
|
|
2015-08-21 22:42:44 -04:00
|
|
|
DllExport void __stdcall DebugGetState(DebugState *state) { GetDebugger()->GetState(state); }
|
2016-11-26 17:48:11 -05:00
|
|
|
DllExport void __stdcall DebugSetState(DebugState state) { GetDebugger()->SetState(state); }
|
2015-07-01 23:17:14 -04:00
|
|
|
|
2016-01-09 13:15:43 -05:00
|
|
|
DllExport void __stdcall DebugSetBreakpoints(Breakpoint breakpoints[], uint32_t length) { GetDebugger()->SetBreakpoints(breakpoints, length); }
|
2016-11-22 22:38:14 -05:00
|
|
|
DllExport void __stdcall DebugSetLabel(uint32_t address, AddressType addressType, char* label, char* comment) { GetDebugger()->GetLabelManager()->SetLabel(address, addressType, label, comment); }
|
2016-11-26 17:48:11 -05:00
|
|
|
|
|
|
|
DllExport bool __stdcall DebugIsExecutionStopped() { return GetDebugger()->IsExecutionStopped(); }
|
2015-08-21 22:42:44 -04:00
|
|
|
DllExport void __stdcall DebugRun() { GetDebugger()->Run(); }
|
|
|
|
DllExport void __stdcall DebugStep(uint32_t count) { GetDebugger()->Step(count); }
|
|
|
|
DllExport void __stdcall DebugStepCycles(uint32_t count) { GetDebugger()->StepCycles(count); }
|
|
|
|
DllExport void __stdcall DebugStepOver() { GetDebugger()->StepOver(); }
|
|
|
|
DllExport void __stdcall DebugStepOut() { GetDebugger()->StepOut(); }
|
2016-06-04 15:38:48 -04:00
|
|
|
DllExport void __stdcall DebugPpuStep(uint32_t count) { GetDebugger()->PpuStep(count); }
|
2016-01-16 19:33:10 -05:00
|
|
|
DllExport bool __stdcall DebugIsCodeChanged() { return GetDebugger()->IsCodeChanged(); }
|
2015-08-21 22:42:44 -04:00
|
|
|
DllExport const char* __stdcall DebugGetCode() { return GetDebugger()->GetCode()->c_str(); }
|
|
|
|
|
2016-11-26 20:44:23 -05:00
|
|
|
DllExport void __stdcall DebugSetPpuViewerScanlineCycle(int32_t scanline, int32_t cycle) { return GetDebugger()->SetPpuViewerScanlineCycle(scanline, cycle); }
|
|
|
|
|
2015-08-21 22:42:44 -04:00
|
|
|
DllExport void __stdcall DebugSetNextStatement(uint16_t addr) { GetDebugger()->SetNextStatement(addr); }
|
2016-11-18 23:50:05 -05:00
|
|
|
DllExport void __stdcall DebugSetMemoryState(uint32_t type, uint8_t *buffer) { GetDebugger()->GetMemoryDumper()->SetMemoryState((DebugMemoryType)type, buffer); }
|
2015-08-21 22:42:44 -04:00
|
|
|
|
2016-11-18 23:50:05 -05:00
|
|
|
DllExport uint32_t __stdcall DebugGetMemoryState(uint32_t type, uint8_t *buffer) { return GetDebugger()->GetMemoryDumper()->GetMemoryState((DebugMemoryType)type, buffer); }
|
|
|
|
DllExport void __stdcall DebugGetNametable(uint32_t nametableIndex, uint32_t *frameBuffer, uint8_t *tileData, uint8_t *attributeData) { GetDebugger()->GetMemoryDumper()->GetNametable(nametableIndex, frameBuffer, tileData, attributeData); }
|
|
|
|
DllExport void __stdcall DebugGetChrBank(uint32_t bankIndex, uint32_t *frameBuffer, uint8_t palette, bool largeSprites, CdlHighlightType highlightType) { GetDebugger()->GetMemoryDumper()->GetChrBank(bankIndex, frameBuffer, palette, largeSprites, highlightType); }
|
|
|
|
DllExport void __stdcall DebugGetSprites(uint32_t *frameBuffer) { GetDebugger()->GetMemoryDumper()->GetSprites(frameBuffer); }
|
|
|
|
DllExport void __stdcall DebugGetPalette(uint32_t *frameBuffer) { GetDebugger()->GetMemoryDumper()->GetPalette(frameBuffer); }
|
2015-08-05 20:40:10 -04:00
|
|
|
|
2015-08-21 22:42:44 -04:00
|
|
|
DllExport void __stdcall DebugGetCallstack(int32_t *callstackAbsolute, int32_t *callstackRelative) { GetDebugger()->GetCallstack(callstackAbsolute, callstackRelative); }
|
2016-11-20 13:15:37 -05:00
|
|
|
DllExport void __stdcall DebugGetFunctionEntryPoints(int32_t *entryPoints) { GetDebugger()->GetFunctionEntryPoints(entryPoints); }
|
2015-08-09 14:47:27 -04:00
|
|
|
|
2015-08-21 22:42:44 -04:00
|
|
|
DllExport uint8_t __stdcall DebugGetMemoryValue(uint32_t addr) { return GetDebugger()->GetMemoryValue(addr); }
|
2016-11-22 22:38:14 -05:00
|
|
|
DllExport int32_t __stdcall DebugGetRelativeAddress(uint32_t addr, AddressType type) { return GetDebugger()->GetRelativeAddress(addr, type); }
|
2016-11-21 22:34:47 -05:00
|
|
|
DllExport int32_t __stdcall DebugGetAbsoluteAddress(uint32_t addr) { return GetDebugger()->GetAbsoluteAddress(addr); }
|
2016-11-22 22:38:14 -05:00
|
|
|
DllExport void __stdcall DebugGetAbsoluteAddressAndType(uint32_t relativeAddr, AddressTypeInfo* info) { return GetDebugger()->GetAbsoluteAddressAndType(relativeAddr, info); }
|
2015-08-17 19:32:10 -04:00
|
|
|
|
2015-08-21 22:42:44 -04:00
|
|
|
DllExport bool __stdcall DebugLoadCdlFile(char* cdlFilepath) { return GetDebugger()->LoadCdlFile(cdlFilepath); }
|
2016-12-05 23:35:07 -05:00
|
|
|
DllExport bool __stdcall DebugSaveCdlFile(char* cdlFilepath) { return GetDebugger()->GetCodeDataLogger()->SaveCdlFile(cdlFilepath); }
|
|
|
|
DllExport void __stdcall DebugGetCdlRatios(CdlRatios* cdlRatios) { *cdlRatios = GetDebugger()->GetCodeDataLogger()->GetRatios(); }
|
|
|
|
DllExport void __stdcall DebugResetCdlLog() { GetDebugger()->GetCodeDataLogger()->Reset(); }
|
2016-01-10 13:23:19 -05:00
|
|
|
|
|
|
|
DllExport int32_t __stdcall DebugEvaluateExpression(char* expression, EvalResultType *resultType) { return GetDebugger()->EvaluateExpression(expression, *resultType); }
|
2016-01-10 19:56:40 -05:00
|
|
|
|
|
|
|
DllExport void __stdcall DebugStartTraceLogger(TraceLoggerOptions options) { GetDebugger()->StartTraceLogger(options); }
|
|
|
|
DllExport void __stdcall DebugStopTraceLogger() { GetDebugger()->StopTraceLogger(); }
|
2016-12-01 19:38:48 -05:00
|
|
|
|
2017-02-26 20:47:39 -05:00
|
|
|
DllExport void __stdcall DebugSetMemoryValue(DebugMemoryType type, uint32_t address, uint8_t value) { return GetDebugger()->GetMemoryDumper()->SetMemoryValue(type, address, value); }
|
2016-12-01 19:38:48 -05:00
|
|
|
DllExport int32_t __stdcall DebugGetMemorySize(DebugMemoryType type) { return GetDebugger()->GetMemorySize(type); }
|
|
|
|
DllExport void __stdcall DebugGetMemoryAccessCounts(AddressType memoryType, MemoryOperationType operationType, uint32_t* counts, bool forUninitReads) { GetDebugger()->GetMemoryAccessCounter()->GetAccessCounts(memoryType, operationType, counts, forUninitReads); }
|
|
|
|
DllExport void __stdcall DebugResetMemoryAccessCounts() { GetDebugger()->GetMemoryAccessCounter()->ResetCounts(); }
|
2016-12-02 18:10:37 -05:00
|
|
|
|
2016-12-08 19:30:41 -05:00
|
|
|
DllExport void __stdcall DebugGetProfilerData(int64_t* profilerData, ProfilerDataType dataType) { GetDebugger()->GetProfiler()->GetProfilerData(profilerData, dataType); }
|
|
|
|
DllExport void __stdcall DebugResetProfiler() { GetDebugger()->GetProfiler()->Reset(); }
|
|
|
|
|
|
|
|
|
2016-12-02 18:10:37 -05:00
|
|
|
DllExport uint32_t __stdcall DebugGetPpuScroll() { return GetDebugger()->GetPpuScroll(); }
|
2015-07-01 23:17:14 -04:00
|
|
|
};
|