Open DrEight opened 6 years ago
the build-in vs-code JavaScript debugger works with node.js only, chakracore.net requires its own debugger which is nearly finished. I will add document and demo when it’s done. The following feature is supported:
I used this launch.json, on your sample ( run script ), but I receive a lot of exceptions that I tried to fix without success for example in the class 'TaskQueueRunner' . My Launch.json : "version": "0.2.0", "configurations": [
{
"type": "node",
"name": "attach to chakra",
"request": "attach",
"port": 4711
}
]
is it correct ?
Run script contains a debug sample under the scripts\debugging folder. Ideally Change the run script launch config to “debugging” in visual studio (not vscode), press f5 , then open the scripts\debugging folder in vs code, and start debug with config “launch” in vscode should work. The check in I committed last night may break the steps above, please use previous version or wait for debug adapter finish.
no I was not able to make it works. I'll wait for the 'debug adapter'. Do you have any estimation date ? Thank you for the work you are doing.
I plan to finish this feature before 23 April. However I’m baby sitting my 2 yr son these days, hope I can finish it on time.
Hi DrEight, the debugging code is completed, there's still known issues but it works :) I'll publish it to the VSCode market in the next few days. however, you can try it now without the publication is done:
Start "RunScript" with "Debugging" profile, a console window should popup and last line should be "Script ready, Waiting for debugger"
Open "VSCodeDebugAdapter" folder with VSCode
Start debug with "extension" launch config, a new VSCode window will popup
In the new VSCode window, open folder "source\RunScript\Scripts\Debugging\"
add breakpoint(s) in app.js (known issue: Sometimes, if you don't set breakpoints, the script engine may not start correctly after VSCode is connected with launch command. Workaround: you can restart from step 1 to try again)
Start debug with "ccn Launch" launch config
You should see the break point hit like this
the VSCode debugger is published, just install the extension and ignore step 2,3 in previous post.
Thank you it works! Is it possibile also to attach to a running js script ?
Yes, you can comment ln 53 and uncomment ln54 in program.cs (RunScript) to tell the engine start the execution without wait for launch command. then use the "ccn Attach" profile to attach your script. the correct order should be:
the 'attach' works in your sample, but I tried with a very basic code like this:
ChakraRuntime runtime = ChakraRuntime.Create();
ChakraContext context = runtime.CreateContext(true);
// debug
var debugCTS = new System.Threading.CancellationTokenSource();
var adapter = new VSCodeDebugAdapter(false);//start program, wait for attach command from VSCode
adapter.OnLaunch += (sender, arguments) => { Console.WriteLine($"Launch requested,arguments={arguments}"); };
adapter.OnAttach += (sender, arguments) => { Console.WriteLine($"Attach requested,arguments={arguments}"); };
adapter.OnAdapterMessage += (sender, msg) => { Console.WriteLine(msg); };
adapter.OnStatusChang += (sender, e) => { Console.WriteLine(e); };
adapter.RunServer(3515, debugCTS.Token);
adapter.Init(m_context.ServiceNode.GetService<IRuntimeDebuggingService>());
string js = System.IO.File.ReadAllText(@"c:\scripts\test.js");
//context.RunScript(q + " function internalCallback(s, callback) {return s + callback(s)};");
context.RunScript(js);
Console.ReadKey(); // wait for the debugger to attach
var ret = context.GlobalObject.CallFunction<string,string>("MyFunction","hello world");
The VS code it does not attach, but it throws an exception: ' Attached failed, engine is waiting for Launch' Looking in the code it seems like the debugger works only if there is a module, that it is not my case. What am I doing wrong?
you did nothing wrong. the debugger is designed to support module only.
can I suggest you change your design to use JavaScript module? If you have questions I'm glad to help.
I am able to debug in VS Code for console application targeting .NET Core 2.1 (similar to the RunScript example project's) , but getting "connect ETIMEDOUT 127.0.0.1:3515", when running the same codes (c#/javascript) in a Universal Windows console app or UWP app. Does VS DebuggerAdapter work with UWP applications? Thanks!
I've seen that there is a VSCode adapter, but I don't understand how it works and if it works. VSCode apart, is there any ways to attach the old VS debugger to js ?