The finish (GDB) or return (DBX) Command

Use the finish (gdb) or the return (dbx) command without an argument to continue execution of the current function until it returns to its caller.

GDB Mode

step_out_of_command

: finish

Use return function_name (dbx) to continue the execution until control is returned to the specified function. The function must be active on the call stack.

DBX Mode

step_out_of_command

: return

| return [qual_symbol_opt]

qual_symbol_opt

: expression

| qual_symbol_opt ` expression

The finish (gdb) / return (dbx) command finishes the append method and returns control to the caller.

GDB Mode

(idb) continue

Continuing.

Breakpoint 1, List<Node>::append (this=0xbfffcbe0, node=0x805c540) at src/x_list.cxx:151

151         Node* currentNode = _firstNode;

(idb) finish

main () at src/x_list.cxx:195

195     nodeList.append(new IntNode(3)); {static int somethingToReturnTo; somethingToReturnTo++; }

DBX Mode

(idb) cont

[1] stopped at [void List<Node>::append(class Node* const):151 0x0804ae6d]

    151         Node* currentNode = _firstNode;

(idb) return

stopped at [int main(void):195 0x080518c8]

    195     nodeList.append(new IntNode(3)); {static int somethingToReturnTo; somethingToReturnTo++; }

The finish (gdb) / return (dbx) command is sensitive to the user's location in the call stack. Suppose function A calls function B, which calls function C. Execution has stopped in function C, and you entered the up command, so you were now in function B, at the point where it called function C. Using the finish (gdb) / return (dbx) command here would return you to function A, at the point where function A called function B. Functions B and C will have completed execution.