Reputation: 103
Here I want to ask this question. When I am debugging a program, sometimes I wish I can run a previous instruction again. Like in Microsoft Visual Studio, we can drag the position indicator (remember the yellow arrow) to the previous instruction you want to locate.
For example:
My program is currently at line 72, and suppose line 70 is in the same function that line 72 sits in. Now I want to re-run line 70 again. Is there any way to do that?
Thanks.
Upvotes: 3
Views: 10222
Reputation: 213955
I want to re-run line 70 again
Use the GDB jump
command.
Upvotes: 6
Reputation: 14034
You can normally call functions within gdb
with the call
command:
(gdb) call some_function(arg1, arg2);
However, if you want to specifically go back the program, you could always find the memory location of the line in question and set the instruction pointer to it.
(gdb) set $eip = <some memory address>
That being said, I don't know of a way to fully "unwind" the program's state, if that's what Visual Studio does. In other words, any other program state may be different the second time through.
Upvotes: 1