SCWells72 wrote:
I was wondering if anyone had any experience with using this debugger against an embedded Rhino engine successfully. I imagine it's too much to ask for remote debugging, but minimally if I could tell the app to bring up the debugger window when (certain) scripts are executing and allow me to set breakpoints, step through execution, etc.
I run the debugger inside Tomcat -- not remotely, but locally, such that the Tomcat process will literally pop up the GUI when I execute a script inside the process. The code to do it is buried inside a big framework of mine, but it looks like it's a few hundred lines of code and the general approach is to instantiate org.mozilla.javascript.tools.debugger.Dim and use its attachTo() method to attach it to the context factory my embedding is using. Interestingly, as I look at the code, I attach it twice, but I suspect this is just bad coding.
I then attach an org.mozilla.javascript.tools.debugger.SwingGui to the Dim. Then when executing a script we need to use the setScopeProvider() method to set the scope and then show the GUI. We also need to tell the GUI not to do System.exit() via setExitAction.
I also have a profoundly ugly way of setting breakpoints by starting a JavaScript source line with >; I then parse these out when executing scripts, removing them from the code and setting breakpoints in the debugger using Dim.sourceInfo(). There may be a cleaner way but this has worked for me.
So it's quite possible in principle, but at least for me, was not a trivial task to set up the first time ... hope this helps you or someone else curiously reading this thread.
-- David P. Caldwell http://www.inonit.com/ _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
