jerryscript-project / iotjs-vscode-extension

Apache License 2.0
3 stars 9 forks source link

How can I test a simple Javascript code with iotjs-vscode-extension ? #10

Open haesik opened 6 years ago

haesik commented 6 years ago

I followed the instruction on the Readme file. But I have failed to start debugging of a sample javascript file. Could you explain more detailed instructions?

my test) I tested using following instructions

$ git clone https://github.com/Samsung/iotjs-vscode-extension.git $ cd iotjs-vscode-extension ~/.vscode -r $ cd path/to/the/iotjs $ ./tools/build.py --buildtype=debug --jerry-debugger $ ./build/x86_64-linux/debug/bin/iotjs --start-debug-server ./test/run_pass/test_console.js

and I made a launch.json file in iotjs/.vscode/ with the following contents { "version": "0.2.0", "configurations": [ { "name": "IoT.js: Attach", "type": "iotjs", "request": "attach", "address": "localhost", "port": 5001, "localRoot": "${workspaceRoot}/test/run_pass/test_console.js", "stopOnEntry": false, "debugLog": 0 }, ] }

I pushed F5 button on vscode .. and I received a fail message written in Korean.. Here is a brief translation => "The debug adapter process terminated unexpectedly"

knightburton commented 6 years ago

@haesik First of all, your launch.json is incorrect, the localRoot should be your working directory's path, the most cases the ${workspaceRoot} is enough.

In the other hand I think if you want to use the debugger directly from the iotjs directory insted of a separated empty project folder, the debugger waiting mode would be much better because of you already have that file on your computer what you want to debug.

I suggest you that to start the iotjs with this command: ./build/x86_64-linux/debug/bin/iotjs --start-debug-server --debugger-wait-source In this case the iotjs will start the debug server and if you hit the F5 button in the vscode the debugger client will connect to it, then you will get a prompt inside the vscode where you can select the desired test file.

haesik commented 6 years ago

I have tried localRoot with ${workspaceRoot}, but the result is same. Could you check the following sequence ?

$ git clone https://github.com/Samsung/iotjs-vscode-extension.git $ cp iotjs-vscode-extension ~/.vscode -r $ cd path/to/the/iotjs $ code . $ ./tools/build.py --buildtype=debug --jerry-debugger $ ./build/x86_64-linux/debug/bin/iotjs --start-debug-server --debugger-wait-source

and I made a launch.json file in iotjs/.vscode/ with the following contents { "version": "0.2.0", "configurations": [ { "name": "IoT.js: Attach", "type": "iotjs", "request": "attach", "address": "localhost", "port": 5001, "localRoot": "${workspaceRoot}", "stopOnEntry": false, "debugLog": 0 }, ] }

I pushed F5 button on vscode .. and I received a same fail message..

knightburton commented 6 years ago

@haesik I see, sorry, I missed that you wanted to copy the extension into the vscode to avoid the developer debug run. In this case the copy path that you using is incorrect, the extensions are listed in ~/.vscode/extensions/ folder, so you have to copy the extension there.

Use this: cp iotjs-vscode-extension ~/.vscode/extensions/ -r

After this, the sequence that you using should work properly.

hs0225 commented 6 years ago

@haesik npm install and npm run compile are required.

cd ~/.vscode/extensions/iotjs-vscode-extension
npm install
npm run compile

@knightburton Could you update the READEME.md about install extensions?

haesik commented 6 years ago

@knightburton @hs0225 Thank you very much for the guides.. Now, I can trace source code.. : )

knightburton commented 6 years ago

@hs0225 Sure, I forgot that the npm install and npm run compile are requires for the first time running, I'll update the README.md.

knightburton commented 6 years ago

I've opened a PR about the README update (#13) and since this issue is solved I close this.

haesik commented 5 years ago

Today, I have tested vscode-extension with latest iotjs and I got an error message. Can you test with latest iotjs and iotjs-vscode-extension?

  1. I have tested with the following instructions

$ git clone https://github.com/Samsung/iotjs-vscode-extension.git $ cp iotjs-vscode-extension ~/.vscode -r $ cd ~/.vscode/extensions/iotjs-vscode-extension $ npm install $ npm run compile $ cd path/to/the/iotjs $ ./tools/build.py --buildtype=debug --jerry-debugger --no-snapshot $ ./build/x86_64-linux/debug/bin/iotjs --start-debug-server ./test/run_pass/test_console.js & $ code .

and I made a launch.json file in iotjs/.vscode/ with the following contents { "version": "0.2.0", "configurations": [ { "name": "IoT.js: Attach", "type": "iotjs", "request": "attach", "address": "localhost", "port": 5001, "localRoot": "${workspaceRoot}", "stopOnEntry": false, "debugLog": 1 }, ] }

and I connect to a running engine and I got the following message,

TCP Error: Connection reset by peer ICE: Assertion 'JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED' failed at /home/haesik/iotjs/iotjs/deps/jerry/jerry-core/parser/js/js-parser.c(parser_append_breakpoint_info):1403. Error: ERR_FAILED_INTERNAL_ASSERTION

Could you check it?

  1. And One more Issue is that When i build with the following command $ ./tools/build.py --buildtype=debug --jerry-debugger
    This time I got the following message and I can't use break point..

TCP Error: Resource temporarily unavailable Hello IoT.js!! 1 2 3 13 [1,2,3] 1 2 3 a 1 b 2 c 3 test null undefined { "a": "123", "b": 123, "c": [ 1, 2, 3 ] } Hello IoT.js!! 1 2 3 13 [1,2,3] 1 2 3 a 1 b 2 c 3

Could you check this also?

tdusnoki commented 5 years ago
  1. The path you wrote in your second command is incorrect. The correct path to copy your extension folder would be~/.vscode/extensions instead of ~/.vscode/ You should also check first if you had a previous version of the extension in that same folder and delete it before copying the new one.
  2. These fixes https://github.com/jerryscript-project/jerryscript/pull/2643 and https://github.com/jerryscript-project/jerryscript/pull/2606 will be added to IoT.js in the next JerryScript update: https://github.com/Samsung/iotjs/pull/1820. After that you will be able to build without --no-snapshot flag.