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.

Local variables displayed incorrectly

Other Parts Discussed in Thread: MSP430F5438

In the attached screen capture local variables 'unsigned long valueL' and 'register int RandValue' are displayed incorrectly.

I'm using version 4.2.1 of Code Composer Studio on Windows XP, MSP430 USB Debug Interface and MSP430F5438.  TI, email me if you would like a copy of the .out file.

Unless there is some optimization that I'm not aware of that's effecting the application... currently opt_level=0, opt_for_speed=4.  All other optimizations are the defaults as  per the making a new project.

If this is going to be fixed by fixing IncidentReport:  SDSCM00038624 please give this item some priority.

At present I can't debug this part of the code - which is ok.  If it occurs in other parts of the code that's could be a problem.  Any workarounds welcome.

5238.screen1.zip

  • Peter,

    I checked and the issue you mentioned seems strictly related to SDSCM00038624 - a fix is implemented and is planned for release 4.2.2.

    Best regards,

    Rafael

  • Peter,

    I got confused. SDSCM00038624 only refers to the message "unknown register ID", but not to the fact the local variables stored in registers do not show in the Watch window.

    In this case when the optimizer stores variables in registers for performance reasons, the debug information is lost and the watch window has no way to get their values anymore. This is more likely to occur if the local variables are parameters passed to the function.

    If you see no disruption in code execution, then it is a normal behaviour of the optimization process. Just checking, are you able to see the local variable in the watch window if you disable the optimizer?

    Regards,

    Rafael

  • Part 1:
    Rafael, how do you disable the optimizer?  From what I can see in TI doc SLAU132C, MSP430 Optimizing C C++ Compiler v 3.1 User's Guide (Rev. C), optimizations are as off as they can be - opt_level=0 and opt_for_speed=4 as per my post.  Which happens to be the default values.

    I've created a new project after installing 4.2.1 and made the following settings changes:
    code_model: large
    data_model: large
    near_data: globals
    Linker/basic options/stack size             768
    Linker/basic options/heap size             160
    Set mV target = 3300
    Select "lnk_msp430f5438"                    Properties / CCS Build / General / Linker Command File
    Select "rts430xl.lib"                     Properties / CCS Build / General / Runtime Support Library
    CCS Debug/Target/Disable Interrrupts        When Source Stepping
    opt_level=0
    opt_for_speed=4

    Part 2:
    Re this part "In this case when the optimizer stores variables in registers for performance reasons, the debug information is lost and the watch window has no way to get their values anymore. This is more likely to occur if the local variables are parameters passed to the function."
    if a value is in register variable, my attitude is if the debugger is on the line of the function call the variable is in scope, stored in a register as it's passed to the function, and you should be able to see it's value.  Don't see how the debug info is lost.  Eg, noting that the variable maybe assigned R9 (from list file) but the function called requires it in R15. The debugger can keep track of this.  I appreciate how the compiler optimises the register variable to limit their scope to the minimum required.  Seen this in the assembler.  Maybe you can explain this further.

    In your post I presume Watch window meant Local window/tab.

  • Peter,

    The optimizer is turned off if you leave the option Optimization Level as completely blank in the Build Options. The optimizer is turned on when the level is set from 0 to 3.

    While variables stored in registers are not displayed in the Local/watch window, I will have to leave to the compiler experts to cover the exact reason of why this happens or was designed this way. However, keep in mind the debugger interface encompasses several device families, therefore while it is straightforward to track down a variable in MSP, the complexity increases exponentially when dealing with other platforms.

    Cheers,

    Rafael

     

  • Re "The optimizer is turned off if you leave the option Optimization Level as completely blank in the Build Options", once an option is selected you can't go back to blank.  I got it back to blank by starting a new project.  As you said with 'opt_level=0, opt_for_speed=4' parts of the optimiser is still on and I could see that when stepping through the code as the debugger would skip some lines of C code.

    The orignal posted problem stands.  That is, when 'opt_level=0, opt_for_speed=4' code composer can display incorrect info in the Local window.
    My workaround is turn off the optimizer - ie set Optimization Level to blank, which "for me" leaves me with no problem.