GDB step in delays

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
6
down vote

favorite
3












I am making a nice presentation of ARM assembly code execution and I would need GDB to step the code every 1 second infinitely long (well until I press CTRL+C). Has anyone got solution?



I don't want to keep on standing next to the keyboard and stepping the program when visitors come visit my stall.







share|improve this question


























    up vote
    6
    down vote

    favorite
    3












    I am making a nice presentation of ARM assembly code execution and I would need GDB to step the code every 1 second infinitely long (well until I press CTRL+C). Has anyone got solution?



    I don't want to keep on standing next to the keyboard and stepping the program when visitors come visit my stall.







    share|improve this question
























      up vote
      6
      down vote

      favorite
      3









      up vote
      6
      down vote

      favorite
      3






      3





      I am making a nice presentation of ARM assembly code execution and I would need GDB to step the code every 1 second infinitely long (well until I press CTRL+C). Has anyone got solution?



      I don't want to keep on standing next to the keyboard and stepping the program when visitors come visit my stall.







      share|improve this question














      I am making a nice presentation of ARM assembly code execution and I would need GDB to step the code every 1 second infinitely long (well until I press CTRL+C). Has anyone got solution?



      I don't want to keep on standing next to the keyboard and stepping the program when visitors come visit my stall.









      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 9 at 10:27









      GAD3R

      22.4k154894




      22.4k154894










      asked Feb 8 at 21:37









      71GA

      4331923




      4331923




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          8
          down vote



          accepted










          Gdb's CLI supports a while loop. There's no builtin sleep command, but you can either call out to the shell to run the sleep program, or use gdb's builtin python interpreter, if it has one. It's interruptible with Control-C.



          Method 1:




          (gdb) while (1)
          >step
          >shell sleep 1
          >end


          Method 2:




          (gdb) python import time
          (gdb) while (1)
          >step
          >python time.sleep(1)
          >end


          Method 3 (define a macro):




          (gdb) define runslowly
          Type commands for definition of "runslowly".
          End with a line saying just "end".
          >python import time
          >while (1)
          >step
          >python time.sleep(1)
          >end
          >end
          (gdb) document runslowly
          Type documentation for "runslowly".
          End with a line saying just "end".
          >step a line at a time, every 1 second
          >end

          (gdb) runslowly





          share|improve this answer






















          • This kooks like the best answer!
            – 71GA
            Feb 8 at 23:55

















          up vote
          7
          down vote













          expect can automate this



          #!/usr/bin/env expect
          spawn -noecho gdb -q ls
          expect -ex (gdb)
          send -- "break mainr"
          expect -ex (gdb)
          send -- "runr"
          while 1
          expect -ex (gdb)
          send -- "sr"
          sleep 1



          or if there's a risk of the program running out of s you can repeatedly gdb it with a little more complication



          #!/usr/bin/env expect

          while 1
          spawn -noecho gdb -q ls
          expect -ex (gdb)
          send -- "break mainr"
          expect -ex (gdb)
          send -- "runr"
          expect
          -ex The program is not being run
          eof
          -ex (gdb)
          send -- "sr"
          sleep 1
          exp_continue








          share|improve this answer






















          • So how do I use this? Can you add a description on how to start it.
            – 71GA
            Feb 8 at 23:39










          • install expect, save the scripts to a file, chmod +x them, run them like any other script with a shebang line
            – thrig
            Feb 8 at 23:50

















          up vote
          3
          down vote













          You could have the shell pipe in commands; here's the idea:



          while :; do echo step; sleep 1; done | gdb arm-program


          gdb reads the commands from the pipe; it sees a "step" command every second ad infinitum.



          You may want to set up some break-points and run the program; adjust to taste:



          (echo br 1; echo run; while :; do echo step; sleep 1; done ) | gdb arm-program





          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f422912%2fgdb-step-in-delays%23new-answer', 'question_page');

            );

            Post as a guest






























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            8
            down vote



            accepted










            Gdb's CLI supports a while loop. There's no builtin sleep command, but you can either call out to the shell to run the sleep program, or use gdb's builtin python interpreter, if it has one. It's interruptible with Control-C.



            Method 1:




            (gdb) while (1)
            >step
            >shell sleep 1
            >end


            Method 2:




            (gdb) python import time
            (gdb) while (1)
            >step
            >python time.sleep(1)
            >end


            Method 3 (define a macro):




            (gdb) define runslowly
            Type commands for definition of "runslowly".
            End with a line saying just "end".
            >python import time
            >while (1)
            >step
            >python time.sleep(1)
            >end
            >end
            (gdb) document runslowly
            Type documentation for "runslowly".
            End with a line saying just "end".
            >step a line at a time, every 1 second
            >end

            (gdb) runslowly





            share|improve this answer






















            • This kooks like the best answer!
              – 71GA
              Feb 8 at 23:55














            up vote
            8
            down vote



            accepted










            Gdb's CLI supports a while loop. There's no builtin sleep command, but you can either call out to the shell to run the sleep program, or use gdb's builtin python interpreter, if it has one. It's interruptible with Control-C.



            Method 1:




            (gdb) while (1)
            >step
            >shell sleep 1
            >end


            Method 2:




            (gdb) python import time
            (gdb) while (1)
            >step
            >python time.sleep(1)
            >end


            Method 3 (define a macro):




            (gdb) define runslowly
            Type commands for definition of "runslowly".
            End with a line saying just "end".
            >python import time
            >while (1)
            >step
            >python time.sleep(1)
            >end
            >end
            (gdb) document runslowly
            Type documentation for "runslowly".
            End with a line saying just "end".
            >step a line at a time, every 1 second
            >end

            (gdb) runslowly





            share|improve this answer






















            • This kooks like the best answer!
              – 71GA
              Feb 8 at 23:55












            up vote
            8
            down vote



            accepted







            up vote
            8
            down vote



            accepted






            Gdb's CLI supports a while loop. There's no builtin sleep command, but you can either call out to the shell to run the sleep program, or use gdb's builtin python interpreter, if it has one. It's interruptible with Control-C.



            Method 1:




            (gdb) while (1)
            >step
            >shell sleep 1
            >end


            Method 2:




            (gdb) python import time
            (gdb) while (1)
            >step
            >python time.sleep(1)
            >end


            Method 3 (define a macro):




            (gdb) define runslowly
            Type commands for definition of "runslowly".
            End with a line saying just "end".
            >python import time
            >while (1)
            >step
            >python time.sleep(1)
            >end
            >end
            (gdb) document runslowly
            Type documentation for "runslowly".
            End with a line saying just "end".
            >step a line at a time, every 1 second
            >end

            (gdb) runslowly





            share|improve this answer














            Gdb's CLI supports a while loop. There's no builtin sleep command, but you can either call out to the shell to run the sleep program, or use gdb's builtin python interpreter, if it has one. It's interruptible with Control-C.



            Method 1:




            (gdb) while (1)
            >step
            >shell sleep 1
            >end


            Method 2:




            (gdb) python import time
            (gdb) while (1)
            >step
            >python time.sleep(1)
            >end


            Method 3 (define a macro):




            (gdb) define runslowly
            Type commands for definition of "runslowly".
            End with a line saying just "end".
            >python import time
            >while (1)
            >step
            >python time.sleep(1)
            >end
            >end
            (gdb) document runslowly
            Type documentation for "runslowly".
            End with a line saying just "end".
            >step a line at a time, every 1 second
            >end

            (gdb) runslowly






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 9 at 9:29

























            answered Feb 8 at 23:04









            Mark Plotnick

            16.9k23862




            16.9k23862











            • This kooks like the best answer!
              – 71GA
              Feb 8 at 23:55
















            • This kooks like the best answer!
              – 71GA
              Feb 8 at 23:55















            This kooks like the best answer!
            – 71GA
            Feb 8 at 23:55




            This kooks like the best answer!
            – 71GA
            Feb 8 at 23:55












            up vote
            7
            down vote













            expect can automate this



            #!/usr/bin/env expect
            spawn -noecho gdb -q ls
            expect -ex (gdb)
            send -- "break mainr"
            expect -ex (gdb)
            send -- "runr"
            while 1
            expect -ex (gdb)
            send -- "sr"
            sleep 1



            or if there's a risk of the program running out of s you can repeatedly gdb it with a little more complication



            #!/usr/bin/env expect

            while 1
            spawn -noecho gdb -q ls
            expect -ex (gdb)
            send -- "break mainr"
            expect -ex (gdb)
            send -- "runr"
            expect
            -ex The program is not being run
            eof
            -ex (gdb)
            send -- "sr"
            sleep 1
            exp_continue








            share|improve this answer






















            • So how do I use this? Can you add a description on how to start it.
              – 71GA
              Feb 8 at 23:39










            • install expect, save the scripts to a file, chmod +x them, run them like any other script with a shebang line
              – thrig
              Feb 8 at 23:50














            up vote
            7
            down vote













            expect can automate this



            #!/usr/bin/env expect
            spawn -noecho gdb -q ls
            expect -ex (gdb)
            send -- "break mainr"
            expect -ex (gdb)
            send -- "runr"
            while 1
            expect -ex (gdb)
            send -- "sr"
            sleep 1



            or if there's a risk of the program running out of s you can repeatedly gdb it with a little more complication



            #!/usr/bin/env expect

            while 1
            spawn -noecho gdb -q ls
            expect -ex (gdb)
            send -- "break mainr"
            expect -ex (gdb)
            send -- "runr"
            expect
            -ex The program is not being run
            eof
            -ex (gdb)
            send -- "sr"
            sleep 1
            exp_continue








            share|improve this answer






















            • So how do I use this? Can you add a description on how to start it.
              – 71GA
              Feb 8 at 23:39










            • install expect, save the scripts to a file, chmod +x them, run them like any other script with a shebang line
              – thrig
              Feb 8 at 23:50












            up vote
            7
            down vote










            up vote
            7
            down vote









            expect can automate this



            #!/usr/bin/env expect
            spawn -noecho gdb -q ls
            expect -ex (gdb)
            send -- "break mainr"
            expect -ex (gdb)
            send -- "runr"
            while 1
            expect -ex (gdb)
            send -- "sr"
            sleep 1



            or if there's a risk of the program running out of s you can repeatedly gdb it with a little more complication



            #!/usr/bin/env expect

            while 1
            spawn -noecho gdb -q ls
            expect -ex (gdb)
            send -- "break mainr"
            expect -ex (gdb)
            send -- "runr"
            expect
            -ex The program is not being run
            eof
            -ex (gdb)
            send -- "sr"
            sleep 1
            exp_continue








            share|improve this answer














            expect can automate this



            #!/usr/bin/env expect
            spawn -noecho gdb -q ls
            expect -ex (gdb)
            send -- "break mainr"
            expect -ex (gdb)
            send -- "runr"
            while 1
            expect -ex (gdb)
            send -- "sr"
            sleep 1



            or if there's a risk of the program running out of s you can repeatedly gdb it with a little more complication



            #!/usr/bin/env expect

            while 1
            spawn -noecho gdb -q ls
            expect -ex (gdb)
            send -- "break mainr"
            expect -ex (gdb)
            send -- "runr"
            expect
            -ex The program is not being run
            eof
            -ex (gdb)
            send -- "sr"
            sleep 1
            exp_continue









            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 8 at 22:17

























            answered Feb 8 at 21:57









            thrig

            22.3k12852




            22.3k12852











            • So how do I use this? Can you add a description on how to start it.
              – 71GA
              Feb 8 at 23:39










            • install expect, save the scripts to a file, chmod +x them, run them like any other script with a shebang line
              – thrig
              Feb 8 at 23:50
















            • So how do I use this? Can you add a description on how to start it.
              – 71GA
              Feb 8 at 23:39










            • install expect, save the scripts to a file, chmod +x them, run them like any other script with a shebang line
              – thrig
              Feb 8 at 23:50















            So how do I use this? Can you add a description on how to start it.
            – 71GA
            Feb 8 at 23:39




            So how do I use this? Can you add a description on how to start it.
            – 71GA
            Feb 8 at 23:39












            install expect, save the scripts to a file, chmod +x them, run them like any other script with a shebang line
            – thrig
            Feb 8 at 23:50




            install expect, save the scripts to a file, chmod +x them, run them like any other script with a shebang line
            – thrig
            Feb 8 at 23:50










            up vote
            3
            down vote













            You could have the shell pipe in commands; here's the idea:



            while :; do echo step; sleep 1; done | gdb arm-program


            gdb reads the commands from the pipe; it sees a "step" command every second ad infinitum.



            You may want to set up some break-points and run the program; adjust to taste:



            (echo br 1; echo run; while :; do echo step; sleep 1; done ) | gdb arm-program





            share|improve this answer
























              up vote
              3
              down vote













              You could have the shell pipe in commands; here's the idea:



              while :; do echo step; sleep 1; done | gdb arm-program


              gdb reads the commands from the pipe; it sees a "step" command every second ad infinitum.



              You may want to set up some break-points and run the program; adjust to taste:



              (echo br 1; echo run; while :; do echo step; sleep 1; done ) | gdb arm-program





              share|improve this answer






















                up vote
                3
                down vote










                up vote
                3
                down vote









                You could have the shell pipe in commands; here's the idea:



                while :; do echo step; sleep 1; done | gdb arm-program


                gdb reads the commands from the pipe; it sees a "step" command every second ad infinitum.



                You may want to set up some break-points and run the program; adjust to taste:



                (echo br 1; echo run; while :; do echo step; sleep 1; done ) | gdb arm-program





                share|improve this answer












                You could have the shell pipe in commands; here's the idea:



                while :; do echo step; sleep 1; done | gdb arm-program


                gdb reads the commands from the pipe; it sees a "step" command every second ad infinitum.



                You may want to set up some break-points and run the program; adjust to taste:



                (echo br 1; echo run; while :; do echo step; sleep 1; done ) | gdb arm-program






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 8 at 21:55









                Jeff Schaller

                31.3k846105




                31.3k846105






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f422912%2fgdb-step-in-delays%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay