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.

DSS Script - Querying value of pointer dereferenced, struct element

Other Parts Discussed in Thread: MSP430F249

Hello,

I'm basically trying to query the value of a struct element using a DSS script (.js) where the only instance of the struct I have is a pointer.

For example the code is something along the lines of:


...

typedef struct
{
    INT32 my_element_a;
   
BOOL my_element_b;
   
UINT16 my_element_c;
}my_struct;

...

my_struct* my_struct_pointer;

...


My script (after connecting to the target and stopping at the appropriate breakpoint) does the following:


var my_address = debugSession.symbol.getAddress("my_struct_pointer->my_element_c")
var my_data = debugSession.memory.readData(Memory.Page.DATA, my_address, 16)


I am finding the following runtime error when my script reaches these lines:


getAddress: ENTRY sSymbol: my_struct_pointer->my_element_c
getAddress: Getting symbol package
getAddress: Looking-up symbol
SEVERE: Unable to get address for symbol: my_struct_pointer->my_element_c


1. How should one correctly access such variables (note that I have also tried java-like syntax of my_struct_pointer.my_element_c)? 

2. As an aside, if the struct were constant, should I be querying the PROGRAM or DATA page?  As I understand it, although my pointer would be in DATA memory, the address that I am searching for is in PROGRAM (non-volatile) memory, so I assume PROGRAM is correct in such a case; correct assumption?

 

Many thanks,


--

Joshua

 

 

  • Hi Joshua, I see the issue also. I can't seem to get it to work the way you want with DSS alone. I was able to use a combination of DSS and GEL. I did:

    var my_address = debugSession.expression.evaluate('&my_struct_pointer->my_element_c');

    var my_data = debugSession.memory.readData(Memory.Page.DATA, my_address, 16);

    Thanks ki

  • That's brilliant Ki, and thanks for the swift response! I'll check the GEL library in future if I can't perform something with DSS... I'm still not entirely clear though on why in my version, I needed to read the data from Memory.Page.PROGRAM in order for this to work. -- Joshua
  • Joshua Lawes said:
    I'm still not entirely clear though on why in my version, I needed to read the data from Memory.Page.PROGRAM in order for this to work.

    What is the connection and device type you are using (basically what target are you debugging on)?

  • Ki-Soo Lee said:
    What is the connection and device type you are using (basically what target are you debugging on)?

    I am using CCSv4.0.1.01001 with an MSP430F249 and attempting to test the project SW via DSS scripting in javascript.

  • MSP430 does not have separate paged memory (Program, IO, Data) but for your memory access calls you need to pass in a page parameter, so you would just use page 0 (the only option available). "Memory.Page.PROGRAM" is defined as "0" hence why that works. But it is a bit of a misnomer in your case.

    ki

  • Ok, got it.  Cheers!

  • Hello,

    When using the expression window in debug mode and displaying a structure variable , i can expand it and see all its members. how can i do the same from the scripting console -meaning how can i list the members of a variable of structure type and in general how can I from the scripting console using DSS access a structure typedef (like if i want to cast a pointer ,...)

    also , I have tried as suggested in order to get an address for a structure member but i did not work for me.

    var script = ScriptingEnvironment.instance();

    var debugServer = script.getServer("DebugServer.1");

    var debugSession = debugServer.openSession("*", "*");

    debugServer.setConfig("ccxmlFile.ccxml");

    debugSession.target.connect();

    i can do getAddress for the structures variable symbol but when i tried getting the address fro one of its members i get an error:

     xx=debugSession.expression.evaluate('&structVar->structMember');
    Error evaluating "&structVar->structMember": cannot dereference non-pointer
    at *(structVar)

    Can you please help

    Thanks

    Guy