Supported on windows
Supported on linux
Supported on embedded
Supported on android

up command

Selects the previous (outer) stack frame or one of the frames preceding it.

Syntax

up
up [Frame count]

Parameters

Frame count
If this parameter is provided, the up command will go N frames up where N is the amount specified here. If this parameter is omited, the up command will go one frame up.

Remarks

Use the backtrace command to display all available frames. Use the frame command to select a frame by number.

Note that the currently selected frame affects the output of the info args, info locals and info frame commands.

Examples

We will illustrate the up command using a recursive function below:

#include <stdio.h>

void level0()
{
    printf("Reached level 0\n");
}

void test(int level)
{
    if (level > 0)
    {
        int prevLevel = level - 1;
        printf("Level %d\n", level);
        test(prevLevel);
    }
    else
        level0();
}

int main()
{
    test(5);
    return 0;
}

We will set a breakpoint at the level0() function and use the up command to navigate the stack trace upwards.

(gdb) b level0
Breakpoint 1 at 0x804841a: file recursion.cpp, line 5.
(gdb) r
Starting program: /home/testuser/recursionDemo
Level 5
Level 4
Level 3
Level 2
Level 1

Breakpoint 1, level0 () at recursion.cpp:5
5 printf("Reached level 0\n");
(gdb) frame
#0 level0 () at recursion.cpp:5
5 printf("Reached level 0\n");
(gdb) up
#1 0x08048462 in test (level=0) at recursion.cpp:17
17 level0();
(gdb) up
#2 0x0804845b in test (level=1) at recursion.cpp:14
14 test(prevLevel);
(gdb) up 3
#5 0x0804845b in test (level=4) at recursion.cpp:14
14 test(prevLevel);
(gdb) print prevLevel
$1 = 3
(gdb) up
#6 0x0804845b in test (level=5) at recursion.cpp:14
14 test(prevLevel);
(gdb) print prevLevel
$2 = 4
(gdb) up
#7 0x08048479 in main () at recursion.cpp:22
22 test(5);
(gdb) up
Initial frame selected; you cannot go up.
(gdb)

Compatibility with VisualGDB

Do not execute the up command manually under Visual Studio. Use the Call Stack window to navigate through stack frames instead.

See also