What's the difference between nexti and stepi in gdb?
stepi
is more detailed than nexti
. if you call sum()
from main()
function then doing stepi
reaches you inside the sum() function, but nexti
doesn't.
Below is the screenshot when you call stepi
when you were at call of sum() instruction (i.e., => 0x08048403 <+40>: call 0x8048419 <sum>
). The stepi
instuction routes you inside the sum()
.
If you do nexti
when you were at call of sum() instruction (i.e., => 0x08048403 <+40>: call 0x8048419 <sum>
) then it uses the returned value from sum method and goes to the next instruction of main method, screenshot as below.
Conclusion: Use stepi
if you want to see every machine instructions that happened in your processor. Use nexti
if you wanna see only the machine instructions executed at the main()
.
The difference is how call
is treated:
stepi
dives intocall
nexti
runscall
but doesn't walk you through its code