6 Replies Latest reply on Sep 19, 2013 3:35 AM by user_1377889

    Strange: Variable inspector data values wrong

    colin.mackenzie

       Hi,

         

      I often find the variable inspector shows 0 values. However, immediately after inspection I printf the values and they are not 0. I can't trust the inspector during breakpoint inspection.

         

      In the attached image, The accel and gyro structures are not in fact all zeros and immediately after the breakpoint they are printed without modification and the output is valid numbers.

         

      The acell/gyro structures contain a union of shorts, raw[3] and {roll,pitch,yaw}, I.e. I can view the roll/pitch/yaw as individual members or as a combined array. Could the union be throwing off the Inspector?

         

      C

        • 1. Re: Strange: Variable inspector data values wrong
          junichi.hiraoka

          I'm not sure to relation Inspector with PSoC5 compiler but,      

           

             

          There might be some difference of them.      

           

             

                

                        

             

          In Build Setting, ARM GCC/Compiler/Code Generation      

           

             

          Selective option of Struct Return Method are Register and Memory.      

           

             

          You would like to change this to various options and check it.      

           

             

          For another Custum Option is -fpack-struct[=n]     

           

             

               

                      

             

          Following are nonetheless GCC4.1.1 descriptions.     

           

             

          -fpcc-struct-return      

           

             

          Return short struct and union values in memory like longer ones,     

           

             

          rather than in registers. This convention is less efficient,     

           

             

          but it has the advantage of allowing intercallability between     

           

             

          GCC-compiled files and files compiled with other compilers,     

           

             

          particularly the Portable C Compiler (pcc).     

           

             

          The precise convention for returning structures in memory     

           

             

          depends on the target configuration macros.     

           

             

               

                      

             

          Short structures and unions are those whose size and alignment match that of some integer type.     

           

             

          Warning: code compiled with the -fpcc-struct-return switch     

           

             

          is not binary compatible with code compiled with the -freg-struct-return switch.     

           

             

          Use it to conform to a non-default application binary interface.     

           

             

               

                      

             

          -freg-struct-return      

           

             

          Return struct and union values in registers when possible.     

           

             

          This is more efficient for small structures than -fpcc-struct-return.     

           

             

          If you specify neither -fpcc-struct-return nor -freg-struct-return,     

           

             

          GCC defaults to whichever convention is standard for the target.     

           

             

          If there is no standard convention, GCC defaults to -fpcc-struct-return,     

           

             

          except on targets where GCC is the principal compiler. In those cases,     

           

             

          we can choose the standard, and we chose the more efficient register return alternative.     

           

             

               

                      

             

          Warning: code compiled with the -freg-struct-return switch is not binary compatible with code compiled with the -fpcc-struct-return switch. Use it to conform to a non-default application binary interface.     

           

             

               

                      

             

          -fpack-struct[=n]      

           

             

          Without a value specified, pack all structure members together without holes.     

           

             

          When a value is specified (which must be a small power of two),     

           

             

          pack structure members according to this value,     

           

             

          representing the maximum alignment (that is,     

           

             

          objects with default alignment requirements larger than     

           

             

          this will be output potentially unaligned at the next fitting location.     

           

             

               

                      

             

          Warning: the -fpack-struct switch causes GCC to generate code     

           

             

          that is not binary compatible with code generated without     

           

             

          that switch. Additionally, it makes the code suboptimal.     

           

             

          Use it to conform to a non-default application binary interface.

          • 2. Re: Strange: Variable inspector data values wrong
            user_1377889
                    The debugger is only able to display the value of a memory-location. When at the breakpoint the var is rept in a register you will not see the correct value. Try to set the optimization to "None"   
               
            Bob   
            • 3. Re: Strange: Variable inspector data values wrong
              colin.mackenzie

               Hi Bob, Thanks. I did make sure all optimizations were off in the compiler and went through all the settings. I am very familiar with GCC and I didn't see anything that could relate to it. I could try adding the volatile keyword or something. This is a global variable so could it be in a different memory bank or so? I have a lot of embedded experience but not on the cypress yet...pretty new.

              • 4. Re: Strange: Variable inspector data values wrong
                colin.mackenzie

                 Psoc73: I tried the Struct Return option both ways. No change. Good one though. The only one I didnt try was the pack-struct. I am not sure if that would work with the Cypress ABI.

                   

                I tried the volative keyword too, no luck. No matter what it just won't inspect my structures. Same with another structure that prints out timing info. My printfs work great, but inspecting it in the debugger it's all zeros.

                • 5. Re: Strange: Variable inspector data values wrong
                  junichi.hiraoka
                          Hi   
                  Whether did you use JTAG debugger or SWD debugger?   
                  If SWD, I can make re-examination for that.   
                  I have no idea from my experience.   
                  • 6. Re: Strange: Variable inspector data values wrong
                    user_1377889
                            Another way of getting some more information is to step through your assembly-file watching the memory locations while having opened the disasse3mbly-window. (Note that source-lines may not be contigous, known bug). Another source of problem can be equally named variables...   
                       
                    Bob