2. Also called Stack Frames
Activation records are entries on a call stack
They maintain information about functions
being called and their return locations
They also contain parameters and local
variables
3. Contains an activation record for each
function that is called
Grows backwards (higher memory address to
lower memory address)
Has a stack pointer pointing to the top of the
stack
4. void function2() {
…
Each function call
function2(); adds an activation
…
} record to the call
stack Stack
void function1() { Pointer
…
} function2_1
function2
int main() {
…
function1
function1();
…
} main
8. void func1(int a)
{
int x;
}
Register values
int main()
int x
{
Frame ptr of main()
func1(3); func1
Program counter of
} main() main
int a
9. An activation record is created on the call
stack when a function is called (winding).
The activation record is removed from the
call stack when the function returns
(unwinding).
“Why can’t you return a pointer to a local variable
declared within a function?”
10. Recursive function calls will add an activation
record to the stack for each call
“What is a stack overflow?”
11. You can use pointers to access the activation
record
Example:
void func(int a) {
printf(“Return address: %xn”, &a-1);
}