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

info frame command

Displays advanced information about a stack frame.

Syntax

info frame
info frame [Frame number]
info frame [Frame address]

Parameters

Frame number
Specifies the zero-based frame number that will be used to display the frame information. If omitted, the info frame command will display the information about the current frame selected by the frame command.

Frame address
Specifies the memory address of the frame to be displayed. A frame address is the address of the memory location after the last word belonging to the frame. E.g. on an x86 system the frame address will be the value of the ebp register + 8 (to account for the saved previous value of ebp and the return address pushed by the call instruction that are considered a part of the frame).

Remarks

The info frame command displays a lot of low-level information about a frame. Use info args and info locals commands to see more concise output.

Examples

We will illustrate the info frame 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 info frame command to display various low-level information about various frames:

(gdb) break level0
Breakpoint 1 at 0x8048452: file recursion.cpp, line 5.
(gdb) run
Starting program: /home/testuser/recursionTest
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 0x0804849a in test (level=0) at recursion.cpp:17
#2 0x08048493 in test (level=1) at recursion.cpp:14
#3 0x08048493 in test (level=2) at recursion.cpp:14
#4 0x08048493 in test (level=3) at recursion.cpp:14
#5 0x08048493 in test (level=4) at recursion.cpp:14
#6 0x08048493 in test (level=5) at recursion.cpp:14
#7 0x080484b1 in main () at recursion.cpp:22
(gdb) select-frame 2
(gdb) info frame
Stack level 2, frame at 0xbffff5c0:
eip = 0x8048493 in test (recursion.cpp:14); saved eip 0x8048493
called by frame at 0xbffff5f0, caller of frame at 0xbffff590
source language c++.
Arglist at 0xbffff5b8, args: level=1
Locals at 0xbffff5b8, Previous frame's sp is 0xbffff5c0
Saved registers:
ebp at 0xbffff5b8, eip at 0xbffff5bc
(gdb) info registers
eax 0x0 0
ecx 0x0 0
edx 0x0 0
ebx 0xb7fc3000 -1208209408
esp 0xbffff590 0xbffff590
ebp 0xbffff5b8 0xbffff5b8
esi 0x0 0
edi 0x0 0
eip 0x8048493 0x8048493 <test(int)+51>
eflags 0x282 [ SF IF ]
cs 0x73 115
ss 0x7b 123
ds 0x7b 123
es 0x7b 123
fs 0x0 0
gs 0x33 51
(gdb) info frame 3
Stack frame at 0xbffff5f0:
eip = 0x8048493 in test (recursion.cpp:14); saved eip 0x8048493
called by frame at 0xbffff620, caller of frame at 0xbffff5c0
source language c++.
Arglist at 0xbffff5e8, args: level=2
Locals at 0xbffff5e8, Previous frame's sp is 0xbffff5f0
Saved registers:
ebp at 0xbffff5e8, eip at 0xbffff5ec
(gdb) info frame 0xbffff5f0
Stack frame at 0xbffff5f0:
eip = 0x8048493 in test (recursion.cpp:14); saved eip 0x8048493
called by frame at 0xbffff620, caller of frame at 0xbffff5c0
source language c++.
Arglist at 0xbffff5e8, args: level=2
Locals at 0xbffff5e8, Previous frame's sp is 0xbffff5f0
Saved registers:
ebp at 0xbffff5e8, eip at 0xbffff5ec

Compatibility with VisualGDB

You can execute the info frame command manually using the GDB Session window to see various low-level information about stack frames.

See also