ClearScript, V8 and Eclipse

Jun 20, 2015 at 6:29 PM
I have been trying to figure out for ages why I could not get Eclipse debugging working with my V8 scripts using ClearScript. Finally made a breakthrough.

The way my C# program uses ClearScript is that I run a standard C# program which calls a V8 script. The V8 script just runs, I have a call back set to check for runaway task and provide some hooks to call back into my C# program for additional complex "provider functions". Therefore when the V8 script terminates it is finished.

In the C# code I call ScriptEngine.execute(...) and it runs the code.

I have modified the sequence so that I have a main() in the V8 script and after running the code I issue a MessageBox.Show(...) to allow the Debugger to be connected, wait for connection then release the MessageBox and run ScriptEngine.executecommand("main()")

This all seems to be a bit prescriptive and am wondering if there is another way to hook the code into Eclipse/V8 debugger so that the code is hooked into the debugger prior to the 1st actual execution allowing me to set up breakpoints and without requiring all code to be inside a function which I execute after the initial ScriptEngine.execute??

Ideally an initial CallBack on Script Load assuming at this point that the Eclipse/V8 Debugger would be able to see the RunTime environment.
Coordinator
Jun 21, 2015 at 6:29 PM
Hello!

JavaScript code can contain one or more debugger statements (placed there manually or inserted programmatically). When debugging is enabled, this statement causes V8 to halt script execution. In this state you can attach the Eclipse debugger. If a debugger is already attached, the statement acts as a break point.

Good luck!
Marked as answer by egooner on 6/22/2015 at 2:26 PM
Jun 22, 2015 at 10:26 PM
Thanks. Sometimes it's the simple things that pass us by. I modified my code to create a pop up after the V8 Engine is initialized to allow the debugger to be connected. Then added a debugger statement and worked a treat.