How to do "Set Next Statement" or "Set Instruction Pointer" in GDB[edit | edit source]

This is actually quite simple! a quick look into the manual gave me the answer.

Constraint: It's disallowed to jump between functions, as the stack frames are left unchanged.


Suppose you want to go to line #n, type these two commands in GDB and you're there:

tbreak n
jump n

tbreak - so that debugger will be in "break" mode


jump - to actually change the PC.

Community content is available under CC-BY-SA unless otherwise noted.