I want to know the exact contents of a program stack.
How is the branching operation done?
What is meant by memory dump while debugging a program using gdb?
Does it give the program stack?
TIA, Praveen
I want to know the exact contents of a program stack.
How is the branching operation done?
What is meant by memory dump while debugging a program using gdb?
Does it give the program stack?
TIA, Praveen
see the link below which can give you a better idea Variables and Memory
it gives stack trace before the memory corruption happens.that stack trace is the series of function calls that were made along with the arguments passed.
The stack is a memory area which contains subroutine arguments, local variables and return addresses from subroutines.
On many architectures, Intel's included, the stack grows from the top down - meaning that the stack pointer is decremented every time data is pushed to the stack.
A typical function call sequence will look like this:
To produce a stack trace, the runtime environment simply scans the stack to determine where the return addresses point to. I wrote "simply," but it's not that simple if the base pointers weren't saved to the stack, because it might be impossible to determine where any stack frames other than the current one are located.
The C language itself doesn't mandate the use of a stack at all - it defines behaviour rather than implementation.
However, in the common case, the program stack is used to store several things:
auto
storage duration (ie. ordinary, non-static
local variables);return;
or the end of the current function is reached);alloca()
function;alloca()
, the size of variable-length arrays and intermediate values used in calculations.This is not an exhaustive list - other, more exotic things like Trampolines are also sometimes stored on the stack. In general, it is a temporary storage area for working items that will not be needed after the current function returns to its caller.
A "backtrace" in a debugger shows some (but not all) of the contents of the stack.