DSS - Launching CCS from DSS

From Texas Instruments Wiki
Jump to: navigation, search

Background

Debug Server Scripting and Code Composer Studio version 4 and greater are both built upon the same Debug Server foundation. It is possible, within the same instance of a Java Runtime, to invoke both DSS and CCS and have both tools share the same Debug Server instance. Hence,it is possible to attach CCS to a running debug session created by DSS. The result is that target state is reflected in both tools. This is useful if target debug visibility (via GUI) is needed when running a DSS script.

The below steps leverage this fact and show an example of an easy way to debug a 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 1: For CCSv5 and greater, this feature is only supported with JavaScript

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

NOTE 3: There are several differences in behavior depending on your CCS version. Please take note of the various subheading that are version specific

Setup

Setup steps for CCSv4.x up to CCSv5.2

If you are using a CCS version greater than 5.2 then this subsection can be skipped.

First we're going to need to make a small change to '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.

Setup steps for all versions

  • Next edit the script you wish to debug by adding a call to open a "CCSSession". Opening a "CCSSession" will launch an instance of CCS, 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 CCS GUI which will share the same debug context
script.getServer("CCSServer.1").openSession(".*");

Debugging

  • Launch the Rhino Debugger:
    • CCSv4.x to CCSv5.2:
> dss <scriptname>.js
    • CCSv5.3 and later:
> dss -dss.debug <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.

Debugging steps for CCSv4.x up to CCSv5.1

  • 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 CCS 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

Debugging steps for CCSv5.2 and greater

  • As shown in the above screenshot, 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.

NOTE: There may be an issue where CCS will launch in the 'Resource' perspective. You will need to manually open the 'CCS Debug' perspective. Otherwise you will not see any action in the CCS GUI as your script executes. To open the 'CCS Debug' perspective, go to 'Window -> Open Perspective -> Other..' and then select 'CCS Debug' from the list of perspectives.

Examples

CCS versions 5.2 and greater come with an example script on how to launch CCS from a DSS script. The example script is located in:

  • CCSv5: <INSTALL DIR>\ccsv5\ccs_base\scripting\examples\DebugServerExamples
  • CCSv6: <INSTALL DIR>\ccsv6\ccs_base\scripting\examples\DebugServerExamples
  • CCSv7: <INSTALL DIR>\ccsv7\ccs_base\scripting\examples\DebugServerExamples

The example script name is 'CCSSession.js'.

To run the example:

  • Open command prompt
  • Browse to the location of the 'CCSSession.js' script
  • Run the script in debug mode to launch in the Rhino Debugger
    • Windows: > ..\..\bin\dss.bat -dss.debug CCSSession.js
  • Set a breakpoint in 'CCSSession.js' at line 27
  • Run the script in the debugger until it reaches the breakpoint (Press 'Go' button)
  • Wait until CCS GUI appears. Make sure it is in the 'CCS Debug' perspective (See the NOTE in the section above under 'Debugging steps for CCSv5.2 and greater')
  • Continue to single step through the script and watch as the CCS GUI is automated by the script

Running from a Java Application

For CCSv4.x

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

You must also be using JDK version 6 or earlier.

Note that this feature is NOT supported with CCSv5 and greater.