Enabling Debugging Support
Support for the JSDT debugger must be enabled at program start using system property smila.scripting.debug, for example:
See JSDT/Debug/Rhino/Embedding_Rhino_Debugger#The_Connection_String for the full description of this string. The short version:
- address: the port number to open for the debugger to communicate on. No error will occur or be logged if the port is already in use.
- suspend: when set to y or true the scripting service will wait for a debugger to connect when initialized. However, as this happens during activation of a Declarative Service, which is limited by a timeout in the DS runtime, an error will occur if you do not connect a debugger within 30 seconds. Thus, suspend=n is usually the better choice.
- transport: must be socket.
Setting up the debugger
- Create a launch configuration for the debugger:
- Go to "Run" -> "Debug Configurations..."
- Click "Apply" and "Close"
- Go to "Window" -> "Preferences..."
- You may want to enable the option "Suspend for all script loads" so that the debugger stops the script execution immediately when a script is loaded.
Using the Debugger with scripts available in workspace
This should work if you have the scripts running in SMILA available in the workspace, e.g. by having the SMILA.application project from the source code open. So this should be the usual way to work within the SMILA development environment.
- Start SMILA with debugging enabled (see above).
- Open the script to debug and set a breakpoint (just like setting breakpoints in Java files: double-click in the grey column at the left side of the editor).
- Execute the script (e.g. invoke it via http://localhost:8080/smila/script/<script>.<function>).
- Eclipse should switch to the Debug perspective (it may display a dialog asking you to confirm the switch).
- The editor should show a copy of the script to debug and the line in which you have set the breakpoint should be marked. You can set additional breakpoints in both versions of the script. However, changes to the script must be done in the original version in SMILA.application.
- Use the debugger just like when debugging Java code.