Debugging Your DSS Script Using CCS

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search


  • Image:Google-16x16.png Search for an article here:


Contents

Background

Debug Server Scripting and Code Composer Studio v4 are both built upon the same Debug Server foundation. Recent changes to DSS/CCS enable us, within the same instance of a Java Runtime to invoke both DSS and CCS and have both tools share the same Debug Server instance. The result is that target state is reflected in both tools.

We're going to leverage this fact and demonstrate an easy way to debug your DSS JavaScript by using the Rhino Javascript debugger to step through the script code while using CCS to inspect what is happening with the target.

Note: Some of the screenshots show an older version of CCSv4, hence the screenshots may be slightly outdated (but are still relevant)

Setup

First we're going to need to make a small change to '<INSTALL DIR>\CCSv4\scripting\bin\dss.bat' and the script we'll be debugging. If you have your own batch file / shell script you need to make a similar change.

  • Open dss.bat and locate the section called LAUNCH_SCRIPT
  • Edit the string %RHINO_SHELL% to be %RHINO_DEBUGGER%

See this section of the DSS topic for more information.

  • Next edit the script you wish to debug by adding a call to open a "CCSSession". Opening a "CCSSession" will launch an instance of CCSv4, which will be used to provide visibility into the target being debugged by the DSS script, and have it share the same debug context. The call to do this is:
script.getServer("CCSServer.1").openSession(".*");

This can be added anywhere after the ScriptingEnvironment is created:

// Create our scripting environment object - which is the 
// main entry point into any script and the factory for   
// creating other Scriptable Servers and Sessions
 
var script = ScriptingEnvironment.instance();
 
// Open a CCS Session to bring up the CCSv4 GUI which will share the same debug context
script.getServer("CCSServer.1").openSession(".*");

Debugging

  • Launch the Rhino Debugger by invoking 'dss <scriptname>.js'
  • Set a breakpoint on the line after the call to open a CCSSession. This is necessary because CCS is launched within the same JVM, but on a separate thread and the calling script has no way of knowing when the IDE is loaded.
Fig. 1: Setting a Rhino Breakpoint
  • Run to the breakpoint by clicking "Go" or hitting "F5"
Fig. 2: Running to the Rhino Breakpoint
  • Within a few seconds the CCS IDE should appear.
  • Launch a Debug Session for the same exact target that is currently being used by DSS. It is important that the target specified in the *.ccxml file used by CCSv4 is the same as the target specified by the *.ccxml file used by DSS. For information on the Target Setup utility in CCSv4 and launching a Debug Session, see the examples captured here. If there is a mismatch between the target configurations, the following error will be reported:
Fig. 3: Target Configuration Mismatch Error
  • If there is no mismatch, then CCSv4 will be able to connect to the current debug session created by DSS and you should now be able to step through your Javascript code in the Rhino Debugger (using Rhino's buttons or keyboard shortcuts) and after each step, CCS will be updated to reflect the current state of the target/development environment.
Fig. 4: Rhino Debugger and CCSv4

Running from a Java Application

If you are using DSS from a Java application and you wish to launch CCS, you will need to add the following JAR file to your CLASSPATH before running the Java application:

<INSTALL DIR>\ccsv4\eclipse\startup.jar

For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Debugging Your DSS Script Using CCS here.
Leave a Comment
Personal tools