diff --git a/CMakeLists.txt b/CMakeLists.txt index f4661a6d8d..8dc0498dd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 68e918a7f0..ececc51b5f 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -525,6 +525,7 @@ + @@ -1076,6 +1077,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index c6a59d5d51..43a36fa022 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1172,6 +1172,9 @@ Ext\libzip + + Debugger\WebSocket + @@ -1886,6 +1889,9 @@ Ext\libzip + + Debugger\WebSocket + diff --git a/Core/Debugger/WebSocket.cpp b/Core/Debugger/WebSocket.cpp index f3f83254af..3d85f4b6fd 100644 --- a/Core/Debugger/WebSocket.cpp +++ b/Core/Debugger/WebSocket.cpp @@ -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 subscribers({ &WebSocketInputInit, &WebSocketMemoryInfoInit, &WebSocketMemoryInit, + &WebSocketReplayInit, &WebSocketSteppingInit, }); diff --git a/Core/Debugger/WebSocket/ReplaySubscriber.cpp b/Core/Debugger/WebSocket/ReplaySubscriber.cpp new file mode 100644 index 0000000000..3a33f90b38 --- /dev/null +++ b/Core/Debugger/WebSocket/ReplaySubscriber.cpp @@ -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 +} diff --git a/Core/Debugger/WebSocket/ReplaySubscriber.h b/Core/Debugger/WebSocket/ReplaySubscriber.h new file mode 100644 index 0000000000..901e54f60e --- /dev/null +++ b/Core/Debugger/WebSocket/ReplaySubscriber.h @@ -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); diff --git a/Core/Replay.cpp b/Core/Replay.cpp index 93b0968c25..bac97e2835 100644 --- a/Core/Replay.cpp +++ b/Core/Replay.cpp @@ -116,7 +116,7 @@ struct ReplayFileInfo { struct ReplayItem { ReplayItemHeader info; - std::vector data; + std::vector 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 &data) { +void ReplayExecuteBlob(const std::vector &data) { ReplayAbort(); // Rough estimate. @@ -178,7 +178,7 @@ bool ReplayExecuteFile(const Path &filename) { return false; } - std::vector data; + std::vector 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 *data) { +void ReplayFlushBlob(std::vector *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 data; + std::vector data; ReplayFlushBlob(&data); success = fwrite(&data[0], data.size(), 1, fp) == 1; diff --git a/Core/Replay.h b/Core/Replay.h index 2229a6dee8..3035330812 100644 --- a/Core/Replay.h +++ b/Core/Replay.h @@ -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 &data); +void ReplayExecuteBlob(const std::vector &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 *data); +void ReplayFlushBlob(std::vector *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); diff --git a/UWP/CoreUWP/CoreUWP.vcxproj b/UWP/CoreUWP/CoreUWP.vcxproj index bd5f53edeb..f3f026c4d6 100644 --- a/UWP/CoreUWP/CoreUWP.vcxproj +++ b/UWP/CoreUWP/CoreUWP.vcxproj @@ -405,6 +405,7 @@ + @@ -636,6 +637,7 @@ + diff --git a/UWP/CoreUWP/CoreUWP.vcxproj.filters b/UWP/CoreUWP/CoreUWP.vcxproj.filters index 7d70fe9b42..89b790f3c4 100644 --- a/UWP/CoreUWP/CoreUWP.vcxproj.filters +++ b/UWP/CoreUWP/CoreUWP.vcxproj.filters @@ -700,6 +700,9 @@ Debugger\WebSocket + + Debugger\WebSocket + Debugger\WebSocket @@ -1701,6 +1704,9 @@ Debugger\WebSocket + + Debugger\WebSocket + Debugger\WebSocket diff --git a/android/jni/Android.mk b/android/jni/Android.mk index d699a76b80..1f0b6efd83 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -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 \