Commit Graph
47 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5 3273e8081e Push game and stepping events from the CPU thread instead of polling for them
GameBroadcaster and SteppingBroadcaster ran per connection on the WebSocket
thread, so every connected debugger was reading pc, the tick count, coreState,
the UI state and the param SFO out from under the CPU thread on every lap of its
loop - up to 1000 times a second in high-activity mode.

Inverted: the CPU thread notices the transition once in WebSocketDebuggerTick(),
formats the event there, and drops it into a per-connection mailbox that the
connection's own thread drains and sends. Same events, same conditions, no core
reads off the CPU thread, and no per-connection polling of emulator state.

The tick hangs off Core_ProcessCPUQueue(), the one function reliably called on
the CPU thread both in game (Core_RunLoopUntil) and at the menu (NativeFrame).
It polls even with nothing connected, since skipping would let the "previous
state" go stale and fire a bogus event at whoever connects next.

Behavior preserved including the awkward bit: a debugger that connects while the
CPU is already stopped still gets an immediate cpu.stepping, which used to fall
out of SteppingBroadcaster's counter starting at 0. That's now an explicit
per-connection prime instead of an accident.

Part of removing the WebSocket debugger's lifecycleLock.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-17 13:11:16 +02:00
Henrik RydgårdandClaude Opus 5 707275b46a Fix deadlock when stopping a game with a debugger request in flight
The WebSocket thread holds lifecycleLock across a whole event handler, and
handlers do their real work through Core_RunOnCPUThread(), which blocks until
the CPU thread drains the queue. Meanwhile PSP_Shutdown() ->
Core_NotifyLifecycle(STOPPING) took that same lock on the CPU thread. So the
debugger thread waited for the CPU thread while the CPU thread waited for the
lock the debugger thread was holding, and neither ever moved.

Drain the CPU queue while waiting for the lock instead of blocking on it. Core
state is still alive at STOPPING (it's notified before CPU_Shutdown), so running
those queued callbacks then is safe, and it lets the debugger thread finish and
release the lock.

Verified with a temporary instrumented build - a 3s sleep inside a handler while
holding lifecycleLock, arranged to overlap the game's shutdown - which hangs
reliably on the old code and exits cleanly with this change.

lifecycleLock stays for now: roughly half the subscribers and all the
broadcasters still read core state directly on the WebSocket thread instead of
going through the queue, and this is what keeps that from racing with teardown.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-17 00:34:01 +02:00
Henrik RydgårdandClaude Sonnet 5 2ee4f2fadb Debugger: add gpu.displaylist.disasm - a GE display list decoder over the WebSocket API
Decoding a GE display list previously meant memory.read-ing the raw bytes
and hand-decoding each 32-bit command word against GPU/ge_constants.h's
GECommand enum - which is exactly what it took to find this session's
actual headline VSH boot finding (a display list that clears the screen
once, sets up per-icon render state 6 times, and never issues a single
further draw call - see docs/VSHBootInvestigation.md Attempt 22). That
manual process is real, repeatable, and error-prone by hand; PPSSPP
already has a proper GE disassembler (GPU/GeDisasm.cpp's
GeDisassembleOp(), and GPUCommon::DisassembleOpRange() built on top of
it) used by the ImGui/Windows GE debugger UI - it just wasn't reachable
from the WebSocket API.

New Core/Debugger/WebSocket/GPUDisasmSubscriber.cpp exposes
gpu->DisassembleOpRange() as gpu.displaylist.disasm, mirroring
memory.disasm's own parameter conventions (address+count or
address+end, capped at 10000 commands) and compact mode (one string per
command, "AAAAAAAA  desc", instead of the full {address,cmd,op,desc}
object) added in the previous commit. GE command words live in normal
guest RAM like CPU code, so - unlike gpu.buffer.* - this doesn't require
the CPU/GPU to be paused first, matching memory.disasm's own live-read
behavior.

Added to all 6 build systems that compile the WebSocket debugger
(CMakeLists.txt, Core.vcxproj(.filters), UWP's CoreUWP.vcxproj(.filters),
android/jni/Android.mk - libretro doesn't build any Debugger/WebSocket
files at all, so nothing to add there).

