Skip to content

Commit 4eb17bb

Browse files
authored
fix!: remove all dynamic references; major re-write and cleanup;
* fix!: remove dynamic keyword and System.Reflection references (fixes #5) * fix: fix build instructions by removing mono requirement and only using dotnet (fixes #6) * fix: remove SendOutput which are overloading the REPL frontend; * fix: remove duplicate SendResponse calls * chore: major re-writing and cleanup of unused code * chore: add lazy logging * chore: add trace log messages for debugging
1 parent 9069b0e commit 4eb17bb

10 files changed

Lines changed: 1766 additions & 917 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ mono-debug.userprefs
1212
npm-debug.log
1313
.vs/
1414
.DS_Store
15+
log.txt
16+
log

README.md

Lines changed: 84 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,19 @@ Unity Debug Adapter (DA) for debugging the Unity Editor or applications using th
44
backend.
55

66
> [!IMPORTANT]
7-
> I am currently re-writing this project. There are a couple of issues and using dotnet rather
8-
> than Mono to run this seems problematic.
7+
> debugging IL2CPP applications is not and will not be supported.
98
10-
> [!IMPORTANT]
11-
> debugging IL2CPP applications is not supported.
12-
13-
This project is adjusted (somewhat forked) from the deprecated and quite frankly bloated
14-
[vscode-unity-debug][vscode-unity-debug] project. [vscode-unity-debug][vscode-unity-debug] does
15-
not work out-of-the-box with new dotnet because of failure to detect the '\r\n\r\n' sequence
16-
in client <-> debug-adapter messages. The failure is caused by an IndexOf("\r\n\r\n") issue
17-
(see https://github.com/dotnet/runtime/issues/43736).
18-
19-
Since the project is stale and no longer accepts pull-requests/patches, fixing
20-
issues of the original [vscode-unity-debug][vscode-unity-debug] project and debloating
21-
it are the reasons for the existence of this project.
9+
This project is adjusted (forked) from the deprecated and *quite frankly* bloated
10+
[vscode-unity-debug][vscode-unity-debug] project.
2211

23-
Hopefully when Unity finally moves to .NET Core, the need for this repository will cease to
24-
exist. In the meantime, if you are doing Unity development on a text-editor/IDE other than
25-
VSCode, Ryder, or Visual Studio, and you want debugging functionalities with a clear license
26-
(MIT) then this project is for you.
12+
If you are doing Unity development on a text-editor/IDE other than VSCode,
13+
Ryder, or Visual Studio, and you want debugging functionalities with a
14+
permissive license (MIT) then this project is for you.
2715

28-
In case you are looking for instructions on how to hook this to Neovim, see [neovim-unity][unity-debugger-support].
16+
In case you are looking for instructions on how to hook this to Neovim, see
17+
[neovim-unity][unity-debugger-support].
2918

30-
## Installation
19+
## Build from Source
3120

3221
Clone the repo and its submodule(s):
3322

@@ -64,27 +53,93 @@ Then, if you want to run the debug adapter:
6453
bin/Release/unity-debug-adapter.exe
6554
```
6655

67-
You should then be seeying an output like this:
56+
If you built this from source, you might need to:
57+
```bash
58+
chmod +x bin/Release/unity-debug-adapter.exe
59+
```
60+
61+
You should then get an output like this:
6862

6963
```text
7064
21/08/2025 00:31:01 [I] waiting for debug protocol on stdin/stdout
7165
21/08/2025 00:31:01 [I] constructing UnityDebugSession
7266
21/08/2025 00:31:01 [I] done constructing UnityDebugSession
7367
```
7468

75-
## Usage
69+
## For Developers
7670

77-
`unity-debug-adapter.exe` accepts two optional long parameters:
78-
- `--trace-level` sets the logging trace level: `trace` | `debug` | `info` | `warn` | `error` | `critical` | `none`
79-
- `--log-file` provides a path to a log file. In case this is not provided, and `--trace-level` is not `none`, logging
80-
is output to stderr.
71+
This section is mainly for developers interested in contributing or want to
72+
learn the intenals of this project.
8173

82-
Example of an invocation:
74+
### Overview
8375

84-
```bash
85-
unity-debug-adapter.exe --trace-level=trace --log-file=dap-log.txt
8676
```
77+
Translates `requests` from nvim (which are DAP conformant)
78+
to Mono.Debugger-sepecific requests.
79+
Translates Mono.Debugger-specific
80+
responses to DAP-conformant `responses`.
81+
Writes logs to s_LogFile or stderr Locally running Unity Editor (which always uses Mono). Or
82+
| a local/remote running Unity Player instance using Mono
83+
| backend (with debugging enabled)
84+
| |
85+
+------+ +-----------+ +--------------------+ < - - - - - +
86+
| Nvim |----------- | UNITY DAP | ---------------- | UNITY |
87+
+------+ ^ +-----------+ ^ | (Mono.Debugger) |
88+
| | +--------------------+
89+
| |
90+
via stdin and stdout + via a TCP/IP socket (ip:port)
91+
(_outputStream and inputStream)
92+
```
93+
94+
### Backends
95+
96+
This debug adapter essentially communicates with the following backends:
97+
98+
- Mono.Debugger.Soft: this is the official Mono debugger in `debugger-libs`.
99+
- GDB: Mono applications can be debugged using `gdb`. This is still not
100+
implemented yet and is TODO.
101+
102+
103+
### Why not IL2CPP
104+
105+
I will not include add support for debugging C# -> IL2CPP code mainly because
106+
of these facts/opinions:
107+
108+
- IL2CPP is closed source and I might get into trouble if I implement something
109+
like what Visual Studio does (i.e., some sort of mapping between original C#
110+
code and generated IL2CPP C++ code).
111+
- I think it makes little sense to debug C++ code (generated or not) via
112+
stepping through a completely different language (e.g., managed C#).
113+
- Complexity. There are very few people who are using Neovim for Unity, fewer
114+
are using debuggers, and even fewer who want to debug IL2CPP through C# via
115+
Neovim. This is simply not worth the effort.
116+
- IL2CPP is simply C++. Just debug it using a proper C++ debugger (e.g., gdb).
117+
118+
### Why Not Use [vscode-unity-debug][vscode-unity-debug]?
119+
120+
[vscode-unity-debug][vscode-unity-debug] does not work out-of-the-box with new
121+
dotnet because of failure to detect the '\r\n\r\n' sequence in
122+
client <-> debug-adapter messages. The failure is caused by an
123+
`IndexOf("\r\n\r\n")` issue (see https://github.com/dotnet/runtime/issues/43736).
124+
125+
Since the project is stale and no longer accepts pull-requests/patches, fixing
126+
issues of the original [vscode-unity-debug][vscode-unity-debug] project and
127+
debloating it are the reasons for the existence of this project.
128+
129+
The project is also very poorly written, all responses are sent twice, the
130+
project relies on heavy usage of the `dynamic` keyword which requires JIT and
131+
which causes issues when this project is compiled with dotnet (rather than
132+
xbuild).
133+
134+
135+
### In an Ideal World
136+
137+
Hopefully we get Unity .NET CLR support before the sun explodes so that we can
138+
use actual proper, industry-standard, open-source, and actively maintained
139+
.NET debuggers.
87140

141+
When that happens, this adapter will add support to it and will, probably, be
142+
much more useful.
88143

89144
## License
90145

0 commit comments

Comments
 (0)