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

down command

Selects the next (inner) stack frame or one of the frames following it.

Syntax

down
down [Frame count]

Parameters

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

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 down 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 down command to navigate through the stack frames in the stack trace.

(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) backtrace
#0 level0 () at recursion.cpp:5
#1 0x08048462 in test (level=0) at recursion.cpp:17
#2 0x0804845b in test (level=1) at recursion.cpp:14
#3 0x0804845b in test (level=2) at recursion.cpp:14
#4 0x0804845b in test (level=3) at recursion.cpp:14
#5 0x0804845b in test (level=4) at recursion.cpp:14
#6 0x0804845b in test (level=5) at recursion.cpp:14
#7 0x08048479 in main () at recursion.cpp:22
(gdb) down
Bottom (innermost) frame selected; you cannot go down.
(gdb) frame 7
#7 0x08048479 in main () at recursion.cpp:22
22 test(5);
(gdb) down
#6 0x0804845b in test (level=5) at recursion.cpp:14
14 test(prevLevel);
(gdb) print prevLevel
$1 = 4
(gdb) down 3
#3 0x0804845b in test (level=2) at recursion.cpp:14
14 test(prevLevel);
(gdb) print prevLevel
$2 = 1
(gdb) down
#2 0x0804845b in test (level=1) at recursion.cpp:14
14 test(prevLevel);
(gdb) down
#1 0x08048462 in test (level=0) at recursion.cpp:17
17 level0();
(gdb) down
#0 level0 () at recursion.cpp:5
5 printf("Reached level 0\n");
(gdb) down
Bottom (innermost) frame selected; you cannot go down.

Compatibility with VisualGDB

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

See also