This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Dear Community,
QUESTION - Using a script (javascript or gel or something else) is there a way to set the PC (Program Counter) to the start of an arbitrary function? I need this to assist my performing unit tests. I want to automate my unit tests as much as possible and if I had a script then I could repeat it and I would use it to set variables and report the results of variables. If I must manually use CCSv4 to set the PC is it possible to have a script at least bring up the source for an arbitrary file, thus speeding up the manual processing of setting the PC?
BACKGROUND:
I'm having to write unit tests for my code, a necessary evil. My application runs on a F28335 and is using using DSPBIOS 5.40 and using CCSv4. Anyway it has several tasks that pending on data which will arrive when the chip is part of the larger system. Meanwhile I'm using an ezDSP F28335 board to "prove" the code works at a unit level. I tried to get Parasoft's C++Test to run on this board but discovered (after much wasted time) the runTime was much to big to fit within the maximum 0x4000 stack (they recommended 0x9000!)
Because the programs tasks are pending on data that will never arrive the fastest way I know to overcome this (without changing the program) is to force the program counter to the first line of executable code within the function that I need to unit test. I'd like to use javascript to automate the process but I'd be willing to use gel if necessary.
Thanks
David,
Since you are using CCS 4 then you can use DSS scripting. Some info is here:
http://tiexpressdsp.com/index.php/Debug_Server_Scripting
This allows you to load code, read/set the PC, read/write memory locations, set breakpoints, run the code, etc using perl or java scripts.
PS:
For readers using CCS V3.3, it supports CCS Scripting. There is some information on this page:
http://tiexpressdsp.com/index.php/CCStudio_Scripting
PPS:
I'm going to move this thread to the CCS forum since there will be more scripting experts watching that forum.
DSS is definitely the way to go. You can also run DSS scripts within CCS from the Scripting Console (access from the view menu).
John
Lori,
I searched the Debug_Server_Scripting url you mention and there is no mention of setting the PC (Program Counter) anywhere in the document. I had already searched that document. I'm not doubting that DSS is able to do it but when I did a dump of all the js there were no commands which implied they set the PC and I can find no js or DSS documentation that explicitly states that it is possible to set the PC to a specific file. I need this capability to arbitrarily jump to a function that I need to unit test.
Thanks
David,
In my CCS 4 install the API documentation is under:
C:/Program Files/Texas Instruments/ccsv4/scripting/docs/DS_API/index.html
Under "memory" there is a "readRegister" and "writeRegister".
Scripts I've done are using inline java in a perl script so my call looks like:
$tgt->{memory}->writeRegister("PC",$start_addr);
Where start_addr is a global symbol in 28x application.
-Lori
Laurie,
I guess that I'll be able to refer to my functions as variable names and set the PC using a refernce to that function name but I have to figure that out but I guess I'm much further. I'm going to pospone verifying your answer until I can post an answer which actually shows how to set the PC to the start of a function using js. I'll work on it tonight.
Thanks
You should also consider the expression.evaluate(sExpr) DSS API where sExpr is any valid GEL expression. Using GEL in this context gives you more flexibility and power within your scripts. The expression can contain any valid symbol information that has been loaded in your debug session. So, for example, if the expression was "PC = functionName;" the evaluation of this expression would set the program counter to a new value.
Raj
Raju,
I can't wait to try this but I'm under a tight deadline today. I'm going to try it tonight from home. As soon as I have it working I'll mark it as verified.
Thank you very much!
To expand on Lori's suggestion, I often do something like:
// get address of functionName and set PC to that address.
var address = debugSession.symbol.getAddress("functionName")
debugSession.memory.writeRegister("PC", address);
Dear Ki-Soo Lee,
Thank you for this handy suggestion. I no longer have CCSv40 installed on my PC so I cannot verify the answer. If I resume work on that old project I'll verify your answer then.
Most Thankfully,
David