How to See the Call Stack in GDB

104 6
    • 1). Start "gdb" for the program you wish to see the call stack of. For example, to start debugging the program "example," you would type the following into the Linux command prompt:

      gdb example

    • 2). Run a backtrace on the program. This displays a list of active function calls in the program thread. This is the call stack, but there is more you can do than just view it. Type the following to initiate the backtrace:

      backtrace

    • 3). Observe the list of active function calls. Each one is preceded by the pound sign "#" and a number. You can access their stack frames through this number.

    • 4). Observe the stack frame of an active function call. For example, to view the stack frame for function call 3, write the following:

      frame 3

    • 5). List all the information contained in this frame. This gives you information about the subroutine, which may help you debug your program.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.