What is the difference between the gdb commands step and next? Give an example to explain your answer.
What will be an ideal response?
The step command to used to execute the next line of code. If that command is a function then the command will result in the debugger stepping in to the function and waiting for the user to issue a command to execute the rest of the code in the function. If the next command is used, and the next line in the code is a function, it skips over the function without going into the function and executes the whole function. For example if the next line to be executed in the code being debugged is:
getinput(user_in);
The step command will result in the debugger going into the function and awaiting the users command before executing the code.
On the other hand if next is used, it will result in the whole function being executed and the debugger will stop on the line after this function call (in this case getinput()).