GDB step in delays
Clash Royale CLAN TAG#URR8PPP
up vote
6
down vote
favorite
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.
bash gdb
add a comment |Â
up vote
6
down vote
favorite
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.
bash gdb
add a comment |Â
up vote
6
down vote
favorite
up vote
6
down vote
favorite
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.
bash gdb
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.
bash gdb
edited Feb 9 at 10:27
GAD3R
22.4k154894
22.4k154894
asked Feb 8 at 21:37
71GA
4331923
4331923
add a comment |Â
add a comment |Â
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
This kooks like the best answer!
â 71GA
Feb 8 at 23:55
add a comment |Â
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
So how do I use this? Can you add a description on how to start it.
â 71GA
Feb 8 at 23:39
installexpect
, 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
add a comment |Â
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
add a comment |Â
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
This kooks like the best answer!
â 71GA
Feb 8 at 23:55
add a comment |Â
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
This kooks like the best answer!
â 71GA
Feb 8 at 23:55
add a comment |Â
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
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
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
add a comment |Â
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
add a comment |Â
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
So how do I use this? Can you add a description on how to start it.
â 71GA
Feb 8 at 23:39
installexpect
, 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
add a comment |Â
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
So how do I use this? Can you add a description on how to start it.
â 71GA
Feb 8 at 23:39
installexpect
, 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
add a comment |Â
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
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
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
installexpect
, 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
add a comment |Â
So how do I use this? Can you add a description on how to start it.
â 71GA
Feb 8 at 23:39
installexpect
, 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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
answered Feb 8 at 21:55
Jeff Schaller
31.3k846105
31.3k846105
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password