return (gdb mode only)

Remove frames from the call stack.

Syntax

return

Parameters

None.

Description

When you use return, the selected stack frame is discarded, and all frames within it, meaning that the function that is executing is no longer being called and therefore stops executing, as well as any of its child functions.

The return command does not resume execution. It leaves the program stopped in the state that would exist if the function had just returned. In contrast, the finish command resumes execution until the selected stack frame returns naturally.

Example

Consider lines 5-18 of code in hello_simple.c:

5       static volatile int bar  = 0;
6
7       static void readGlob( int x )
8       {
9           bar = 100;
10          foo = x;
11          bar = 200;
12      }
13
14      int main()
15      {
16      int j = 10;
17      readGlob(5);
18      j = bar;

The application has executed line 17, a call to readGlob(), and is now at the beginning of line 10, inside the function readGlob(). The return command terminates readGlob() and removes its frame from the stack, before the debugger executes line 11, bar = 200.

The application stops at line 18 as though readGlob() has returned normally.

Because the debugger executes the return command after executing line 9, but before line 11, the value of bar in line 18 is 100, not 200.

Breakpoint 1, readGlob (x=1111) at /hello_simple.c:10
10          foo = x;
(idb) p bar
$1 = 100
(idb) return
Make readGlob return now? (y or n) y
#0  0x08048402 in main () at /hello_simple.c:18
18      j = bar;
(idb) p bar
$2 = 100

See Also


Submit feedback on this help topic

Copyright © 1996-2010, Intel Corporation. All rights reserved.