14 Replies Latest reply on Nov 26, 2018 4:23 AM by user_13463998

    F10 not single stepping

    jgriswold_3357391

      Using the following environment:

      Environment:

      PSoC Creator  4.2 (4.2.0.641)

      Culture: English (United States)

      OS Version: Microsoft Windows NT 10.0.17134.0

      CLR Version: 4.0.30319.42000

       

      I find that pressing F10 (which lists itself as step-over) behaves like I anticipate F11 should behave (step-into).

       

      Am I doing something wrong? Is there a setting I've overlooked? A compile option?

       

      Anyone? Bueller?

       

      Thanks

        • 1. Re: F10 not single stepping
          DheerajK_81

          There is only a slight difference between the two.

           

          Both behave by jumping to the next instruction, one instruction at a time, but when you step into, it will go to every instruction in assembly, other files etc. and after complete execution returns to the main.c file. This gives you the overall flow including the backend.

           

          However, step over will always jump one instruction at a time inside the main.c file only. It will execute the instruction completely without showing you what is happening at the backend.

           

          Regards,

          Dheeraj

          • 2. Re: F10 not single stepping
            jgriswold_3357391

            The behavior you describe is the behavior I would expect, but I don't see that behavior.

             

            I find that pressing F10 (step over) will often step INTO a call, rather than stepping OVER.

             

            I was hoping to find a solution to the incorrect behavior.
            Thanks

            • 3. Re: F10 not single stepping
              DheerajK_81

              If you "step into" first and get inside some assembly or other files, then click on "step over" it will act like "step into" until it reaches an instruction in the main.c. Then it will perform as desired.

               

              Are you saying when you tried step over in main.c file, it went out of the main.c into another file?

               

              Regards,

              Dheeraj

              • 4. Re: F10 not single stepping
                jgriswold_3357391

                In any given .c file (in 35 years I have not found a different behavior in main.c), I expect F10 to execute one line of code, be it "x = 10;" or "x = f( 10);"
                I would expect F11 to do the "x = 10" and execute the call INTO f(), landing on the first line of f();

                 

                What I get is an inconsistent mix of F10 and F11 behavior when I press F10. Sometimes it steps over, sometimes it steps into.

                 

                I do find this vexes me, and am looking to see if I am doing something wrong.

                • 5. Re: F10 not single stepping
                  DheerajK_81

                  You will get a mix only if you F11 into a file other than main.c and then press F10. If you remain inside the main.c, then it works as expected.

                   

                  Do you see a different behavior in this particular scenario?

                   

                  Regards,

                  Dheeraj

                  • 6. Re: F10 not single stepping
                    jgriswold_3357391

                    Apparently I am confused (not that this is unusual).

                     

                    You are saying that if I have code like this in main.c

                    x=10;

                    x=f(10);

                     

                    and if I have code like this in somefile.c:

                    x=10;

                    x=f(10);

                     

                    pressing F10 in main will do a step-over on each line, but pressing F10 in somefile.c will do a step-over on the first line and a step-in on the second?

                     

                    If so, I'd characterize that as a bug in the debugger (note my sense of irony).

                     

                    Thanks

                    • 7. Re: F10 not single stepping
                      jgriswold_3357391

                      I'd like to bring to bear some of the Cypress documentation, neither piece of which differentiates between main.c and any other file.


                      F11 - Step Into - Executes a single line of code. If the line is a function call, the debugger will break at the first instruction in the function. If the line is not a function call, the debugger will break at the following line of code. Use this to verify that a line of code is doing what is expected. This function temporarily allows the processor to run until it finishes processing the instructions that make up the current line of code.

                       

                      F10 - Step Over - Executes a single line of code. The debugger will break at the following line of code. If the current line of code is a function call, the function will be executed without stopping. The debugger will then stop on the next line after the function call. Use this to verify that a line of code is doing what is expected. This function temporarily allows the processor to run until it finishes processing the instructions that make up the current line of code.

                       

                      As stated in the original question, I often get F11 behavior when I press F10.

                      • 8. Re: F10 not single stepping
                        DheerajK_81

                        Let me use your situation to better explain what I meant:

                         

                        In main.c file:

                        Line 1: x = 10;

                        Line 2: x = f(10);

                        Line 3: y = 10;

                         

                        Let the function f(num) be defined in somefile.c:

                        f(num){

                           //Some functions here

                           f1();

                           f2();

                        }

                         

                        Now when you step over in main.c then both the lines get executed as desired. Now suppose in line 2 you did a step into, it would go to the first line inside f(num) in somefile.c. If you step over now, it will execute the functions f1() and f2() without going into what the functions internals are. But it won't execute f(num) all together because you are already inside it.

                         

                        And above case is for c files. Suppose you step into an assembly file and you do a step over, then step into and step over might act the same way unless there occurs a loop label etc. where the step over will work. You will need to come back to main.c file in this case for them to work the best.

                         

                        I hope this makes sense.

                         

                        If this isn't the case for you, then it would be better if you could provide your project so that I can check your build settings.

                         

                        Regards,

                        Dheeraj

                        • 9. Re: F10 not single stepping
                          jgriswold_3357391

                          I didn't think this would be such a difficult issue.

                           

                          In your example, from line 1 of f(num), pressing F10 should execute f1() and f2() in order. That is what I would consider correct behavior.

                           

                          In real life, though, I find that pressing F10 here steps INTO f1(), and does not step OVER as we both agree would be correct.

                           

                          No assembly language files are used in my project.

                           

                          If you really think there's a project/build setting that determines how F10 works, please inform me. I cannot post my project due to IP concerns.

                           

                          Thanks for your continued assistance. With me, you must feel like Sisyphus

                          • 10. Re: F10 not single stepping
                            DheerajK_81

                            Please navigate to your project directory: C:\.....\<project_name>.cydsn\CortexM4\ARM_GCC_541\Debug\ in the command prompt.

                             

                            Then type in the following command:

                            "C:\Program Files (x86)\Cypress\PSoC Creator\4.2\PSoC Creator\import\gnu\arm\5.4.1\bin\arm-none-eabi-objdump" -dl <project_name>.elf

                             

                            If there is no line number information you will only see the disassembly. So, this will tell you about the lines getting optimized.

                             

                            Can you check if the lines you mention which aren't working correctly are being optimized or not?

                             

                            Regards,

                            Dheeraj

                            • 11. Re: F10 not single stepping
                              jgriswold_3357391

                              After a month, it's rather moot. I've moved on to another project. While painful, the IDE does, after a fashion, work.

                              Thank you.

                              • 12. Re: F10 not single stepping
                                user_13463998

                                Hi,

                                 

                                May be you've already left, I found this thread today.

                                And this sounds pretty interesting to me, so I tried myself, too.

                                Meantime, I learned the usage of "F10" and "F11", thank you!

                                 

                                I placed

                                y = 10 ;

                                y = g(10) ;

                                in main.c

                                and

                                x = 10 ;

                                x = f(10) ;

                                in given.c

                                 

                                In my project both y = 10; and x = 10; are skipped

                                as those variables are overwritten in the next line

                                the compiler kindly opt-out these lines, so I could not

                                step on these lines.

                                 

                                Meantime, in both main.c (y = g(10);) and given.c (x = f(10);)

                                I could step over the function. (I could not step into with "F10").

                                 

                                But the only exception was, when I was setting break point

                                inside f(), even with F10, debug stops inside f().

                                 

                                So I wonder if you can reproduce you problem with my project attached

                                or if by any chance you had a break point(s) in your "f()".

                                 

                                I may be totally missing the point but I'm just curious.

                                 

                                moto

                                 

                                main.c

                                ==================

                                #include "project.h"

                                #include "given.h"

                                #include <stdio.h>

                                 

                                char str[128] ; /* print buffer */

                                 

                                void init_hardware(void)

                                {

                                    CyGlobalIntEnable; /* Enable global interrupts. */

                                    UART_Start() ;

                                }

                                 

                                /* to compare with f(), I added g() */

                                int g(int arg)

                                {

                                    int i ;

                                    int sum = 0 ;

                                    for (i = 0 ; i < arg ; i++ ) {

                                        sum += i ;

                                    }

                                    return(sum) ;

                                }

                                 

                                int main(void)

                                {

                                    int count = 0 ;

                                    int x, y ;

                                  

                                    init_hardware() ;

                                  

                                    sprintf(str, "Debug Test (%s %s)\n", __DATE__, __TIME__) ;

                                    UART_UartPutString(str) ;

                                  

                                    y = 10 ;

                                    y = g(10) ;

                                  

                                    sprintf(str, "y = %d\n", y) ;

                                    UART_UartPutString(str) ;

                                  

                                    x = given_func() ;

                                 

                                 

                                    sprintf(str, "x = %d\n", x) ;

                                    UART_UartPutString(str) ;

                                  

                                    while(1) {

                                        sprintf(str, "Loop %d\n", count++) ;

                                        UART_UartPutString(str) ;

                                        CyDelay(1000) ; /* wait a sec */

                                    }

                                }

                                ==================

                                 

                                given.c

                                ==================

                                #include "project.h"

                                #include "given.h"

                                 

                                extern char str[] ; /* print buffer */

                                 

                                int f(int arg)

                                {

                                    int i ;

                                    int sum = 0 ;

                                    for (i = 0 ; i < arg ; i++ ) {

                                        sum += i ;

                                    }

                                    return(sum) ;

                                }

                                 

                                int given_func(void)

                                {

                                    int x, result ;

                                    x = 10 ;

                                    x = f(10) ;

                                    result = more_func(x) ;

                                    return( result ) ;

                                }

                                 

                                int more_func(int arg)

                                {

                                    int result = 0 ;

                                  

                                    if ((arg % 2) == 0) { /* arg is an even */

                                        result = 1 ;

                                    }

                                    return( result ) ;

                                }

                                ==================

                                • 13. Re: F10 not single stepping
                                  jgriswold_3357391

                                  Thanks, Moto, but I've had to move on. I can't dedicate any more time to this problem.

                                  • 14. Re: F10 not single stepping
                                    user_13463998

                                    OK, thanks for your reply anyway!

                                    moto