mirror of
https://github.com/libretro/virtualjaguar-libretro.git
synced 2026-11-10 17:28:58 -10:00
dependabot/github_actions/develop/actions/setup-python-7
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
85cd3f1642 |
feat(app): debugger halt and GDB stub with the emulation thread on (#967 phase 3b) (#1068)
* feat(app): bounded halt pump on DebugCore; the UI mirrors the halt DebugCore owns the halt: pump() serves the debug lane, waits at most kPumpWait (4 ms) on a debug-lane-only wait and returns VJ_DBG_RESUME_NONE to GDBHalt's own loop, which keeps the socket service and the halt timeout. The UI writes its verdict tagged with the halt serial it saw, so a verdict for a dead halt never resumes the next one; frameEnded() closes a halt the core left on gdb's say-so. DebugSession mirrors HaltState once per UI frame (syncHalt) and fires onHaltUi / onResumeUi on serial edges; attach/detach/breakNow are ordered through the lane and a pending detach. Inline keeps the nested UI frame. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): a STEP the core never re-halts must not leave the UI mirror halted pump() returns STEP without bumping the halt serial, so the bar stays up while the core steps. If the frame ends before the core re-halts (the stepped instruction ended it, or the target had stopped), frameEnded() found nothing halted and the mirror stayed halted for good; inline, stepEmulation() is gated on halted(), so the frame that would re-halt never ran and F9 / Detach wrote verdicts nothing took. DebugCore now remembers a STEP in flight (cleared by the next halt entry or setIface) and frameEnded() closes it like a foreign resume. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): verdicts and detach only against the core's live halt After a STEP verdict the halt serial is unchanged but the core is running until it re-halts, so DebugSession::detach() offered a DETACH for a serial the re-halt then dropped, left detachPending_ set (attach / Break refused) and, with hardcore turning on in that window, left the core attached. resume / step / detachAndResume now require the core's halt to be live (parked, same serial); detach and detachAndResume fall back to the lane detach otherwise, and that post also releases the pump if it runs inside a live halt. haltedFrame() syncs the mirror first so the first nested frame meets the current halt; the inline resume hook keeps headless audio unpaused as before. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(app): the emulation thread pumps the halt; quitting ends it Threaded, the pump's wait is App::haltWait (serve the debug lane for at most 4 ms, refill the views when a request is pending); frameEnded() runs after every retro_run so a halt gdb ended is closed on our side (inline: from syncDebug outside a frame). beginQuit() sets quitting_, wakes the pump and waits at most 200 ms for the detach the pump answers with, before the auto-save, the SRAM flush and the 3 s unload; closing the window inside an inline halt takes the same path. haltedFrame runs only inline. The halt bar says "HALTED by gdb" for a halt the app did not ask for; a halt at the CPU window's own temporary breakpoint (run to cursor, step over) is ours (DebugSession::ownsBreakAt). Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(app): calls and frame advances give up when a halt begins; content changes detach first EmuThread::call and advance take a give-up predicate: a call queued behind a frame that halts returns instead of parking the UI behind the busy spinner; advance registers its budget on the debug lane and waits with the same predicate. Every UI-thread call passes one (App::emuCall). Threaded, open / close / reset / disc detach the debugger first and then proceed; save / load state and boot refuse with a toast; frame-lane posts wait for Continue and the halt bar and the Core options tab say so. Inline keeps refusing (the call would run inside retro_run). RetroAchievements replies ride the debug lane, so none is ever cancelled. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): a given-up disc follow-up retries; close reports a re-halt; deterministic give-up and re-drain tests followDiscSwap advances seenDiscSwaps_ only when its call ran, so a halt no longer loses the RA / cheats follow-up. closeContent says so when its detach predicate gave up. The netplay headless step stops re-budgeting a frame whose advance gave up. testCallGiveUpLosesToStart covers the compare-and-swap-lost branch of call(), and testAdvanceBudgetDoesNotOvertakeFramePost covers the loop's second frame-lane drain; the 300-iteration smoke loop is gone. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(app): the halt and the GDB stub work on the emulation thread; a silent host behind every halt; hardcore locks the stub The phase 1 limits are gone: Break / Step / breakpoints work threaded and virtualjaguar_gdb_stub is a plain option again. Whenever the stub is enabled the app attaches its host on the emulation thread inside the load (before the first frame, so a gdb_wait boot halt is seen) and again after any frame it is missing, so every gdb halt flows through the app's pump: the halt bar shows it, calls give up, quitting detaches. RetroAchievements hardcore locks the stub to disabled at load, and a hardcore flip with the stub open reloads the game so the lock reaches the core (phase 3 plan, decisions 2 and 3). Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): B4 review: pre-frame silent host, gdb halts survive headless inline, Detach clears breakpoints - emuRunOneFrame re-attaches the silent gdb host before the frame, so a gdb halt right after a Detach is hosted - headless inline haltedFrame releases only app halts and quit; gdb's halt keeps the core's socket loop serving - Detach drops the session breakpoint list with the core's table - Settings > Emulation thread hint reflects that the halt and stub work threaded - locked-option warning is generic; a hardcore restart waits out an inline halt Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(app): the halt and the GDB stub end to end on the emulation thread debug_e2e_threaded drives break / step / continue / detach / hardcore / quit from a UI thread that never blocks over 50 ms, pins the option post that applies after Continue, the save state that gives up when a halt begins, a posted lane detach run inside a live halt, the 3 s join, and a gdb_wait boot halt with no client (Detach, quit). gdb_threaded_halt finds a headless run halted at boot from a gdb client, reads memory, continues, and quits the app mid-halt, threaded and inline, plus an inline hardcore variant: SIGINT / SIGTERM end a headless run cleanly (installed after SDL_Init, headless only). The headless inline loop now closes a gdb halt after each frame (frameEnded + syncHalt), without which the hardcore reload retry stays blocked. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): B5 review: the cancelled save is proven absent after frames run; free ports; signal handler resets debug_e2e_threaded waits for frames after the halt ends before asserting the cancelled save left no file (it is held while halted, so the old check was vacuous) and saves to a different file; the gdb_wait sections probe a free port; the test also fails on ThreadSanitizer. The signal handler restores SIG_DFL after storing the flag (a second signal kills a wedged run) and g_signalQuit is asserted lock-free. gdb_threaded_halt.py's watchdog kills live children; a missing Python3 is reported at configure time. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(app): the halt and the GDB stub on the emulation thread Halt model, Detach, hardcore lock and reload, gdb_wait, headless signal quit, testing; README, testing.md, design section 6 (2026-10-22 as-shipped notes), plan 3b task list. Includes the MSVC fix: debug_e2e_threaded includes <ws2tcpip.h> for socklen_t. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): quitting while a gdb client holds a halt no longer hangs The pump answered a quit with DETACH, which drops the app's host inside the core. A gdb client's breakpoint that is still armed (a hot loop) then fires again at once, with the socket open and no host: the core parks in GDBHalt() for the client, and the quit's flush, autosave and unload wait on it forever. The pump now answers CONTINUE and the host stays attached (unloading drops it). Every wait in the quit epilogue is bounded (flush 1 s, autosave 1.5 s, skipped while the core is still halted); the unload keeps its 3 s backstop. Also: re-attach the silent gdb host before each frame (inline stepEmulation, headless inline loops), comment/doc fixes, EmuThread::stop precondition, and the three gdb tests' PASS regexes lose their ^ anchor. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): a hardcore restart that gives up stays pending and retries Achievements::pump cleared resetPending_ before the restart and ignored its result. Threaded, the restart can give up when the core halts again (a gdb client with a breakpoint still armed): hardcore was then active without a clean restart and the open GDB stub bypassed the hardcore lock. The restart now stays pending until it takes. reset() returns whether it ran. A give-up with the game still loaded (and, for the reload, the stub still open) retries at the next pump; a restart that failed to load the game, or closed the stub, is dropped. The cheat reset is posted once and the restart is counted once (--ra-expect-reset), the give-up is logged once. Tests: VJ_TEST_RESTART_GIVEUPS=N makes the first N restarts report a give-up (a headless run cannot stage the re-halt); gdb_hardcore_flip_giveup_* (reload path) and ra_hardcore_reset_giveup_* (reset path), inline and threaded. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): a signalled threaded --neuro headless run still prints the Neuro report The signal-quit block returns before the TIMING/report section; report first (it only touches UI-thread state) so a SIGTERM'd --neuro run behaves like a finished one. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(app): gdb_* tests take their port from the OS at run time (#967) The six tests with hard-coded ports 23457-23463 (gdb_enabled, gdb_enabled_threaded, gdb_hardcore_flip_*, gdb_hardcore_flip_giveup_*) all failed on the hosted Windows ARM64 runner with 'failed to open port': every one of the distinct ports was refused, which points at a reserved/excluded range, not a collision (the Python gdb tests, which already pick a free port, passed there). tests/with_free_port.py binds 127.0.0.1:0, reads the port back, substitutes {PORT} in the command and, with --config-ini, writes the saved stub setting for the hardcore tests. The assertions and ctest regexes are unchanged. Registered only with Python3 (STATUS message otherwise). RESOURCE_LOCK vj_gdb_port on every test that binds a stub port closes the bind-0 TOCTOU window. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): start Winsock before the core loads so the GDB stub can bind on Windows (#967) Every gdb_* test that opens the stub failed on hosted Windows x64 with "[GDB] stub enabled but failed to open port N", on fixed and on OS-chosen free ports alike. The core's GDBSockOpen (src/debug/gdbsock.c) calls socket() without WSAStartup, because its libretro host (RetroArch) starts Winsock. The app never did on that path (neuro and netplay only start it for themselves), so socket() failed with WSANOTINITIALISED and the stub stayed disabled. The feature was therefore broken for users on Windows too, not only in tests. platform::initNetworking() now runs WSAStartup once, right after SDL_Init and before any core load, headless runs included. A no-op on macOS and Linux. Winsock is reference counted, so neuro's and netplay's own WSAStartup stay harmless. Also corrects the comments that blamed reserved port ranges. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(app): with_free_port.py hands the app explicit stdout/stderr (#967) The Packages / Windows x64 job builds the GUI-subsystem exe (VJ_APP_WIN32_GUI). There, gdb_enabled, gdb_enabled_threaded and the gdb_hardcore_flip* tests missed their PASS regexes. Popen(cmd) left the child's standard handles to inheritance, so Windows started the GUI-subsystem app with no stdout. console_attach.cpp then attached the runner's console, and the output never reached ctest's pipe. The wrapper now passes stdin=DEVNULL and stdout/stderr explicitly, so the output stays on the pipe. Tests that ctest launches directly already get redirected handles and were unaffected. Refs #1075 Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: dry <dry@x> |
||
|
|
5d0afd4b37 |
feat(app): Tools windows work with the emulation thread on (#967 phase 3a) (#1061)
* feat(app): a debug lane in the emulation thread's command queue (#967) EmuCommands gets Lane::Debug beside the frame lane; the loop drains both at each frame boundary. EmuThread::debugCall / debugPost are safe inside retro_run() once the halt pump serves the lane (phase 3b). Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(app): DebugViews, per-window requests the emulation thread fills (#967) A request table with a double buffer per request: the UI sets and reads, the emulation thread (inline: the same thread) fills after each frame. A changed request or a content switch invalidates its buffer; no lock is held across a core call. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(app): DebugCore owns the debug interface; DebugSession marshals to it (#967) DebugCore wraps every vj_debug_iface entry point (emulation thread only); DebugSession routes each action through coreCall/corePost, which run inline until App wires them to the debug lane. setHaltAvailable gates attach, Break and breakpoints so a threaded run can keep the windows and refuse the halt. Inline behaviour is unchanged. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(app): Memory viewer and Palette read published view buffers (#967) The Memory grid, its selection footer and the Palette ask the view copier for their bytes and draw the published buffers; a content switch (DebugViews epoch) resets them. SearchJob::step and the CRY table each take one callCore. Adds the shared counting test fixture (debug_ui_fixture.h) and the debug_no_direct_iface static guard that the other tool windows reuse. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): resized Memory window adopts its wider buffer; guard catches core() calls (#967) fetchWindow compared only serial and start address when deciding a buffer was already adopted, so a paused window that grew (bytes-per-row change at the region top) kept the shorter window. It now compares size too. CheckNoDirectIface also rejects the session's DebugCore wrappers (s.core().peek( and friends). The smoke test pins the resize case and asserts the Palette really adopted a changed CLUT byte. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(app): CPU debugger reads Regs and Disasm view buffers (#967) Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): CPU walks drop stale answers; rows re-adopt on every answer (#967) Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(app): Object list reads the OpSnapshot request; step-a-frame via advance(1) (#967) Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): Object list step bumps the serial after the frame; release posts the clear (#967) Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(app): Blitter log and Textures through view buffers and core calls (#967) Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(app): Cheat scanner on the Dram request; Audio scope available with the thread on (#967) The scan pass is one DebugSession::snapshotDram (callCore: the 2 MiB peek runs on the emulation side); the live column reads a published Dram request and copies the buffer only when a newer fill exists. The raw memoryRegion path is gone. The scope gets a framesSeen test hook and a threaded-audio gate test. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): Cheat scanner shows -- until a value was read; new rows carry the scan's own values (#967) Per-row known flag: cleared on a new result list, release and an epoch change; edit prefill and Add as cheat refuse a row with no value. doScan derives the rows from the RAM image it just read, not the older published buffer. Tests: search before the first answer, stale held buffer, collapsed window, unreadable core. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(app): the Tools windows work with the emulation thread on (#967) The App fills the debug views after each emulated frame (and on the UI thread inline), wires DebugSession to the debug lane, hands the core's interface over again and narrows the thread gate to "halt not available": Break, Step, breakpoints and the GDB stub stay off until phase 3b. --show-window opens a tool threaded. DebugSession::iface()/setThreadBlocked() are gone. debug_views_threaded runs the real core on the emulation thread with the session wired as App wires it. Final-review fixes folded in: - "Step a frame" refuses while the debugger is attached in the threaded case too, because advance() has no give-up. - The scanner's live column waits on its own buffer (DebugViews::serialOf) instead of on any pending view. - The -emu.csv perf trace gains a trailing fill_ns column that times the debug-view copier. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(app): correct the guard's getter list and the Step-a-frame comments (#967) CheckNoDirectIface.cmake named haltSerial() as a legal core() getter. DebugCore has no haltSerial() yet; it arrives in phase 3b. The op_view.h and op_ui.cpp comments now say that Advance also refuses while the session is attached, because emu.advance() has no give-up. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): a replaced core closes the tools like an unload (#967) Threaded openContent() on a running game publishes null and the new debug interface inside one blocking emu.call(), so the UI's syncCore() saw only the final non-null interface: closeAllTools() was skipped and the cheat scanner kept the old game's candidates, which it could then compare or write against the new game's RAM. syncCore() now closes the tools whenever it replaces a core it had (generation moved, had a core), which is what inline does when it sees null then the new interface. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): every breakpoint control greys out while the halt is unavailable (#967) With the emulation thread on, only the toolbar's Break button was gated: the margin click, the context menu's Set breakpoint and "Add at cursor" still called toggleBreakpoint(), which always refuses without the halt machine and reported the misleading "table is full / not attached" error. All three now share one predicate (canAddBp): the menu item and button grey out with haltDisabledReason() as the tooltip, the margin hover says why, and toggleBp() itself answers with that reason without touching the core. Removing a breakpoint stays allowed. The Break tooltip uses the same reason text. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(app): Tools-window actions wait for the frame in progress (#967) README: with the emulation thread on, an action that reaches the core (a Tools-window edit, a load, a state save) waits for the current frame to end, including link play's bounded peer wait. It does not run immediately. Refs #967 Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> |
||
|
|
78fc634c9a |
feat(app): debug session wiring - Tools menu, nested halt pump, re-entrancy guards
CoreHost announces VJ_CAP_DEBUG, receives the core's debug interface once per session (debugIface(), onDebugIface) and drops it on unload. While the core is parked in retro_run() at a halt (inFrame()), state load/save, reset, load/unload, option changes, controller and disc changes are refused. App::haltedFrame() is the halt pump's nested UI frame (events, ImGui, present, no emulation step); stepEmulation returns while halted; audio is paused on a halt and cleared on resume; hardcore and content loaded sync into the DebugSession each frame. F9 breaks/continues, F10 steps (while halted only: it releases a captured mouse otherwise). The Tools menu lists seven greyed placeholders for the tool windows (Memory, CLUT, Cheat scanner, CPU, Objects, Blitter, Textures) plus Break/Continue/Step/Detach, and a "halted" bar. Tests: debug_session_unit (mock interface), debug_e2e (real core through CoreHost + DebugSession: halt, step, continue, breakpoint, hardcore mid-halt, refusals while parked, reload). Refs #652 Refs #833 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |