Overview

When working with a specific project, it is usual to have a specific set of views, graphs, variables, breakpoints and expressions already pre-populated so at the start of every Debug Session you can easily resume from a previous configuration.

This application note describes a few practical tips to accomplish that, by customizing and automating some operations of a debug session using the scripting tool built into Code Composer Studio.

This application note does not exhaust the subject and will be continuously updated.

References

The procedure

The process of adding these elements (variables, graphs, breakpoints) to a debug session cannot be fully automated - i.e., to add these elements to a debug session, a core must be connected and either a program or its debug symbols needs to be loaded, so the javascript routines are able to properly find the variable names. However, the addition of these elements can be simplified to a simple click.

The addition of variables can be simplified to a single click, which starts with the common steps:

  • Open the Debug session you are working on.
  • Open the scripting console view (menu ViewScripting Console). This is useful to get help for the different commands used below and to test its parameters.

Expressions

The command to add an expression is called expAdd(). Using the scripting console view, you can get its help to see the parameters:


js:> help expAdd

Description: Add an expression to the expression view
Syntax: expAdd(expression)
Arguments:
  expression - the expression to add to the expression view

Description: Add an expression to the expression view with a given format
Syntax: expAdd(expression,format)
Arguments:
expression - the expression to add to the expression view
format - the display format that will be tried to use (if reasonable) when the value of expression is displayed 
This is an optional parameter. The format can be obtained from getHex, getDecimal, getBinary, getNatural, and getQValue.


Create a new file (menu FileOtherGeneralFile) and store it into your project directory. Give it a .js extension.


Open this file (sometimes it is needed to right click on it and select Open WithText Editor) then pass the commands to add variables, Memory-mapped registers (MMRs) and C-language expressions with a single mouse click. The example script below adds a menu entry named Show variables to the Scripts menu of the Debug session.


function load_vars()
{
  expRemoveAll();
  expAdd('REG_SYSTEM_MEM_VALID',getHex());
  expAdd('saram_start',getNatural());
  expAdd('count',getDecimal());
  expAdd('adcBuf[3]<<8',getHex());
}

hotmenu.addJSFunction("Show variables","load_vars()");


To use this newly created file, go back to the scripting console view and use the command loadJSfile() with the last parameter as true, so it can be automatically loaded when the debug session starts.


loadJSFile("C:\Users\user\workspace_v8\my_proj\show_variables.js",true);

Breakpoints

Similar syntax can be used to set breakpoints automatically by using the command ba() - Breakpoint Add.


js:> help ba

Description: Add a software breakpoint, depends on the input argument, different type of breakpoint will be added. If arg1 is null, than it will be added as an address breakpoint or a symbolic breakpoint. If both arguments are not null, source breakpoint will be added, the first argument must be a string and the second argument must be a number.
Syntax: ba(arg0,arg1)
Arguments: 
  arg0 - can be address (number) or symbolic (string).
  arg1 - the line number, if and only if arg0 is a file.
Returns: the breakpoint index handle.


And easily add a specific function and the menu entry to add these breakpoints, either to a function or a line at a source file of the active project:


function add_bkpts()
{
ba('adcProcess')
ba('main.c',139)
}

hotmenu.addJSFunction("Add Breakpoints",add_bkpts()");

Graphs

Just like the other previous cases, setting up graphs can be easily done as well. However, the only detail is that a graph properties file must be previously created:

  • In the active debug session, open a graph (menu ToolsGraph → and one of the options listed).
  • Set it up with the desired settings for Acquisition Buffer Size, Dsp Data Type, etc.
  • Click on the button Export and save its configuration data to a file in your project - it will have the default extension .graphProp

After that, use the function openAnalysisView()


js:> help openAnalysisView 

Description: opens an Analysis View.  E.g. to open a single time graph, openAnalysisView('Single Time','C:\\abc.graphProp')
Syntax: openAnalysisView(viewID,arg)
Arguments: 
  viewID - Name of the view. Please see feature specific view names For CCS Graphs Feature: 'Single Time', 'Dual Time',  'FFT Magnitude', 'FFT Magnitude Phase', 'Complex FFT', 'FFT Waterfall'
  arg - See feature specific interpretation of this argument For CCS Graphs: Used as a property file from which to load the graph property values


And easily add a specific function and the menu entry to add the graph:


function open_graph()
{
openAnalysisView('Dual Time','C:/Users/user/workspace_v8/my_proj/my_proj_graph.graphProp')
}

hotmenu.addJSFunction("Show graph","open_graph()");