Menu

Issue: Local Var not correct in debug

Help
2012-01-17
2013-03-06
  • Michael Jeanmotte

    Hello,

    Thanks a lot for MSPGCC. It's a really good solution to develop a software on a MSP430.

    I just need some help because I worked 3 days on this bug: all local var in main() are not corrects in debug.

    Configuration:

    - Windows 7
    - Eclipse Indigo Service Release 1
    - msp430-gcc 4.6.1 (Package mspgcc-20111224-experimental)
    - C/C++ GCC Cross Compiler Support 1.0.0.201109151620
    - C/C++ GDB Hardware Debugging 7.0.0.201109151620
    - MSP-FET430UIF with MSP430.dll developper package rev 3.02.01.009 from TI (MSP430.dll 3.2.1.9 and HIL.dll 1.2.6.0)
    - MSP430-gdbproxy.exe (14-11-2006)

    I did tests with another version of Eclipse: Helios but it was the same problem.

    Description:

    Example 1

    #include <msp430.h>

    unsigned short e = 0;

    int main(void)
    {
         WDTCTL = WDTPW + WDTHOLD; 
        
         while(1)
         {
                e++;
         }

         return 0;
    }

    This example give the correct value of e in debug.

    Example 2

    #include <msp430.h>

    int main(void)
    {
         WDTCTL = WDTPW + WDTHOLD; 

        unsigned short e = 0;
        
         while(1)
         {
                e++;
         }

         return 0;
    }

    This example give a wrong random value of e in debug.

    Example 3

    #include <msp430.h>

    int main(void)
    {
         WDTCTL = WDTPW + WDTHOLD; 

        unsigned short e = 0;
        unsigned short i = 1;
        unsigned short c = 2;
        
         while(1)
         {
                e++;
                i++;
                c++;
         }

         return 0;
    }

    This example give wrong values for e, i and c but I see i = e and c = i in debug. There is a shift of 1 in the vars.

    Example 4

    If I create a new function:

    void test()
    {
            unsigned short y = 0;

    y++;
    }

    I call it into the main function. In this case, I can see the correct value for the local var y in debug.

    Conclusion

    I try to correct this bug with all version of mspgcc MinGW provided on sourceforge but it was still the same think.
    The only solution I found is to use mspgcc4 (older version: mspgcc4-20110312.zip). With this version, I don't have a shift in my variables in debug but I can't use the latest microcontrollers provided by TI.

    Thanks in advance for your help.

     
  • Peter A. Bigot

    Peter A. Bigot - 2012-01-17

    I believe you have rediscovered this bug.  Workarounds should include enabling optimization, or moving the code to a different function and calling it from main().

     
  • Michael Jeanmotte

    Thanks Pabigot for the link and the workaround.

    I created a __main() function into main().

    In this case, the debug works correctly with local vars.

    Best Regards

     
  • Michael Jeanmotte

    By Curiosity, I put levels of O1, O2, O3 and OS for the optimization.

    In this case, I can not debug correctly.

    The pointer is still blocked on the first instruction (WDTCTL = WDTPW + WDTHOLD;) in the main function.

    The conclusion is I can use only the __main() solution.

     
  • RC Kung

    RC Kung - 2012-09-13

    Did you tried to set
    unsigned short e=0;
    before
    WDTCTL = WDTPW + WDTHOLD;
    ?

    I am using CCE 3. I do know the thing, but I do not know why.
    The declaration could not be put in the middle of the function.
    Maybe it is the same problem.

     

Log in to post a comment.