Search code examples
assemblystackgdbcallstackbacktrace

What is the "Stack" section in gdb


In gdb, it seems that whatever is located in the "Stack" section is always the same as the %rip register. For example:

rip 0x0000555555554603
─── Stack ────────────────────────────────────────────────────────────────────────────────────────
[0] from 0x0000555555554603 in main

And after doing si:

rip 0x0000555555554606
─── Stack ────────────────────────────────────────────────────────────────────────────────────────
[0] from 0x0000555555554606 in main

What exactly is the "Stack" section in gdb? It seems to me like it is more-or-less the instruction pointer (%rip) in the currently running function (and previous %rips in the call stack that have not completed execution). Is this correct, or what does this section tell us?

If useful, here is the front-end that I'm using in gdb, which is called gdb dashboard:

enter image description here


Solution

  • That is the call stack. GDB enables you to see the call stack, so you can understand how you got to where you are (Which function calls did you go through to get to where you are).

    The call stack is the list of functions that have been called and not yet returned, beginning with the current function at frame 0, and going all the way down to main at the last frame.

    In your particular case, your call stack is only main, because you've not called other functions (or because they returned already). %rip points to the current instruction, so your location in the current frame always corresponds to its contents.