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.

calling a subroutine with parameters from a script



Is there a way to call a subroutine/function on the target and pass parameters to it and view the value that it returns?  This is trivial in other debuggers (such as gdb) that I have used in the past, but I can find no way to do this with DSS or GEL.  I am using CCS Version: 5.1.0.09000 on an MSP430, if that matters.

I need this functionality for scripted tests, where I will be testing the API of a function against a number of test vectors passed in as parameters, and viewing the result passed back by the return statement in the function.  I envision something along the lines of:

debugSession.expression.evaluate('GEL_call("API_under_test(123,456)")');

Is there some way to do this with either GEL or javascripting to the DSS?

  • Hi Robert,

    the expression.evaluate() API should return whatever value is returned from the GEL function that you called. So if your "GEL_call" function returns a value, that will be the return value of expression.evaluate

    Thanks

    ki

  • You missed the whole point, Ki.  I want to call not a GEL function, but I want a GEL or DSS way to call a C function that executes on the unit under test -- the target board.  Instead of GEL_go() I want some sort of GEL_call().  Is there any way to do this from a script?  Since it is C code, not C++ code, we do not need to handle thrown exceptions, but we do need to be able to handle functions with more than one return statement in the compiled C code on the target.

    Not to belabor the point, but since you missed it the first time, I will say all this a different way.  I have a C source code file, lets call it foo.c, and it looks something like this:

    int foo(char a, int b) {

        if (a == 'A") {

            return 1+b;

        } else {

            return 2+b;

        }

    }

    Now what I need to be able to do from the script is call foo() with several different sets of parameters, like this:

    x = foo("A",3);

    y=foo("B",7);

    etc.

    I need to call -- from the script -- the compiled C function foo() that resides on the embedded target board that is being controlled by DSS, and I need to be able to capture the value that the function returns.

    I need to be able to do this for various arbitrary functions, not just the example function foo().  This is so I can demonstrate that the API for the function behaves according to its specification.

    Is there any way to do this without having to write test scaffolding code in C on the embedded target?  The idea is to be able to test these API's on the code image that we will be shipping with the product, not on some modified binary image that is used just for testing.  Our regulated environment prohibits the presence of "dead code", so I cannot ship with test scaffolding in the code.  This functionality is a peice of cake with gdb, butt I am forced to use the code composer environment on this project.  Surely I am not the only person who has ever needed to do this dort of thing.

  • Robert Brown said:
    Not to belabor the point, but since you missed it the first time

    Yup I misunderstood. Sorry about that. I get it now.

    What you are asking for is not supported via GEL or DSS as far as I know. I suppose you can do some trickery and do this with some register manipulation like setting the PC to the function entry point and read the return registers and such but I think you are looking for a cleaner solution. From what I have seen, most people do write that additional test harness code that you want to avoid. Sorry.

    ki

  • Yes, Ki-Soo, it seems that DSS provides no such capability.  The gnu debugger, gdb, provides this ability when used with the gcc compiler, so I was hoping (and expecting) that DSS also provided a similar capability.  Since it does not, I have developed a technique of implementing a trampoline for each such function that I need to call in my scripted tests.  I just yesterday got a script working to automatically generate these trampolines for me, which makes it much easier and less error prone.  These trampolines exist in a small C source code file that is compiled and linked with the target image.  I have already hand coded a few test cases that use these trampolines, and I am now starting to work on a script to automatically generate the javascript code to interface with these trampolines.  Once that is doen, I will have something close to what I originally asked for, but its been a long journey.

    Thanks for your help!