f5d
Stack frames
When your program is started, the stack has only one frame, that of the
function main. This is called the initial frame or the outermost frame. Each time a function is called, a new frame is made. Each time a function
returns, the frame for that function invocation is eliminated. If a function is
recursive, there can be many frames for the same function. The frame for the
function in which execution is actually occurring is called the innermost frame. This is the most recently created of all the stack frames that still
exist.
Inside your program, stack frames are identified by their addresses. A stack
frame consists of many bytes, each of which has its own address; each kind of
computer has a convention for choosing one byte whose address serves as the
address of the frame. Usually this address is kept in a register called the frame pointer register while execution is going on in that frame.
GDB assigns numbers to all existing stack frames, starting with zero for the
innermost frame, one for the frame that called it, and so on upward.
These numbers do not really exist in your program; they are assigned by GDB to
give you a way of designating stack frames in GDB commands.
Some compilers provide a way to compile functions so that they operate without
stack frames. (For example, the
The frame command allows you to move from one stack frame to another, and to print the
stack frame you select. args may be either the address of the frame of the stack frame number. Without an
argument, frame prints the current stack frame.
The select-frame command allows you to move from one stack frame to another without printing
the frame. This is the silent version of frame.