Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscript debugger #302

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

samisalreadytaken
Copy link

@samisalreadytaken samisalreadytaken commented Jun 22, 2024

Adds Squirrel debugger

This is not the one that is used in Valve games, that is an old, very limited, Eclipse only debugger. This one is as extensive as possible, uses the Debug Adapter Protocol by Microsoft, a new debugger protocol standard that is already implemented by a number of editors.

Port numbers 1212 and 1213 are completely arbitrary, they can be changed. vscript_debugger_port variable is used to attach the debugger as soon as possible (but after classes are registered) for it to enable debug information for scripts loaded on map load. This only works for client though, script_debug command can't be executed while a server doesn't exist.

sqdbg_definitions.nut file is executed when the debugger attaches, this file is used to let the debugger know of the class names and how to display them in the client.

https://gist.github.com/samisalreadytaken/0e4238f501bcff21649cd2c99ae0ab2c

Ideally this would be distributed with game files, it would be too cumbersome to ask users to manually download/write this every time. It's not embedded in the binaries because it should be possible to adjust things manually.

L4D2 branch has the concommands script_connect_debugger and script_disconnect_debugger. They could replace the script_debug command to be able to disconnect the debugger on will.

Steps to test it on VS Code:

  1. Download VS Code: https://code.visualstudio.com/download

  2. Download and install the debugger extension: https://github.com/samisalreadytaken/sqdbg-vs/releases/download/0.1.0/sqdbg-vs-0.1.0.vsix

  3. Install a Squirrel language extension from its marketplace. The one by "marcinbar" seems to work well enough.

  4. Attach the debugger in game with script_debug or script_debug_client

  5. Load a squirrel script in the editor, press F5, enter the connection port (1212 for server, 1213 for client)

You may now place breakpoints and use the Debug Console to execute scripts while the game is running.

This video briefly shows installation of the extension, placing line and function breakpoints, and debugging both server and client at the same time with 'compound' configurations (compounds only work for opening a folder in vscode and creating launch.json)

https://www.youtube.com/watch?v=qIxujbfh_0c

Even though VSCode is a terribly slow editor, it has (not all, but) most debugging features implemented. Other (present and future) DAP compatible editors can be used as well.


PR Checklist

  • My PR follows all guidelines in the CONTRIBUTING.md file
  • My PR targets a develop branch OR targets another branch with a specific goal in mind

@samisalreadytaken samisalreadytaken force-pushed the vscript-debugger branch 7 times, most recently from 76ef30b to 2d13fae Compare June 29, 2024 16:13
@samisalreadytaken samisalreadytaken force-pushed the vscript-debugger branch 3 times, most recently from 9660448 to 1c0a117 Compare November 13, 2024 21:40
@samisalreadytaken samisalreadytaken force-pushed the vscript-debugger branch 3 times, most recently from e713151 to 9a3db43 Compare November 22, 2024 10:02
@samisalreadytaken samisalreadytaken force-pushed the vscript-debugger branch 3 times, most recently from ec3d4c5 to b8e61f0 Compare December 4, 2024 18:11
@samisalreadytaken samisalreadytaken force-pushed the vscript-debugger branch 3 times, most recently from e588bcf to f536972 Compare December 16, 2024 15:29
@samisalreadytaken samisalreadytaken marked this pull request as draft January 4, 2025 17:41
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.

2 participants