Debugger: Add stub API for replay functionality.

This commit is contained in:
Unknown W. Brackets 2021-05-23 21:23:13 -07:00
parent ecc2f62688
commit 64e007c0ce
11 changed files with 119 additions and 8 deletions

View File

@ -1580,6 +1580,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/Debugger/WebSocket/MemoryInfoSubscriber.h
Core/Debugger/WebSocket/MemorySubscriber.cpp
Core/Debugger/WebSocket/MemorySubscriber.h
Core/Debugger/WebSocket/ReplaySubscriber.cpp
Core/Debugger/WebSocket/ReplaySubscriber.h
Core/Debugger/WebSocket/SteppingBroadcaster.cpp
Core/Debugger/WebSocket/SteppingBroadcaster.h
Core/Debugger/WebSocket/SteppingSubscriber.cpp

View File

@ -525,6 +525,7 @@
<ClCompile Include="Debugger\WebSocket\DisasmSubscriber.cpp" />
<ClCompile Include="Debugger\WebSocket\MemoryInfoSubscriber.cpp" />
<ClCompile Include="Debugger\WebSocket\MemorySubscriber.cpp" />
<ClCompile Include="Debugger\WebSocket\ReplaySubscriber.cpp" />
<ClCompile Include="Debugger\WebSocket\SteppingBroadcaster.cpp" />
<ClCompile Include="Debugger\WebSocket\SteppingSubscriber.cpp" />
<ClCompile Include="Debugger\WebSocket\WebSocketUtils.cpp" />
@ -1076,6 +1077,7 @@
<ClInclude Include="Debugger\WebSocket\InputBroadcaster.h" />
<ClInclude Include="Debugger\WebSocket\InputSubscriber.h" />
<ClInclude Include="Debugger\WebSocket\MemoryInfoSubscriber.h" />
<ClInclude Include="Debugger\WebSocket\ReplaySubscriber.h" />
<ClInclude Include="Debugger\WebSocket\SteppingSubscriber.h" />
<ClInclude Include="Debugger\WebSocket\WebSocketUtils.h" />
<ClInclude Include="Debugger\WebSocket\CPUCoreSubscriber.h" />

View File

@ -1172,6 +1172,9 @@
<ClCompile Include="..\ext\libzip\zip_random_win32.c">
<Filter>Ext\libzip</Filter>
</ClCompile>
<ClCompile Include="Debugger\WebSocket\ReplaySubscriber.cpp">
<Filter>Debugger\WebSocket</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ELF\ElfReader.h">
@ -1886,6 +1889,9 @@
<ClInclude Include="..\ext\libzip\zipconf.h">
<Filter>Ext\libzip</Filter>
</ClInclude>
<ClInclude Include="Debugger\WebSocket\ReplaySubscriber.h">
<Filter>Debugger\WebSocket</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />

View File

@ -59,6 +59,7 @@
#include "Core/Debugger/WebSocket/InputSubscriber.h"
#include "Core/Debugger/WebSocket/MemoryInfoSubscriber.h"
#include "Core/Debugger/WebSocket/MemorySubscriber.h"
#include "Core/Debugger/WebSocket/ReplaySubscriber.h"
#include "Core/Debugger/WebSocket/SteppingSubscriber.h"
typedef DebuggerSubscriber *(*SubscriberInit)(DebuggerEventHandlerMap &map);
@ -73,6 +74,7 @@ static const std::vector<SubscriberInit> subscribers({
&WebSocketInputInit,
&WebSocketMemoryInfoInit,
&WebSocketMemoryInit,
&WebSocketReplayInit,
&WebSocketSteppingInit,
});

View File

@ -0,0 +1,60 @@
// Copyright (c) 2021- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "Core/Replay.h"
#include "Core/Debugger/WebSocket/ReplaySubscriber.h"
DebuggerSubscriber *WebSocketReplayInit(DebuggerEventHandlerMap &map) {
// No need to bind or alloc state, these are all global.
map["replay.begin"] = &WebSocketReplayBegin;
map["replay.abort"] = &WebSocketReplayAbort;
map["replay.flush"] = &WebSocketReplayFlush;
map["replay.execute"] = &WebSocketReplayExecute;
map["replay.status"] = &WebSocketReplayStatus;
map["replay.time.get"] = &WebSocketReplayTimeGet;
map["replay.time.set"] = &WebSocketReplayTimeSet;
return nullptr;
}
void WebSocketReplayBegin(DebuggerRequest &req) {
// TODO
}
void WebSocketReplayAbort(DebuggerRequest &req) {
// TODO
}
void WebSocketReplayFlush(DebuggerRequest &req) {
// TODO
}
void WebSocketReplayExecute(DebuggerRequest &req) {
// TODO
}
void WebSocketReplayStatus(DebuggerRequest &req) {
// TODO
}
void WebSocketReplayTimeGet(DebuggerRequest &req) {
// TODO
}
void WebSocketReplayTimeSet(DebuggerRequest &req) {
// TODO
}

View File

@ -0,0 +1,30 @@
// Copyright (c) 2021- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
#include "Core/Debugger/WebSocket/WebSocketUtils.h"
DebuggerSubscriber *WebSocketReplayInit(DebuggerEventHandlerMap &map);
void WebSocketReplayBegin(DebuggerRequest &req);
void WebSocketReplayAbort(DebuggerRequest &req);
void WebSocketReplayFlush(DebuggerRequest &req);
void WebSocketReplayExecute(DebuggerRequest &req);
void WebSocketReplayStatus(DebuggerRequest &req);
void WebSocketReplayTimeGet(DebuggerRequest &req);
void WebSocketReplayTimeSet(DebuggerRequest &req);

View File

