Hi,
this post got quite lenghty, sorry about that..
I have a DSS script which initialises/configures the analysis properties (i.e. startAddress, transport, etc.), runs the analysis, executes a test set and tries to retrieve the analyzer results. The problem is that the analyser does not produce any results; the exported CSV files have only column headers but no data. I need some help to get those results.
I have CCSv6.0 installed in Ubuntu Linux and the target I'm using is C66xx.
First I tried measuring code coverage via CSS IDE and it worked: CCS started to receive the PC trace as expected on given startAddress and Code Coverage information could be extracted. No problem.
Then I tried to repeat the same thing using DSS scripts. I reused the same ccxml file and used the same analysis properties which were proven to work. And yes, the script "seems" to work to an certain extent:
- the connection is established since I'm able to get information about the target, all necessary object instances (i.e. DebugSession, ScriptAnalysisSession, etc.) are created, symbol used as startAddress can be found from target, etc.
- it seems that at least SOMETHING is received from the analysis, since if I increase the size of the buffer, the time for extracting the analysis information increases also.
- when the testcase used in code coverage measurement has been executed and trace data should be available for retrieval, invocation for analyzer.waitForEndOfData -returns after few seconds and does not wait indefinitely.
- call to analyzer.exportDataToCSV creates csv-file with log headers which are showing column names you would expect for code coverage data.
..BUT:
- what I do NOT really know is that is PC trace (or code coverage, or whatever analysis is used) really started when the given startAddress is executed and is some trace really retrieved.
- even IF something is retrieved, theres nothing is available in csv -files.
I also tried to use a predefined analysis settings, i.e. I saved the settings from CCS GUI with a name and used loadAnalysis -method to load those settings. Unfortunately it didn't work either, but caused an obscure exception in CoreTrace.js.
I'm starting to be out of ideas here. One culprit might be that I'm just using those Analysis, Analyzer, AnalysisSession, etc. objects incorrectly. I just can't get my head around on which is what.. I've been following the script examples coming with CCS and I've tried to use guidelines available in TI pages, but I haven't been able to find any clear omissions or incorrect configurations in my code.
Also, there are some obscure errors/exceptions/warnings coming up, from time to time, when trying to execute the script. (See below)
***
warning: dispatch exception: Ti::Sds::Trace::ChannelError
identity: 6978C715-BAEE-4ED6-88FD-7BDAC8038C81
facet:
operation: GetChannelAttribute
warning: dispatch exception: Ti::Sds::Trace::ChannelError
identity: 6978C715-BAEE-4ED6-88FD-7BDAC8038C81
facet:
operation: GetChannelAttribute
***
..this error/warning doesn't (?) seem to affect the execution of the script. If it does, I don't know how.
The script I've created is included below. The script defines a class named Rowboat (don't ask me why) which handles the initialisation of connections, execution of testcases, extraction of results, etc. The executed script is implemented below the class definition.
=============================================
/**
* script file starts
*/
importPackage(Packages.com.ti.debug.engine.scripting);
importPackage(Packages.com.ti.ccstudio.scripting.environment);
importPackage(Packages.com.ti.dvt.engine.scripting);
importPackage(Packages.com.ti.dvt.analysis.traceviewer.activity);
importPackage(Packages.java.lang);
importPackage(Packages.java.io);
importPackage(Packages.java.util);
var Rowboat = function(){
this.scriptingEnv = ScriptingEnvironment.instance();
this.debugServer = this.scriptingEnv.getServer("DebugServer.1");
this.debugServer.setConfig("/home/tk/ti/CCSTargetConfigurations/codecoverage.ccxml");
this.debugSession=null;
this.dvtServer = null;
this.analysisSession=null;
this.outFilePath = "/home/tk/my.out";
};
Rowboat.prototype.initiateConnections = function(){
this.debugSession = this.debugServer.openSession("Spectrum Digital XDSPRO STM LAN Emulator_0/C66xx_0");
this.debugSession.target.connect(true);
this.scriptingEnv.traceWrite("Loading symbols from "+this.outFilePath);
try{
this.debugSession.symbol.load(this.outFilePath);
}catch(err){
print("Exception thrown during loading of symbols; "+err.message);
};
this.dvtServer = this.scriptingEnv.getServer("DVTServer.1");
this.scriptingEnv.traceWrite("DVT server created");
this.analysisSession = this.dvtServer.openAnalysisSession();
};
Rowboat.prototype.terminateConnections = function(){
this.scriptingEnv.traceWrite("**** Rowboat.terminateConnections invoked ***");
try{
if(this.analysisSession!=null){
this.analysisSession.terminate();
}
this.dvtServer.stop();
this.debugSession.terminate();
this.debugServer.stop();
//this.scriptingEnv.traceEnd();
if(!this.debugSession.target.isConnected()){
this.debugSession.target.disconnect();
this.scriptingEnv.traceWrite("Disconnected from target:"+this.scriptingEnv.target.isConnected());
}
}
catch(err){
print("Exception caught in Rowboat.terminateConnections(): "+err.message);
}
};
Rowboat.prototype.initiateAnalysisSettings = function(){
this.scriptingEnv.traceWrite("*** Rowboat.initiateAnalysisSettings invoked ***");
try{
this.scriptingEnv.traceWrite("invoking loadAnalysis.. ");
this.analysis = this.analysisSession.loadAnalysis("Hardware Trace Analyzer/Code Coverage");
this.analysis.setProperty("core",this.debugSession.getName());
this.analysis.setProperty("startAddress","testcase_1");
this.analysis.setProperty("bufferSize","512 kB");
this.analysis.setProperty("receiver","Pro_Trace");
this.analysis.setProperty("transportType", "Pro Trace");
}catch(err){
print("Exception caught in Rowboat.initiateAnalysisSettings(): "+err.message);
}
};
Rowboat.prototype.activateAnalysis = function(duration){
this.scriptingEnv.traceWrite("*** activateAnalysis invoked ***");
this.debugSession.target.runAsynch();
this.scriptingEnv.traceWrite("print out analysis object to see if it's valid: "+this.analysis.getName());
this.analysis.run();
this.scriptingEnv.traceWrite("Analysis started");
};
Rowboat.prototype.runTests = function(duration){
this.scriptingEnv.traceWrite("*** Rowboat.runTests invoked ***");
var runTestsResult = runCommand("python","runTestCases.py");
this.scriptingEnv.traceWrite("Sleeping "+duration+ " ms.. ");
Thread.sleep(duration);
};
Rowboat.prototype.getAnalysisResults = function(){
this.scriptingEnv.traceWrite("*** getAnalysisResults invoked ***");
try{
var table=0;
this.debugSession.target.halt();
Thread.sleep(5000);
var analyzer=this.analysis.findAnalyzerByName("Code Coverage");
this.scriptingEnv.traceWrite("Waiting end of analysis data from analyzer: "+ analyzer.getName());
analyzer.waitForEndOfData(60000, table);
this.scriptingEnv.traceWrite("All data received from analyzer.. ");
this.scriptingEnv.traceWrite("Start exporting measurement results to csv file");
var cwd = this.scriptingEnv.getCurrentDirectory();
this.scriptingEnv.traceWrite("Exporting results to " + cwd);
analyzer.exportDataToCSV("Line Coverage", cwd+"/"+"CodeCoverageLogs.csv", null);
this.scriptingEnv.traceWrite("Trying to get dataset from analysis session.. ");
var dataset = this.analysisSession.getDataSet();
if(dataset.length>0){
for(var i=0;i>dataset.length;i++){
this.scriptingEnv.traceWrite(dataset[i]);
}
}else{
this.scriptingEnv.traceWrite("No dataset received.");
}
analyzer.end();
this.scriptingEnv.traceWrite("results exported");
this.analysisSession.endAnalysis(this.analysis);
}
catch(err){
this.scriptingEnv.traceWrite("Exception caught on line "+err.lineNumber+" with message: "+err.message);
}
};
var rowboat=new Rowboat();
rowboat.initiateConnections();
rowboat.initiateAnalysisSettings();
rowboat.activateAnalysis(5000);
rowboat.runTests(25000);
rowboat.getAnalysisResults();
rowboat.terminateConnections();
print("Script exiting..");
/**
* script file ends
*/