Verified live via PPSSPPHeadless + wsdbg against a real demo ELF: both
compact and full-JSON modes correctly decode real GE command words (NOP/
NOP_FF) with no errors. UnitTest.exe all: 49/49 passed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-14 11:04:32 +02:00
Henrik Rydgård 0ed1f3eceb Add some easy ways to get into the web debugger 2026-08-08 10:13:09 +02:00
Henrik Rydgård 18ccef1bd4 Just some minor code modernization 2025-08-25 10:45:12 +02:00
Nemoumbra 846c265972 Fixed the docs + better wording 2025-08-10 17:44:38 +03:00
Henrik Rydgård 088a02bfdb Cleanup a lot of the bootup state management. 2025-03-30 14:02:29 +02:00
Henrik Rydgård 45cf6d423e Buildfixes 2024-12-18 13:57:29 +01:00
Henrik Rydgård 3e198c53b2 More include cleanup 2024-12-18 13:57:26 +01:00
Henrik Rydgård e01ca5b057 Logging API change (refactor) (#19324)
* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
2024-07-14 14:42:59 +02:00
Henrik Rydgård 9253bf9cb5 Add a new screen for managing installed Adreno drivers 2024-01-17 10:51:08 +01:00
Henrik Rydgård 1025bbcf89 Log level/type: Use enum class instead of the awkward namespace trick.
Just a small cleanup I've wanted to do for a long time.
2023-08-25 11:48:59 +02:00
Henrik Rydgård 93bb113009 Common: Rename Download to Request, and the old Request to ServerRequest. 2023-07-21 22:12:00 +02:00
Nemoumbra 3fbaea3b9a Allowed -> disallowed, at -> [], code cleanup 2023-06-05 21:51:13 +03:00
Nemoumbra af8480683a Config initialization moved to HandleDebuggerRequest 2023-06-01 17:12:22 +03:00
Nemoumbra 311687a673 ClientConfigSubscriber added 2023-05-31 19:17:43 +03:00
Nemoumbra 7f0828c659 Added WebsocketClientInfo 2023-05-27 17:59:45 +03:00
Unknown W. Brackets 753ac95307 Debugger: Fix game.reset by adding a reboot status.
We don't want EmuScreen to auto-exit, and we don't want to double-lock the
debugger lifecycle lock.  Let's just handle reboot specifically.
2022-10-01 18:13:22 -07:00
Unknown W. Brackets ce3b80dcea Debugger: Add initial GPU stats shell. 2021-10-19 10:01:40 -07:00
Unknown W. Brackets 64e007c0ce Debugger: Add stub API for replay functionality. 2021-05-29 14:50:57 -07:00
Henrik Rydgård f4a6d291e1 Common: Capitalize setCurrentThreadName(). 2021-04-30 23:02:36 -07:00
Unknown W. Brackets 7a1398844a Debugger: Add simple API to control tagging detail.
In case a client requires it.
2021-04-04 20:23:51 -07:00
Unknown W. Brackets f97df5d153 Debugger: Broadcast ctrl input events.
This can be useful to trigger debugging functionality on button press.
2021-01-18 18:14:48 -08:00
Unknown W. Brackets de3277c679 Debugger: Add API to trigger buttons. 2021-01-18 16:58:34 -08:00
Unknown W. Brackets 589d83d4da http: Prevent assert on bad websocket data. 2020-12-28 09:30:36 -08:00
Henrik Rydgård 15382d5f94 Move threading utils from native to Common 2020-10-01 09:27:25 +02:00
parport0 fd62d30773 Debugger: Add memory.read_*, memory write_* 2020-07-26 01:18:16 +03:00
Unknown W. Brackets 653129c528 Debugger: Add an event for GE dump recording. 2018-09-01 10:59:37 -07:00
Unknown W. Brackets 4ce2b64ef7 Debugger: Refactor to allow simpler broadcasting.
It's okay to mix a bit for simple ones, I think.
2018-09-01 10:15:22 -07:00
Unknown W. Brackets e6917cccf6 Debugger: Add APIs to retrieve render image. 2018-06-16 15:33:02 -07:00
Unknown W. Brackets 5bfba9b284 Debugger: Add HLE API funcs.
Lumping function symbols in here too, they're pretty related...
2018-06-08 06:59:18 -07:00
Unknown W. Brackets 3193772e78 Debugger: Use a lock for memory reallocs.
Simpler this way, no need to remember to lock memory.
2018-06-08 06:59:18 -07:00
Unknown W. Brackets 29d93c56c7 Debugger: Initial breakpoint APIs. 2018-06-08 06:59:18 -07:00
Unknown W. Brackets 2f3b6c19d0 Debugger: Poll frequently after stepping.
This will make us listen for events slightly less often, so we don't want
to sustain it.
2018-06-08 06:59:17 -07:00
Unknown W. Brackets e746a2d106 Debugger: Add stepping to WebSocket API. 2018-06-08 06:59:17 -07:00
Unknown W. Brackets 944948a5f4 Debugger: Initial disasm API. 2018-06-08 06:59:17 -07:00
Unknown W. Brackets 4da97b3f9e Debugger: Lock during startup/shutdown.
Otherwise things can get freed while we're trying to inspect them.
2018-06-08 06:59:17 -07:00
Unknown W. Brackets b756d92139 Debugger: Add version event for future proofing.
Game isn't precisely right, but it's close enough.
2018-06-08 06:59:17 -07:00
Unknown W. Brackets 3dac5f2103 Debugger: Add current game info. 2018-06-08 06:59:17 -07:00
Unknown W. Brackets 6bec3db3fb Debugger: Disconnect on shutdown/disable.
Although, it could be made safe to keep them up when restarting with
debugging still enabled.
2018-06-08 06:59:16 -07:00
Unknown W. Brackets c44d8dbe2d Debugger: Name the WebSocket debugger thread. 2018-06-08 06:59:16 -07:00
Unknown W. Brackets a4044fd6a0 Debugger: Reorganize state handling.
Looking like this will be needed for disasm caches, etc.
2018-06-08 06:59:16 -07:00
Unknown W. Brackets be3b50dd74 Debugger: Improve JSON number parsing.
With gason, this becomes doable without overflow issues.
2018-06-08 06:59:16 -07:00
Unknown W. Brackets 1f987bf1c1 Debugger: Initial register get/set APIs. 2018-06-08 06:59:16 -07:00
Unknown W. Brackets 123723286d Debugger: Synchronize error events using tickets. 2018-06-08 06:59:16 -07:00
Unknown W. Brackets b37d59e8fa Debugger: Organize WebSocket event handling.
Just a starting point to organize it.  Trying to keep it simple.
2018-06-08 06:59:16 -07:00
Unknown W. Brackets c2b9b5a9e8 Debugger: Serve a simple log listener WebSocket.
Planning to add more functionality to it, and sharing the reporting port
is possibly not ideal - although it would make discovery easier.
2018-06-08 06:59:16 -07:00