@ -116,7 +116,7 @@ struct ReplayFileInfo {
struct ReplayItem {
ReplayItemHeader info;
std::vector<u8> data;
std::vector<uint8_t> data;
ReplayItem(ReplayItemHeader h) : info(h) {
}
@ -136,7 +136,7 @@ static uint8_t lastAnalog[2][2]{};
static size_t replayDiskPos = 0;
static bool diskFailed = false;
void ReplayExecuteBlob(const std::vector<u8> &data) {
void ReplayExecuteBlob(const std::vector<uint8_t> &data) {
ReplayAbort();
// Rough estimate.
@ -178,7 +178,7 @@ bool ReplayExecuteFile(const Path &filename) {
return false;
}
std::vector<u8> data;
std::vector<uint8_t> data;
auto loadData = [&]() {
// TODO: Maybe stream instead.
size_t sz = File::GetFileSize(fp);
@ -243,7 +243,7 @@ void ReplayBeginSave() {
replayState = ReplayState::SAVE;
}
void ReplayFlushBlob(std::vector<u8> *data) {
void ReplayFlushBlob(std::vector<uint8_t> *data) {
size_t sz = replayItems.size() * sizeof(ReplayItemHeader);
// Add in any side data.
for (const auto &item : replayItems) {
@ -289,7 +289,7 @@ bool ReplayFlushFile(const Path &filename) {
size_t c = replayItems.size();
if (success && c != 0) {
// TODO: Maybe stream instead.
std::vector<u8> data;
std::vector<uint8_t> data;
ReplayFlushBlob(&data);
success = fwrite(&data[0], data.size(), 1, fp) == 1;

View File

@ -49,17 +49,17 @@ enum class ReplayAction : uint8_t {
struct PSPFileInfo;
// Replay from data in memory. Does not manipulate base time / RNG state.
void ReplayExecuteBlob(const std::vector<u8> &data);
void ReplayExecuteBlob(const std::vector<uint8_t> &data);
// Replay from data in a file. Returns false if invalid.
bool ReplayExecuteFile(const Path &filename);
// Returns whether there are unexected events to replay.
// Returns whether there are unexecuted events to replay.
bool ReplayHasMoreEvents();
// Begin recording. If currently executing, discards unexecuted events.
void ReplayBeginSave();
// Flush buffered events to memory. Continues recording (next call will receive new events only.)
// No header is flushed with this operation - don't mix with ReplayFlushFile().
void ReplayFlushBlob(std::vector<u8> *data);
void ReplayFlushBlob(std::vector<uint8_t> *data);
// Flush buffered events to file. Continues recording (next call will receive new events only.)
// Do not call with a different filename before ReplayAbort().
bool ReplayFlushFile(const Path &filename);

View File

@ -405,6 +405,7 @@
<ClInclude Include="..\..\Core\Debugger\WebSocket\LogBroadcaster.h" />
<ClInclude Include="..\..\Core\Debugger\WebSocket\MemorySubscriber.h" />
<ClInclude Include="..\..\Core\Debugger\WebSocket\MemoryInfoSubscriber.h" />
<ClInclude Include="..\..\Core\Debugger\WebSocket\ReplaySubscriber.h" />
<ClInclude Include="..\..\Core\Debugger\WebSocket\SteppingBroadcaster.h" />
<ClInclude Include="..\..\Core\Debugger\WebSocket\SteppingSubscriber.h" />
<ClInclude Include="..\..\Core\Debugger\WebSocket\WebSocketUtils.h" />
@ -636,6 +637,7 @@
<ClCompile Include="..\..\Core\Debugger\WebSocket\LogBroadcaster.cpp" />
<ClCompile Include="..\..\Core\Debugger\WebSocket\MemorySubscriber.cpp" />
<ClCompile Include="..\..\Core\Debugger\WebSocket\MemoryInfoSubscriber.cpp" />
<ClCompile Include="..\..\Core\Debugger\WebSocket\ReplaySubscriber.cpp" />
<ClCompile Include="..\..\Core\Debugger\WebSocket\SteppingBroadcaster.cpp" />
<ClCompile Include="..\..\Core\Debugger\WebSocket\SteppingSubscriber.cpp" />
<ClCompile Include="..\..\Core\Debugger\WebSocket\WebSocketUtils.cpp" />

View File

@ -700,6 +700,9 @@
<ClCompile Include="..\..\Core\Debugger\WebSocket\MemoryInfoSubscriber.cpp">
<Filter>Debugger\WebSocket</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\Debugger\WebSocket\ReplaySubscriber.cpp">
<Filter>Debugger\WebSocket</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\Debugger\WebSocket\SteppingBroadcaster.cpp">
<Filter>Debugger\WebSocket</Filter>
</ClCompile>
@ -1701,6 +1704,9 @@
<ClInclude Include="..\..\Core\Debugger\WebSocket\MemoryInfoSubscriber.h">
<Filter>Debugger\WebSocket</Filter>
</ClInclude>
<ClInclude Include="..\..\Core\Debugger\WebSocket\ReplaySubscriber.h">
<Filter>Debugger\WebSocket</Filter>
</ClInclude>
<ClInclude Include="..\..\Core\Debugger\WebSocket\SteppingBroadcaster.h">
<Filter>Debugger\WebSocket</Filter>
</ClInclude>

View File

@ -422,6 +422,7 @@ EXEC_AND_LIB_FILES := \
$(SRC)/Core/Debugger/WebSocket/LogBroadcaster.cpp \
$(SRC)/Core/Debugger/WebSocket/MemorySubscriber.cpp \
$(SRC)/Core/Debugger/WebSocket/MemoryInfoSubscriber.cpp \
$(SRC)/Core/Debugger/WebSocket/ReplaySubscriber.cpp \
$(SRC)/Core/Debugger/WebSocket/SteppingBroadcaster.cpp \
$(SRC)/Core/Debugger/WebSocket/SteppingSubscriber.cpp \
$(SRC)/Core/Debugger/WebSocket/WebSocketUtils.cpp \