Skip to content

Commit 7a5076e

Browse files
committed
feat: SourcePawn remote debugger for VS Code
Debug SourcePawn plugins running on a live SourceMod server from VS Code, over DAP: breakpoints (conditional, hit-count, logpoints and non-freezing snapshot logpoints), call stack, variable inspection and editing, stepping, Debug Console REPL, data breakpoints, memory view, and a function profiler. Layout: dap/ DAP/TCP/profiler crate (ours) sp-console-debugger/ vendored upstream, NOT committed -- reconstructed at build time from patches/*.commit + *.patch vscode/ the VS Code extension and its test suites docs/ usage, architecture, protocol, troubleshooting Security posture: the debug port listens on 127.0.0.1 by default, since a session can read and write plugin memory and can hold the game thread on a breakpoint. Exposing it beyond loopback requires a shared token, which is demanded before any request is served; without one the listener refuses to start. Lifecycle: the accept thread and all client threads are owned and joined on teardown, so unloading or reloading the extension -- and restarting the server with an editor attached -- neither freezes nor crashes the host process. Tests: unit suites plus two integration suites driven against a mock srcds (full DAP session, and extension load/unload/reload/shutdown), alongside the upstream console regression harness. Also ships the GitHub issue form and pull request template: the bug form asks for the SourceMod line and how the extension was loaded (the two answers that explain most reports) plus the evidence -- `sm exts list`, traced Debug Console output, server log. The PR checklist covers what breaks quietly here: regenerating the vendored patch, MSVC-only pitfalls, releasing threads and VM callbacks on unload, and the docs that go stale with each.
1 parent c01ca99 commit 7a5076e

95 files changed

Lines changed: 29457 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Bug report
2+
description: The debugger misbehaves, fails to connect, or takes the server down
3+
labels: ["bug"]
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Thanks for the report. The two details that resolve most issues fastest are
9+
**which SourceMod line the server runs** and **how the extension was loaded**,
10+
so please do not skip those fields.
11+
12+
**Never paste your `token`.** If you quote any part of
13+
`console-debugger.cfg` or of your launch configuration, redact it first.
14+
15+
- type: checkboxes
16+
id: preflight
17+
attributes:
18+
label: Preflight
19+
description: Tick what applies. Leaving a box unticked is useful information too.
20+
options:
21+
- label: The server was fully restarted after deploying the extension (not `sm exts load` / `reload`)
22+
- label: The server package matches the server's SourceMod line (`sm1.12` vs `sm1.13`)
23+
- label: The patched SourcePawn VM from the release package is installed
24+
- label: I can reproduce this with only the debugger extension and the plugin involved
25+
26+
- type: textarea
27+
id: what-happened
28+
attributes:
29+
label: What happened
30+
description: What you did, what you expected, and what happened instead.
31+
placeholder: |
32+
Set a breakpoint on line 42 of antibhop.sp and started the session.
33+
Expected: the breakpoint verifies and the server stops on it.
34+
Actual: the breakpoint stays hollow and `launch` fails with "...".
35+
validations:
36+
required: true
37+
38+
- type: textarea
39+
id: reproduce
40+
attributes:
41+
label: Steps to reproduce
42+
description: |
43+
Smallest sequence that shows the problem. A minimal plugin helps enormously.
44+
If it is a connection problem, say which host and port the editor used.
45+
placeholder: |
46+
1. Start the server
47+
2. F5 in VS Code with a launch configuration pointing at that server
48+
3. Trigger the plugin (say hello in chat)
49+
4. ...
50+
validations:
51+
required: true
52+
53+
- type: dropdown
54+
id: sm-line
55+
attributes:
56+
label: SourceMod line
57+
options:
58+
- "1.12 (stable)"
59+
- "1.13 (dev)"
60+
- Not sure
61+
validations:
62+
required: true
63+
64+
- type: input
65+
id: versions
66+
attributes:
67+
label: Versions
68+
description: Server package and `.vsix` you installed, plus the exact SourceMod build.
69+
placeholder: "sp-debugger-server-linux-sm1.12 (release 1.0.3), sp-debugger.vsix 1.0.3, SourceMod 1.12.0.7246"
70+
validations:
71+
required: true
72+
73+
- type: dropdown
74+
id: os
75+
attributes:
76+
label: Game server OS
77+
options:
78+
- Linux
79+
- Windows
80+
- Other
81+
validations:
82+
required: true
83+
84+
- type: input
85+
id: game
86+
attributes:
87+
label: Game / engine
88+
placeholder: "CS:S, TF2, L4D2, ..."
89+
90+
- type: textarea
91+
id: extension-state
92+
attributes:
93+
label: "`sm exts list` output"
94+
description: Run it in the server console. It shows whether the debugger loaded at all.
95+
render: text
96+
placeholder: |
97+
[01] Automatic Updater (1.12.0.7246): ...
98+
[03] Console Debugger (0.1.0): Allow debugging plugins through the server console.
99+
100+
- type: textarea
101+
id: debug-console
102+
attributes:
103+
label: Debug Console output
104+
description: |
105+
Add `"trace": true` to the launch configuration and reproduce once — it prints the
106+
request/response flow the adapter saw.
107+
render: text
108+
109+
- type: textarea
110+
id: server-log
111+
attributes:
112+
label: Server log
113+
description: |
114+
Relevant lines from the server console and from
115+
`addons/sourcemod/logs/errors_*.log`. If the server crashed, include the tail of the
116+
console output and, on Linux, a backtrace if you have one
117+
(`coredumpctl info` / `gdb -p`).
118+
render: text

‎.github/PULL_REQUEST_TEMPLATE.md‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!--
2+
Keep the description short and factual: what changes, and why it is the right
3+
change. The checklists below are the parts of this repo that are easy to break
4+
without noticing.
5+
-->
6+
7+
## What and why
8+
9+
<!-- One or two paragraphs. If it fixes a bug, say what the bug did, not just its name. -->
10+
11+
Fixes #
12+
13+
## How it was verified
14+
15+
<!--
16+
Paste the result lines, not just "tests pass". If a suite was not run, say which
17+
and why -- that is more useful than silence.
18+
-->
19+
20+
- [ ] `cd vscode && bun test` — unit suites
21+
- [ ] `cd vscode && bun tsc -p ./ --noEmit` — the `.vsix` job compiles every file under `src/`, tests included
22+
- [ ] `sp-console-debugger/tests/run_tests.sh` — console regression (needs the mock env)
23+
- [ ] `vscode/tests/dap/run_dap_tests.sh` — DAP regression + extension lifecycle (needs the mock env)
24+
- [ ] Built against **both** SourceMod lines (`--sm-path` at a 1.12 tree and at a 1.13/master tree)
25+
26+
```
27+
<!-- result lines here -->
28+
```
29+
30+
## Checklist
31+
32+
- [ ] **Vendored tree**: if anything under `sp-console-debugger/` changed, `patches/sp-console-debugger.patch` was regenerated and the round-trip verified (delete the folder, refetch, re-apply, `diff -r` clean). See [docs/updating-upstream.md](../docs/updating-upstream.md).
33+
- [ ] **Windows**: no POSIX-only call without a guard, and no bare `std::min`/`std::max` in a file that pulls in `winsock2.h` (the `min` macro rewrites them and MSVC fails to compile).
34+
- [ ] **Teardown**: any new thread, socket or VM callback is released in `Stop()` / `SDK_OnUnload`. The extension is unloaded on `sm exts unload/reload` and on every server restart; anything still running then takes the game server with it.
35+
- [ ] **Debug surface**: if this adds or widens a DAP request, it cannot read or write more than the debugged plugin's own memory, and it is gated on a paused session where that matters.
36+
- [ ] **Docs**: user-visible behaviour is reflected in `docs/usage.md`, protocol changes in `docs/protocol.md`, design decisions in `docs/architecture.md`, new failure modes in `docs/troubleshooting.md`.
37+
- [ ] **Output**: any new Debug Console message is plain text (no decorative glyphs) and ends with a newline.
38+
39+
## Risk
40+
41+
<!--
42+
What breaks if this is wrong, and who notices first? Call out anything that
43+
changes the default configuration, the wire protocol, or the release packaging --
44+
those reach every server owner on the next update.
45+
-->

0 commit comments

Comments
 (0)