Add some easy ways to get into the web debugger

This commit is contained in:
Henrik Rydgård
2026-08-08 10:13:09 +02:00
parent 4d94022af1
commit 0ed1f3eceb
4 changed files with 39 additions and 6 deletions
+11 -5
View File
@@ -128,11 +128,13 @@ static void SetupDebuggerLock() {
}
void HandleDebuggerRequest(const http::ServerRequest &request) {
net::WebSocketServer *ws = net::WebSocketServer::CreateAsUpgrade(request, "debugger.ppsspp.org");
if (!ws)
return;
SetCurrentThreadName("WebSocketDebugger");
net::WebSocketServer *ws = net::WebSocketServer::CreateAsUpgrade(request, "debugger.ppsspp.org");
if (!ws) {
return;
}
UpdateConnected(1);
SetupDebuggerLock();
@@ -188,7 +190,10 @@ void HandleDebuggerRequest(const http::ServerRequest &request) {
ws->Send(DebuggerErrorEvent("Bad message: binary WebSocket frames are not supported", LogLevel::LERROR));
});
while (ws->Process(highActivity ? 1.0f / 1000.0f : 1.0f / 60.0f)) {
// Don't out-line the highActivity check, it needs to recompute on every lap.
constexpr float lowActivityPollTimeStep = 1.0f / 60.0f;
constexpr float highActivityPollTimeStep = 1.0f / 1000.0f;
while (ws->Process(highActivity ? highActivityPollTimeStep : lowActivityPollTimeStep)) {
std::lock_guard<std::mutex> guard(lifecycleLock);
// These send events that aren't just responses to requests
@@ -212,6 +217,7 @@ void HandleDebuggerRequest(const http::ServerRequest &request) {
if (stopRequested) {
ws->Close(net::WebSocketClose::GOING_AWAY);
}
if (highActivity > 0) {
highActivity--;
}
+20 -1
View File
@@ -38,8 +38,8 @@
#include "Core/Util/RecentFiles.h"
#include "Core/Util/PathUtil.h"
#include "Core/Config.h"
#include "Core/Debugger/WebSocket.h"
#include "Core/WebServer.h"
#include "Core/Debugger/WebSocket.h"
enum class ServerStatus {
STOPPED,
@@ -760,6 +760,17 @@ void WebServerSetUploadPath(const Path &path) {
g_uploadPath = path;
}
WebServerFlags GetServerFlags() {
return serverFlags;
}
void OpenWebDebugger() {
if (!WebServerRunning(WebServerFlags::DEBUGGER)) {
StartWebServer(WebServerFlags::DEBUGGER);
}
System_LaunchUrl(LaunchUrlType::BROWSER_URL, "http://localhost:" + std::to_string(g_Config.iRemoteISOPort) + "/debugger/index.html");
}
static void WebServerThread() {
SetCurrentThreadName("HTTPServer");
@@ -787,6 +798,14 @@ static void WebServerThread() {
double lastRegister = time_now_d();
INFO_LOG(Log::HTTP, "Entering web server loop. Listening on port %d", g_Config.iRemoteISOPort);
if (serverFlags & WebServerFlags::DEBUGGER) {
g_OSD.Show(OSDType::MESSAGE_SUCCESS, "Debugger web server running on port " + std::to_string(g_Config.iRemoteISOPort), 5.0f, "debugger");
g_OSD.SetClickCallback("debugger", []() {
OpenWebDebugger();
});
}
while (RetrieveStatus() == ServerStatus::RUNNING) {
constexpr double webServerSliceSeconds = 0.2f;
http->RunSlice(webServerSliceSeconds);
+3
View File
@@ -43,6 +43,9 @@ bool RemoteISOFileSupported(const std::string &filename);
void WebServerSetUploadPath(const Path &path);
int WebServerPort();
// Will start the webserver if not running.
void OpenWebDebugger();
struct UploadProgress {
s64 totalBytes = 0;
s64 uploadedBytes = 0;
+5
View File
@@ -14,6 +14,7 @@
#include "Core/Config.h"
#include "Core/System.h"
#include "Core/SaveState.h"
#include "Core/WebServer.h"
#include "Core/Debugger/MemBlockInfo.h"
#include "Core/RetroAchievements.h"
#include "Core/Core.h"
@@ -2392,6 +2393,10 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUCommon *gpuDebug, Draw:
});
}
ImGui::Separator();
if (ImGui::MenuItem("Open web debugger")) {
OpenWebDebugger();
}
ImGui::Separator();
if (ImGui::MenuItem("Exit")) {
System_ExitApp();
}