Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

E4/JavaScript/Debugging

< E4‎ | JavaScript

Overview

The JavaScript debugger provides a generalized framework that allows one to plug-in support for any of the various JavaScript Runtimes. The architecture of the JavaScript debug framework is very similar to JDT's debug framework sharing many of the same abstractions:ui, debug model, and JSDI where the JSDI layer is a JavaScript specific set of interfaces analagous to Java's JDI. The JavaScript debugger was built with help from the JDT debug team and so no surprising provides a very similar look and feel and similar set of capabilities.

The bundles involved are:

  • org.eclipse.e4.languages.javascript.debug.ui
  • org.eclipse.e4.languages.javascript.debug.model
  • org.eclipse.e4.languages.javascript.debug.jsdi

Providing support for a specific JavaScript runtime is a matter of implementing JSDI and translating calls back to the underlying runtimes debugger API. e4 provides a JSDI implementation for the Rhino runtime that should be very helpful for those interested in providing an implementation for other runtimes.

Rhino implementation

There are three bundles in the implementation:

  • org.eclipse.e4.languages.javascript.debug.connect
  • org.eclipse.e4.languages.javascript.debug.jsdi.rhino
  • org.eclipse.e4.languages.javascript.debug.rhino

The Rhino implementation provides a remote debugger in two pieces: the JSDI implementation and the Rhino Debugger Implementation. The "connect" bundle provides the IPC and must be present for both pieces for the implementation to operate. It should be added that the Rhino Debugger implementation is not OSGi specific and the bundle/jars can be used in any Java application where Rhino is present.

For those interested in integrating the Rhino Debugger (and hoperfully familiar with the Rhino APIs) the class RhinoDebugger in addition to supporting the Rhin Debug APIs implements a ContextFactory.Listener and this is the means of integrating it. In Eclipse this is done with the following code snippet.

ContextFactory contextFactory = new ContextFactory();

// In eclipse this is generally provided via system property
String rhinoDebug = context.getProperty("rhino.debug");
if ( rhinoDebug != null) {
    RhinoDebugger debugger = new RhinoDebugger(rhinoDebug);
    debugger.start();
    contextFactory.addListener(debugger);
} 

The rhinoDebug string consists of a comma separated list of name=value pairs. The following property names are supported at the moment:

  • transport - The transport type to use - currently the only valid value is 'socket'
  • suspend - controls whether the runtime should be suspended until a debug client connects - 'y' or 'n'
  • port - the port to listen on

For example: transport=socket,suspend=true,address=9000

Back to the top