|
|
|
In this article
|
|
|
|
|
|
|
|
[[_TOC_]]
|
|
|
|
|
|
|
|
Debugging from VSCode
|
|
|
|
=====================
|
|
|
|
Starting from version `4.1-beta7` UnityBase support debugging of server-side directly from a [VSCode IDE](https://code.visualstudio.com/) using [VS Code Debug Adapter for Firefox](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-firefox-debug)
|
|
|
|
|
|
|
|
### Install FireFox extension for VSCode
|
|
|
|
|
|
|
|
Press `Ctrl+Shift+X` type `Firefox` and select extension `Debugger For FireFox` by Holger Benl
|
|
|
|
|
|
|
|
### Create a [Launch configuration](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations)
|
|
|
|
|
|
|
|
``` launch.json
|
|
|
|
{
|
|
|
|
"version": "0.2.0",
|
|
|
|
"configurations": [
|
|
|
|
{
|
|
|
|
"type": "firefox",
|
|
|
|
"request": "attach",
|
|
|
|
"name": "SyNode",
|
|
|
|
"addonType": "webExtension",
|
|
|
|
"addonPath": "${workspaceRoot}/",
|
|
|
|
"host": "127.0.0.1",
|
|
|
|
"port": 6000,
|
|
|
|
"sourceMaps": "client"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Modify a `package.json`
|
|
|
|
Since UB can run multiple JS Engine, we need to add a configuration with a engine name we want to debug.
|
|
|
|
|
|
|
|
Modify your application `package.json` by adding top-level property `"id": "Server"`.
|
|
|
|
|
|
|
|
Possible values are:
|
|
|
|
|
|
|
|
- `"id": "Server"` to debug a server-side thread
|
|
|
|
- `"id": "client"` to debug a console thread (command line js executed by `>ub myscript.js -dev - debug`)
|
|
|
|
- `"id": "WebSocket"` to debug a server-side WebSocket thread
|
|
|
|
|
|
|
|
### Run ub in developer mode
|
|
|
|
|
|
|
|
**!!! Please, disable a WebSocket (comment a wsServer section in `ubConfig.json`) before debugging - debugging with enabled WebSockets don't work yet**
|
|
|
|
|
|
|
|
Run UB in developer mode to allow debugger
|
|
|
|
```
|
|
|
|
cd yourAppFolder
|
|
|
|
ub -dev
|
|
|
|
```
|
|
|
|
|
|
|
|
### Start debugging in VSCode
|
|
|
|
In VS Code press F5 to connect to a UB Remote Debugger.
|
|
|
|
|
|
|
|
You can set a breakpoints in IDE before start a debugger or during debugging.
|
|
|
|
|
|
|
|
|
|
|
|
### Read [debugging manual](https://code.visualstudio.com/docs/editor/debugging)
|
|
|
|
|
|
|
|
### Debugging tips
|
|
|
|
|
|
|
|
You can modify a sources you debug, but this changes are applied to server only after restart.
|
|
|
|
|
|
|
|
You can restart a server directly from debugging console by typing `$$()` command - see picture
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
For contributors
|
|
|
|
===============
|
|
|
|
|
|
|
|
In case you need to debug a debugger protocol - add a logging section to the launch.json
|
|
|
|
```
|
|
|
|
"configurations": [
|
|
|
|
{
|
|
|
|
....
|
|
|
|
"log": {
|
|
|
|
"consoleLevel": {
|
|
|
|
"PathConversion": "Debug",
|
|
|
|
"default": "Debug"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
``` |