Skip to content

Ported the Script Debugger from dhewm3#6

Open
DanielGibson wants to merge 8 commits intostgatilov:trunkfrom
DanielGibson:script-debugger
Open

Ported the Script Debugger from dhewm3#6
DanielGibson wants to merge 8 commits intostgatilov:trunkfrom
DanielGibson:script-debugger

Conversation

@DanielGibson
Copy link

@DanielGibson DanielGibson commented Feb 10, 2026

Doom3 GPL contained most of the source of the script debugger that used to be part of Quake4.
Harrie van Ginneken fixed it for dhewm3 by implementing the missing parts and we further improved it together.

debugger

Like all the original Tools it's mostly Windows-only, but it's actually split into client (that Windows MFC frontend) and server, and the serverpart should also work on Linux (tested that on dhewm3 a while back, didn't test it in TDM now). And I guess TDM also works fine in Wine?

On Windows, just enter debugger in the console to start it.

Then go to the "Scripts" Tab and select a script you're interested in and find an interesting function and set a breakpoint (click in the line and press F9 or click to the left of the line number where that dot will appear).
When the game gets to that point it will pause and you can inspect the function in the script debugger or step through it line-by-line with F10/F11 (or those buttons); you can make it continue running normally (until it hits a breakpoint again) by pressing that little triangular "play" button at the top.

When hovering variables with the mouse cursor, it should show their current value. Doesn't seem to work for constants though..

After clicking a variable you can press Shift+F9 to get into some "quick watch" view, where you can also add the variable to the watch tab

Also check out the context menu in the text view showing the script source (no you can't edit it there).

Generally it's kinda ugly and janky, but better than nothing.

Download

Here's a testbuild for Windows, based on current trunk code, seems to work with latest 2.14 beta game data: TheDarkModx64-scriptdbg2.zip

Linux build: thedarkmod.x64-script-dbg-linux.zip

More details

The script debugger will actually run in a separate process, same you get when starting thedarkmod with the +debugger commandline argument (then you get only the debugger window).

For the networked setup, the following CVars are relevant: com_enableDebuggerServer, com_dbgClientAdr and com_dbgServerAdr.

Maybe (on Linux) you could even run TheDarkModx64.exe +debugger in Wine and the native darkmod (on the same machine) with +set com_enableDebuggerServer 1 and they may find each other. Likely you need to start the native one with the server first, if anyone tries please let me know :)

It's based on the (nonfunctional) script debugger included in the
Doom3 GPL code, fixed in dhewm3 by Harrie van Ginneken and further
improved by him and me.

Doesn't work in TDM yet, especially because there's still SDL-code in it
... that weren't really specific to it but (as far as I can tell)
required to make it work
this appears to be from the original Doom3 GPL source, no idea why..
on Windows this restriction is not enforced, and at least nowadays
usleep() on Linux has a precision that is *much* better than 1ms
pthread_join() returns an error code, this can be logged in addition
to the existing message (both as string and its number)
by replacing SDL-based threading code with stuff from sys_threading.h
…t/prev

the code for this already existed, it just wasn't wired into the UI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant