harold-b/vscode-duktape-debug

Does not hit breakpoints

Closed this issue · 5 comments

I'm interesting in using the vscode duktape debugger, but I'm having trouble getting it working.

It does connect to my target, but no breakpoints are ever hit.

  • I've installed the latest Visual Studio Code and duk-debugger extension
  • I've downloaded duktape 1.5.1 and built the commandline tool with debug (make -f Makefile.dukdebug)
  • I can run duktape with the included javascript file (duk --debugger mandel.js)
  • I open the duktape folder in VS Code
  • Open the mandel.js file and add some breakpoints
  • I created a default 'Duk Attach' configuration
  • When I hit start debugging, the debugger attaches, the code runs and I can see the output in the console, and then it detaches again, but never hits the breakpoints

I have tried doing the same thing with the the browser based debugger that comes with duktape, and that works correctly.

Any help you can give would be greatly appreciated.

Hey there, I'll try to look into this issue today, the last past few days have been extremely busy and I've not been able to check this stuff out. Thanks for your patience.

Okay, I've looked into it. Thanks again for bringing up this issue, and sorry I did not keep my word the other day, I thought I'd have some free time in the week.

I looked into the issue and found a couple of bugs. I've committed a fix (ed0a6b4) and published an update for the extension. You should be able to get it working now. However, because the messaging API of the front-end of the debugger provided by VSCode (and the network) might delay a bit the messages, you might still not hit the first breakpoints before the whole script is executed.

I mitigated this by just adding these lines to delay running the script immediately:

var start = new Date().getTime() + 1000;
while( new Date().getTime() < start )
{}
mandel();

I hope this fixes it for you
Also, I added the 'debugLog' configuration option (set it in launch.json to true) which will allow you to view the network traffic from the debug client and the server, in case you need it.

Let me know if you come across any other issues and again, thanks for your patience.

@harold-b thanks so much for fixing this! it works really well.

I did find the issue you mentioned, where the code runs before the breakpoint is set. I worked around this by setting stopOnEntry: true and then hitting pause. This stopped the program at the first line, and allowed me to then get all the breakpoints where I want them.

Thanks again.

Glad to help.

Did not recall I had implemented stopOnEntry I thought it was still a missing feature :P

I tried it, however seems to be bugged on my end. Front end does not update the correct state. So thanks for bringing up another bug to my attention. 👍

@willi1s Just to let you know, I've fixed stopOnEntry to work properly, in case you run into any issues with it. You can update to version 0.2.7.

Please consider leaving a review :)