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.

CCS/DRA744: DSS - getAddress on local variable and private class variable error

Part Number: DRA744

Tool/software: Code Composer Studio

I'm facing an issue with the TI DSS debug scripting. My code is C++ based, using the TI simulator, and I am trying to set a breakpoint on an ASM label inside a class function, and:
- Read a local variable address
- Read a private class variable address

I am able to set the breakpoint, but upon trying to read the variable addresses, it’s as if they were not in scope.
My code looks something like this (compiled with no optimization):

myClass.h:

class MyClass
{
private:
       int m_Var;
public:
       MyClass() : m_Var(0) {}
       void calc(void)
       {
               int local = 0;
               local++;
               asm(" .global dump\ndump: "); //label for breakpoint
                 local++;
        }
}

My DSS script looks like this:

var script = ScriptingEnvironment.instance();
ds = script.getServer("DebugServer.1");
var ds;
ds.setConfig(...); //simulator
var debugSession0 = ds.openSession(".*_0");
debugSession0.target.connect();
debugSession0.memory.loadProgram(...);
var pcsave = debugSession0.symbol.getAddress("dump");
debugSession0.breakpoint.add(pcsave);
debugSession0.target.run();

debugSession0.target.waitForHalt();
if(debugSession0.expression.evaluate("PC") == pcsave)
{
    print(pcsave)
    var my_address = debugSession0.symbol.getAddress("local");
    print(my_address);
    var my_address = debugSession0.symbol.getAddress("this->m_Var"); //tried with (*this).m_Var as well, and with .expression.evaluate
    print(my_address);
    debugSession0.target.run();
}


Presumably the debugger should see both variables as the breakpoint stops at the label and they should be in scope, but I am getting „Unable to get address for symbol” errors from DSS.

Can anybody please help me with this issue?

  • Manfred,

    If you do the same thing manually in CCS. i.e. set a breakpoint at the asm() statement do you see local in the variables view?  The reason I ask is if I have optimization on in the compiler that will be optimized out unless I have volatile in front of the declaration of local.

    Regards,
    John

  • Hi John,

    I am having this issue, and CCS does not let me set a breakpoint on the asm(" .global dump\ndump: "); line at all. With DSS there seems to be some action as the program halts and I can read global variables.

    Regards,

    Dan

  • Dan,

    I am using a different device but I think I can still show what is going on.

    In my case I am using C but I have created a function john() that does the same as what you have in your C++ method.

    In CCS with the default build options I am not able to set a breakpoint on any of the source lines inside john() other than the end brace as it is optimized out.  When I look at the disassembly I can can see the dump label is applied to this end brace.

    By looking at the variables view I can see that local is not present and if I explicitly add it to the expressions view it will tell me that it doesn't exist:

    Thus if I try to access that variable from DSS I will get the same error.

    Now if I change local to be volatile in my code then it will not be optimized away.  I am now able to set breakpoints inside john() and I can see that there is assembly code associated with the source lines:

    If I look in the variables and expressions view I can see that local exists:

    If I try to set a breakpoint on the asm() line it will set it on the local++ line after it which makes sense.

    Regards,

    John