Returning from a function

When you use return, GDB discards the selected stack frame (and all frames within it). You can think of this as making the discarded frame return prematurely. If you wish to specify a value to be returned, give that value as the argument to return.

return or return expression
You can cancel the execution of a function call with the return command. If you give an expression argument, its value is used as the function's return value.

This pops the selected stack frame (see Selecting a frame ) and any other frames inside it, leaving its caller as the innermost remaining frame. That frame becomes selected. The specified value is stored in the registers used for returning values of functions.

The return command doesn't resume execution; it leaves the program stopped in the state that would exist if the function had just returned. In contrast, the finish command (see Continuing and stepping ) resumes execution until the selected stack frame returns naturally.