[contents]
[usage]
[execution]
[stack]
[breakpoints]
[watchpoints]
[advanced]
3. How do I use the call stack?The call stack is where we find the stack frames that control program flow. When a function is called, it creates a stack frame that tells the computer how to return control to its caller after it has finished executing. Stack frames are also where local variables and function arguments are 'stored'. We can look at these stack frames to determine how our program is running. Finding the list of stack frames below the current frame is called a backtrace. How do I ...?
3.1 How do I get a backtrace? [top]  [toc]
Use the gdb command backtrace. In the backtrace below, we can
see that we are currently inside
3.2 How do I change stack frames? [top]  [toc]Use the gdb command frame. Notice in the backtrace above that each frame has a number beside it. Pass the number of the frame you want as an argument to the command.
3.3 How do I examine stack frames? [top]  [toc]To look at the contents of the current frame, there are 3 useful gdb commands. info frame displays information about the current stack frame. info locals displays the list of local variables and their values for the current stack frame, and info args displays the list of arguments.
[contents] [usage] [execution] [stack] [breakpoints] [watchpoints] [advanced] Questions? Comments? Flames? email rms@unknownroad.com |