Repository navigation
Script debugger: step over stops, steps stay in their thread, a caller's variables are read - #785
Closed
ashalkhakov wants to merge 2 commits into
Closed
ashalkhakov wants to merge 2 commits into
ashalkhakov wants to merge 2 commits into
Conversation
…r's variables are read Fixes in the script debugger server and the game's side of it (base and d3xp): - Step over never stopped: GetInterpreterCallStackFunction() with no depth returned callStack[callStackDepth].f, the entry past the top of the call stack, not the function executing, so CheckForBreakPointHit() compared against the wrong function. It now returns the current function. - A step ended when any thread returned from its last function, and step into stopped in whichever thread ran next. A step now remembers the interpreter (thread), line and call depth it began at; only that thread ends it, on another line, so stepping over a call that waits (sys.wait(), an animation) works while the game's other threads run. Breakpoints still stop any thread. - GetRegisterValue() read a caller's locals (and its self) at the current function's stack base; it now uses the frame's own (callStack[i].stackbase). - GetRegisterValue() threw (idTypeDef::SuperClass on a namespace) for a name not found in a namespace's function, which aborted the game; it now only looks through an object's superclasses. - Entities ($name), and object fields that are vectors or entities, are formatted (they were "???"). - A caller's frame in DBMSG_INSPECTCALLSTACK shows the line of the call, not of the statement after it. No change to the protocol or the game API. Tested under Xvfb on the retail data with a debugger client (UDQuakeTools' udscript-dap): a breakpoint in a thread that calls a function that waits, step over across the wait while Mars City's other threads ran, step into, the caller's locals, step out; built with the default options and with IMGUI=OFF. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
dhewm3 doesn't accept LLM-generated code, see also https://github.com/dhewm/dhewm3#contributing or the |
GetRegisterValue() had no case for ev_object, so a method's self (and any variable of an object's type) read "???". An object's register holds the number of the entity it is the script object of, as an entity's does: it is now formatted as the entity ($name). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ashalkhakov
added a commit
to ashalkhakov/UDQuakeTools
that referenced
this pull request
Oct 18, 2026
A method's frame had its fields in a Fields scope of their own, and self (an object, which the game could not print) read "???". Now Locals starts with self, shown as its entity (the game's, with dhewm/dhewm3#785's fix; its object's type with stock dhewm3) and opening to its object's fields and its superclasses', as VS Code shows a method's this; the separate scope is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
@DanielGibson OK, but the debugger is very nice to use with these changes. Do you want me to close this PR and #786? |
ashalkhakov
added a commit
to ashalkhakov/UDQuakeTools
that referenced
this pull request
Oct 18, 2026
…E with screenshots (#21) * udscript-dap: the Debug Adapter Protocol over dhewm3's script debugger A DAP client debugs a mod's scripts in a running dhewm3. The adapter speaks rvDebuggerClient's half of the game's protocol (UDP 27980/27981, an idBitMsg per message, DBMSG_* first): - UDScriptDebuggerConnection (UDScripts): the game's messages, sent and heard on a dispatch source; UDBitMsg gains idBitMsg's shorts, ints and byte-aligned strings (ReadString's '%' read as '.'). - UDDAPConnection (LSPServerKit): DAP over LSP's framing, a request an object answered now or later (the game's answers come when they come). - udscript-dap (Sources/Tools, carried in Quarry beside udscript-lsp): breakpoints (sent again whenever the game connects; one on a line with no code, which the game takes off, unverified), break, resume, step over and in (the game has no step out), threads, the call stack (a script in a pak served by reference, read through the workspace's file system), a frame's variables (its function's parameters and locals, which UDScriptIndex reads from the script, each asked of the game, which reads a variable by name but cannot list them), hovers and watches, the console both ways. launch starts the game with its debugger server on, its output forwarded; attach asks a running one. In a namespace's function the game is asked only for that function's variables: for any other name, GetRegisterValue asks the namespace for its superclass and the game aborts (idTypeDef::SuperClass throws). Tested with a fake game on UDP (Tests/Support/UDFakeScriptDebugger) on both systems, and end to end against upstream dhewm3 1.5.5 headless on the retail data: a breakpoint in map_marscity1::main hit, its threads, frames and source, a step in, a console command run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Quarry debugs scripts: UDCodeKit's debugger over udscript-dap - UDScriptDebugger (Scripts/): a window's breakpoint store, its session over udscript-dap (beside Quarry's executable; $UD_SCRIPT_DAP for the tests), and UDCodeKit's debug bar, navigator and area. Debug > Run starts the workspace's game, Attach debugs one started with its debugger server. - The window: a Debug navigator tab (threads and their stacks), and under the editors the debug bar over the debug area, laid out by hand as the pane opens and closes (a pane that was no height lays out nothing by its autoresizing on GNUstep). A Debug menu: Run (⌘R, which Revert to Saved gives up, as in UDCode), Attach to Game, Stop, Continue/Pause, Step Over/Into/Out, Toggle Breakpoint, Show Debug Area. - Script tabs show the window's breakpoints in their gutters; Toggle Breakpoint also comes through the window, as on GNUstep a view's controller is not among its responders. - Workspace Settings > Debugging: the game's executable and its arguments (UDWorkspace's gameExecutable and gameArguments). - UDWorkspace's gameFolders, diskPathOfGamePath: and gamePathOfDiskPath:, which the adapter uses too: a script in a pak is named where it would be in the mod's folder, the same in its tab, its breakpoints and its frames (the adapter's source for it carries that path and its reference). UDScriptDebuggerTests drives it through Quarry's window against the fake game: a breakpoint set in the script's tab and sent as the game names the script, the stop shown in its tab, a variable read, continue, stop. Builds against UDCodeKit's debugger (ashalkhakov/UDCodeKit#45), to be pinned once it is released. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * UDCodeKit at 0.4.0: its debugger, which Quarry's script debugging is Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * udscript-dap: steps that stay in their thread, step out, fields, conditions and logpoints - Steps. dhewm3's stock server ends a step when any thread returns from its last function, and compares step over against the wrong function, so a step ran on. With it, the adapter takes the step itself: temporary breakpoints on the lines where the step may end (the function's, for step over and into; the caller's), a stop in another thread gone on from, the breakpoints taken off at the step's stop. Step out the same way. A server that says it can (DBMSG_VERSION, protocol 2: the dhewm3 fixes in ashalkhakov/dhewm3 script-debugger-fixes) steps itself, out too. - Fields. A method's frame has a Fields scope beside Locals: its object's and its superclasses' (UDScriptIndex reads an object's superclass now), from the loaded scripts, each asked of the game; a newer server lists a frame's variables itself (DBMSG_INSPECTVARIABLES). - Conditions, hit counts and logpoints, as VS Code's SourceBreakpoint has them (supportsConditionalBreakpoints, supportsHitConditionalBreakpoints, supportsLogPoints): the game has none, so the adapter reads what they name at the stop and decides (UDScriptExpression: idScript's operators over the game's formatting of values); a condition that does not read leaves the breakpoint unverified, saying why. Tested with the fake game, and end to end headless on the retail data against both stock dhewm3 1.5.5 and the patched one: a breakpoint in a thread whose function calls one that waits, step over across the wait while Mars City's other threads ran, step into, the caller's locals, step out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Quarry: VS Code's debugging, from UDCodeKit 0.5.0 - UDCodeKit 0.5.0 pinned: hover values, watch expressions, conditional breakpoints, hit counts and logpoints, the Breakpoints navigator, Run to Cursor. - The window's navigator gets a Breakpoints tab (UDBreakpointNavigator- ViewController), a breakpoint chosen or edited there opening its script; the debug area its watches, before a session too. - The breakpoints and watches are kept as VS Code keeps them, the workspace's state rather than its settings: in user defaults by the workspace file's path (no save asked for at each one). - Debug > Run to Cursor (⌃⌘C), from the window too (on GNUstep a view's controller is not among its responders). - The tests find a control by its action with sel_isEqual: on GNUstep's runtime a XIB's selector is another pointer than @selector()'s, which UDCodeKit's own editExpression: now shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * udscript-dap: a method's self opens to its fields, as VS Code's this A method's frame had its fields in a Fields scope of their own, and self (an object, which the game could not print) read "???". Now Locals starts with self, shown as its entity (the game's, with dhewm/dhewm3#785's fix; its object's type with stock dhewm3) and opening to its object's fields and its superclasses', as VS Code shows a method's this; the separate scope is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ROADMAP: the debugger's polish against Xcode, ours first, then dhewm3's Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * udscript-dap: expressions in watches, hovers and the console self.field and a vector's .x, .y, .z; in the console what is no expression, or a name that is no variable here, is the game's command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Quarry: Run while debugging restarts the game, as Xcode's udscript-dap answers a disconnect once the game it launched has quit, so the next one has the debugger's port. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Quarry: Xcode's behaviors, a stop bringing Quarry forward and going on the game udscript-dap says the game it launched (DAP's process event), which UDCodeKit's session keeps; Quarry brings it forward when it has run on for a moment (not a step), and comes forward itself at a stop, at the debug navigator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * UDCodeKit at 0.6.0: changed values, the variables filter, the debuggee's process Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Quarry: the debug area keeps its size while hidden Laid out at no height, its views' autoresizing did not come back: the variables' scroll view reached over the area's top when it was shown, its first row under it, until a resize laid it out again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * udscript-dap: dhewm3's script errors, other threads, entities, setting variables, jumping What a dhewm3 with the protocol's newer capabilities (dhewm/dhewm3#786) offers: Script Errors and Script Warnings as exception filters, a stop at one saying what; another thread's call stack; an entity (self's too) opening to its script object's fields and spawn args; setVariable; gotoTargets and goto (Debug > Jump to Cursor in Quarry). Threads say whether they are waiting or ending. Stock 1.5.5 refuses them, saying so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * udscript-dap: protocol 2 as dhewm/dhewm3#786 now has it; other threads' variables Every request about a stopped game's threads names its thread, the stopped one's too: one list of a frame's variables (DBMSG_INSPECTVARIABLES) for any thread's frame, cached per stop, and setting one in any thread. The capabilities are three: step out, inspect, break on errors. Another thread's frames now have Locals (a method's self opening to its fields and its entity's spawn args), and hovers and watches there. A jump to a line outside the stopped function is refused saying which function the thread can jump within, and so is one from another thread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * UDCodeKit at 0.6.1 (a refused jump's reason); the dhewm3 fork as our own The roadmap names the script debugger's engine work as our dhewm3 fork's (ashalkhakov/dhewm3#1), a dhewm3 for mod authoring, not dhewm3's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * README: what the tools are for, how to get them, what Quarry does, its limits As TopoText's and XFormsKit's: a pitch, the downloads and what each is, what Quarry does and what it doesn't yet, the layout, the docs. Building, the tests and the AppImage move to docs/building.md; setting up and using the script debugger, with stock dhewm3 and our fork, is docs/debugging.md. The AppImage was checked on Fedora 42 (Bazzite's base) with its desktop libraries: the launcher, Quarry and Pak Manager start with their windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * README: Quarry's screenshots, taken by a test of its own windows UDScreenshotTests, when $UD_SCREENSHOTS names a folder, opens a retail Doom 3 install and photographs the main menu in the GUI editor's design, a material lit and a particle playing, and (given a dhewm3) the debugger stopped as Mars City starts: import on GNUstep's virtual display; on macOS Scripts/screenshot-watch.sh, which a terminal with the Screen Recording permission runs. docs/building.md says how; the roadmap's summary is today's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ROADMAP: UDCodeKit's debugger done; a C/Objective-C IDE for GNUstep next Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes in the script debugger server and in the game's side of it (
baseandd3xp). There are no protocol or game API changes.Step over never stopped.
idGameEditExt::GetInterpreterCallStackFunction()with no depth returnedcallStack[callStackDepth].f. That's the entry past the top of the call stack, not the executing function, soCheckForBreakPointHit()compared against the wrong function.Steps ran on. Any thread returning from its last function ended a step, and step into stopped in whichever thread ran next. With the hundreds of threads a map runs, a step usually ran on.
A step now records the thread (interpreter), the line and the call depth it began at. Only that thread can end it, on another line. So you can step over a call that waits (
sys.wait(), an animation) while the other threads run. Breakpoints still stop any thread.A caller's frame read the wrong values.
GetRegisterValue()read a caller's locals, and itsself, at the current function's stack base. It now uses that frame's owncallStack[i].stackbase.A hover could abort the game. For a name it couldn't find in a namespace's function,
GetRegisterValue()calledidTypeDef::SuperClass()on the namespace. That throws, and the game aborted. It now only walks an object's superclasses.Entities and vector fields showed
???. Entity variables now show as$name, and object fields that are vectors or entities show their values.Caller frames showed the line after the call. In
DBMSG_INSPECTCALLSTACK, a caller's frame now shows the line of the call itself.Testing:
IMGUI=OFF.udscript-dap. The test hit a breakpoint in a thread that calls a function that waits, then:A follow-up PR adds Step Out and listing a function's variables to the protocol, in a backward-compatible way. It builds on this one.
These changes were written with Claude (Anthropic's AI model); the commits carry its Co-Authored-By line.