lwnode provides preliminary debugging capabilities via VS code. This document shows you how to debug a hello.js.
We assume lwnode is checked out in the lwnode directory in the following code example.
$ git clone https://github.com/Samsung/escargot-vscode-extension.git
$ cd escargot-vs-code-extension
$ npm install
$ npm install -g vsce
$ npm run compile
$ vsce package
// escargot-vscode-extension.vsix is created$ cd lwnode
$ code .Install the plugin as follows:
- Type
ctrl+shrt+pand typeExtensions: Install from VSIX... - Select
escargot-vs-code-extension.vsix
$ cd lwnode
$ vi .vscode/launch.json// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
// Your existing targets may appear here.
// Add the following target to your launch.json
{
"name": "Debug: lwnode",
"type": "escargot",
"request": "attach",
"address": "localhost",
"port": 6501,
"localRoot": "${workspaceRoot}",
"debugLog": 4
}
]
}
Compile lwnode with a debugger option.
$ cd lwnode
$ ./configure --debug --escargot-debugger
$ ninja -C out/linux/Debug lwnode// Open a new terminal
$ cd lwnode
$ out/linux/Debug/lwnode --start-debug-server ./hello.jsA sample of hello.js is given below.
// hello.js
let sum = 0;
for (let i = 0; i < 10; i++) {
sum += 1;
}lwnode will wait for a connection from VS code.
$ cd lwnode
$ code .On VS Code, run as follows:
- Open
hello.jsin VS Code - Select
Run and Debug (ctrl+shift+D)on the left panel - Set target to
Debug: lwnodefound on the top - Select
Run -> Start Debugging (F5)on the menu
Known Issues:
- The debugger by default stops at every
*.jsfile loaded before loadinghello.js. This behaviour is expected to be fixed in the next version. (i.e., theconsole.log()function will call many subsequence JS functions calls.) - To add a break point, wait until
hello.jsis loaded in VS code, and add a break point.