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.

Can static variable be viewed in Watch and Memory?

Anonymous
Anonymous
Guru 17045 points
Hi All,
 
I would like to ask a question on static variables.
 
When I tried to observe a static variable from either

1.      Memory, by typing its variable name in verbatim

2.      Watch, by typing its variable name in verbatim

I in these two cases all got the same error message: “identifier not found: variable XXX”.
 
So where are static variables stored? Why they are not watchable?
 
 
 
Thanks,
Zheng
  • Zheng,

    When you declare something static, it's location is not made public so you can't watch it in CCS. Often, the optimizer will store a static variable in a register instead of in memory. If you need to watch something, you will have to make it public and turn off optimizing.

    I know this is annoying. I would like to use static variables to maintain encapsulation. When debugging your code and using watch, you will have to keep them public. Then when the bugs are gone, make them static.

     

    Luke

  • Anonymous
    0 Anonymous in reply to Luke Postema

    Dear Luke,

    I see it, thanks for the clear explanation.

    Zheng

  •  

    Hello Zheng,

    As already mentioned the static variable are not visible in CCS and MAP file because they can be in registers.

    That is the answer that I have received from TI compiler team too.

    However in huge projects the 99% of static varibales are located in memory.

    Funny enoght the static varible information is available in your output file /DWARF sections/

    If you use the TI tools "ofd6x.exe ""  you can generate  XML file with all your STATIC data.and coressponding memory adresses.

    Even more  one of my colegues wrote small Python/QT GUI program that makes browsing of all your data Static and non static

    Up until now I havent seen an situation when I cannot. Watch at Static

    I can imagine that in small software projects the compiler optimize the code and static data in not visible anymore.

    Greetings,

    Mirtcho Maglijanov

     

     

  • Hi Mirtcho, I tried ofd2000.exe to show 'static' variables and function in xml file. The command is: ofd2000 -v -o=xx.xml yy.out
    The question is : 1) static variables and memory address could not be found in xml file still . 2) static functions could be found in xml file, however, there is no memory address, also the 'offset' data is hard to translate as address.
    Could you please details me how to use ofd2000.exe to show the static variables/functions memory address? thanks.
  • sir zhang58 said:
    Could you please details me how to use ofd2000.exe to show the static variables/functions memory address?

    Alternatively, there is a syntax you can use in the CCS expression view to display static variables. See CCS6.1 cannot display global static variables in debug mode

  • Hi Chester,
    Thanks for your information. I tried the method in CCS and it works.
    However, could you please share me the way how to display all the extern/static variables in a map or xml or other file? According to the previous discussion in this webpage, it seems ofd2000.exe should be a way, but I tried and failed. In some cases, we need to review all the variables/functions memory address in a file, so it is a really requirements. thanks.