diff --git a/Core/WebServer.cpp b/Core/WebServer.cpp index 1b4df8f1ee..7c30f989d2 100644 --- a/Core/WebServer.cpp +++ b/Core/WebServer.cpp @@ -854,9 +854,10 @@ static void WebServerThread() { } } + // Before RUNNING, so WebServerWaitForStartup() callers can read the port. + g_Config.iRemoteISOPort = http->Port(); UpdateStatus(ServerStatus::RUNNING); - g_Config.iRemoteISOPort = http->Port(); RegisterServer(http->Port()); double lastRegister = time_now_d(); diff --git a/Tools/wsdbg/src/main.rs b/Tools/wsdbg/src/main.rs index 8730b7f1dc..daaa1c241c 100644 --- a/Tools/wsdbg/src/main.rs +++ b/Tools/wsdbg/src/main.rs @@ -294,10 +294,10 @@ fn launch_ppsspp(cmd: &[String]) -> Result<(std::process::Child, u16)> { child.kill().ok(); child.wait().ok(); Err(anyhow!( - "PPSSPP never reported a debugger port. It logs that line at NOTICE, so it should \ - survive any --loglevel - but a build predating that change logs it at INFO, where \ - --loglevel=3 hides it. Check the forwarded output above for 'Listening on port'; \ - if it isn't there, either raise --loglevel or pass an explicit --debugger=PORT." + "PPSSPP never reported a debugger port. Headless prints 'Debugger listening on port N' \ + to stderr whenever --debugger=0, with or without --log; other builds (and older \ + headless builds) only log it, so they need --log. Check the forwarded output above, \ + or pass an explicit --debugger=PORT." )) } } diff --git a/headless/Headless.cpp b/headless/Headless.cpp index b7adf0eb9e..06c6177dc4 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -1170,6 +1170,12 @@ int main(int argc, const char* argv[]) { ShutdownWebServer(); return 1; } + // With port 0 the OS picks one, and a client (wsdbg --launch) can only learn it from our + // output. Print it outside the log system so it doesn't depend on --log. + if (cmdLineOptions.DebuggerPort().value() == 0) { + fprintf(stderr, "Debugger listening on port %d\n", WebServerPort()); + fflush(stderr); + } } if (cmdLineOptions.stateToSave.has_value()) {