mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Add some easy ways to get into the web debugger
This commit is contained in:
1 parent
4d94022af1
commit
0ed1f3eceb
4 files changed
+39
-6
No files matched your search
@@ -128,11 +128,13 @@ static void SetupDebuggerLock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HandleDebuggerRequest(const http::ServerRequest &request) {
|
void HandleDebuggerRequest(const http::ServerRequest &request) {
|
||||||
net::WebSocketServer *ws = net::WebSocketServer::CreateAsUpgrade(request, "debugger.ppsspp.org");
|
|
||||||
if (!ws)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SetCurrentThreadName("WebSocketDebugger");
|
SetCurrentThreadName("WebSocketDebugger");
|
||||||
|
|
||||||
|
net::WebSocketServer *ws = net::WebSocketServer::CreateAsUpgrade(request, "debugger.ppsspp.org");
|
||||||
|
if (!ws) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateConnected(1);
|
UpdateConnected(1);
|
||||||
SetupDebuggerLock();
|
SetupDebuggerLock();
|
||||||
|
|
||||||
@@ -188,7 +190,10 @@ void HandleDebuggerRequest(const http::ServerRequest &request) {
|
|||||||
ws->Send(DebuggerErrorEvent("Bad message: binary WebSocket frames are not supported", LogLevel::LERROR));
|
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);
|
std::lock_guard<std::mutex> guard(lifecycleLock);
|
||||||
// These send events that aren't just responses to requests
|
// These send events that aren't just responses to requests
|
||||||
|
|
||||||
@@ -212,6 +217,7 @@ void HandleDebuggerRequest(const http::ServerRequest &request) {
|
|||||||
if (stopRequested) {
|
if (stopRequested) {
|
||||||
ws->Close(net::WebSocketClose::GOING_AWAY);
|
ws->Close(net::WebSocketClose::GOING_AWAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highActivity > 0) {
|
if (highActivity > 0) {
|
||||||
highActivity--;
|
highActivity--;
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-1
@@ -38,8 +38,8 @@
|
|||||||
#include "Core/Util/RecentFiles.h"
|
#include "Core/Util/RecentFiles.h"
|
||||||
#include "Core/Util/PathUtil.h"
|
#include "Core/Util/PathUtil.h"
|
||||||
#include "Core/Config.h"
|
#include "Core/Config.h"
|
||||||
#include "Core/Debugger/WebSocket.h"
|
|
||||||
#include "Core/WebServer.h"
|
#include "Core/WebServer.h"
|
||||||
|
#include "Core/Debugger/WebSocket.h"
|
||||||
|
|
||||||
enum class ServerStatus {
|
enum class ServerStatus {
|
||||||
STOPPED,
|
STOPPED,
|
||||||
@@ -760,6 +760,17 @@ void WebServerSetUploadPath(const Path &path) {
|
|||||||
g_uploadPath = 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() {
|
static void WebServerThread() {
|
||||||
SetCurrentThreadName("HTTPServer");
|
SetCurrentThreadName("HTTPServer");
|
||||||
|
|
||||||
@@ -787,6 +798,14 @@ static void WebServerThread() {
|
|||||||
double lastRegister = time_now_d();
|
double lastRegister = time_now_d();
|
||||||
|
|
||||||
INFO_LOG(Log::HTTP, "Entering web server loop. Listening on port %d", g_Config.iRemoteISOPort);
|
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) {
|
while (RetrieveStatus() == ServerStatus::RUNNING) {
|
||||||
constexpr double webServerSliceSeconds = 0.2f;
|
constexpr double webServerSliceSeconds = 0.2f;
|
||||||
http->RunSlice(webServerSliceSeconds);
|
http->RunSlice(webServerSliceSeconds);
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ bool RemoteISOFileSupported(const std::string &filename);
|
|||||||
void WebServerSetUploadPath(const Path &path);
|
void WebServerSetUploadPath(const Path &path);
|
||||||
int WebServerPort();
|
int WebServerPort();
|
||||||
|
|
||||||
|
// Will start the webserver if not running.
|
||||||
|
void OpenWebDebugger();
|
||||||
|
|
||||||
struct UploadProgress {
|
struct UploadProgress {
|
||||||
s64 totalBytes = 0;
|
s64 totalBytes = 0;
|
||||||
s64 uploadedBytes = 0;
|
s64 uploadedBytes = 0;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "Core/Config.h"
|
#include "Core/Config.h"
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Core/SaveState.h"
|
#include "Core/SaveState.h"
|
||||||
|
#include "Core/WebServer.h"
|
||||||
#include "Core/Debugger/MemBlockInfo.h"
|
#include "Core/Debugger/MemBlockInfo.h"
|
||||||
#include "Core/RetroAchievements.h"
|
#include "Core/RetroAchievements.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
@@ -2392,6 +2393,10 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUCommon *gpuDebug, Draw:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
if (ImGui::MenuItem("Open web debugger")) {
|
||||||
|
OpenWebDebugger();
|
||||||
|
}
|
||||||
|
ImGui::Separator();
|
||||||
if (ImGui::MenuItem("Exit")) {
|
if (ImGui::MenuItem("Exit")) {
|
||||||
System_ExitApp();
|
System_ExitApp();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user