Execute code at line <x> in gdb?
In visual studio, you can right-click any code and choose "Set next statement", and visual studio starts execu开发者_开发百科ting code from there instead. This is really useful for when you think "wait, what??" and want to see the last bit of code execute again, without having to restart from scratch.
Does gdb have any similar functionality? If I notice that, for example, a function call has produced an unexpected value, how can I make the function call again?
This is gdb under xcode 3.2.5 on Mac OS X.
Use gdb jump
command. More info here.
If you merely want to re-execute a function foo(int)
with some value, you don't have to do what you asked for at all. The following should work (at (gdb)
prompt):
break foo
print foo(42)
thanks to Employed Russian for the link. I also found this, although I don't have a new enough gdb version to use it:
http://www.sourceware.org/gdb/wiki/ReverseDebug
精彩评论