Questions tagged [stack-frame]

Use stackframe for questions related to debugging unterminated function calls.

A stackframe is a list of functions that have been invoked but have not yet returned a value

References

291 questions
0
votes
0 answers

Why does the base pointer point to the top of the stack?

In the "Programming from the ground up" book, I see the stack frame when calling function is somewhat like this parameter 2 <- 12(%ebp) parameter 1 <- 8(%ebp) return address <- 4(%ebp) ebp <- (%ebp) local var 1 <-…
Mike
  • 1
  • 1
0
votes
3 answers

Why functions locals and arguments are pushed to the stack?

how functions are stored on memory i.e : the data segment as normal variables expressions or on the code segment in either one What is pushed to the stack a pointer? or the whole function and why do we need to push the local variables and…
Susano
  • 230
  • 2
  • 9
0
votes
1 answer

Why is my base case being (erroneously) triggered immediately?

I am trying to implement a merge sort algorithm in C. In the recursive array split function, my base case is occurring infinitely, despite the return statement, and the merge function is never called. Here is my code: #include const int…
0
votes
2 answers

Move current stack frame in C

I was wondering if there would be a convenient way to copy the current stack frame, move it somewhere else, and then 'return' from the function, from the new location? I have been playing around with setjmp and longjmp while allocating large arrays…
Robert
  • 277
  • 1
  • 16
0
votes
1 answer

Is the stack frame of a function called multiple times different each time?

void foo() { int i; printf("%d",i++); } int main() { int j; for(j=0;j<10;j++) { foo(); } } The output of the code is a series of 10 random but continuous numbers. I wanted to know how is this possible if i is being…
Sunny
  • 51
  • 1
  • 7
0
votes
1 answer

Why do I have a segmentation fault in recursive assembly function?

Hi I write a Fibonacci recursive code in assembly with the amd64 abi calling convention, but I always get segmentation fault :/ I compile it with: nasm -f elf64 -o fibo.o fibonacci.asm ld -o fibo fibo.o ./fibo I have no compiling errors but a…
Jan Wolfram
  • 145
  • 8
0
votes
0 answers

Using the Frame pointer instead of the Stack pointer in x86_64

Compiling a simple C code into assembly using GCC will have the following output: ... 13 xorl %eax, %eax 14 movl $0, -4(%rbp) 15 movl $5, -8(%rbp) 16 movl $6, -12(%rbp) 17 movl -8(%rbp),…
Josh
  • 43
  • 1
  • 4
0
votes
2 answers

When passing an data member array into a recursive procedure, is a new copy of that array created in each stack frame?

I am facing the issue that copy of an 2 dimensional array is not made in each stack frame of recursive call. I am doing indirect recursion. I also tried sending my data in function call from main() function but the copy was not made. Same address…
0
votes
1 answer

Is there a symbol table for local variables stored within a stack frame?

Logically, I would assume that there has to be. If im correct, I'm also assuming that its separate from the global symbol table, and that its created by the compiler when a function call is reached and deleted when the compiler reaches the end of…
KeatonB
  • 213
  • 2
  • 10
0
votes
2 answers

C Context switch stack variable corruption

Im trying to implement custom threads in C by creating a simple context switch function plus a FCFS scheduler. The first step that i want to perform is to copy the entire function stack frame to heap to a saved frame and replace it by the first in…
Tretorn
  • 365
  • 1
  • 16
0
votes
0 answers

about command line argument in assembly

Here is my code segment .data ; initialized data is put in the data segment here ; segment .text global main main: enter 0,0 ; setup stack frame pusha call func ; ; ; ; popa …
0
votes
1 answer

assembly for variable-size stack frame(about stack for local variable)

long vframe(long n, long idx, long *q){ long i; long *p[n]; p[0] = &i; for(i=1; i
cp3
  • 1
  • 2
  • 7
0
votes
1 answer

Replace System.Diagnostics.StackFrame.GetMethod in UWP

Porting some code from .NET Framework to UWP, and I'm not sure how to replicate this in a UWP project: StackFrame frame = new StackFrame(1); var method = frame.GetMethod(); var names = method.Name.Split('_'); var propertyName = names.Length == 2 ?…
Mercutio
  • 1,152
  • 1
  • 14
  • 33
0
votes
1 answer

stackframe dosen't get eliminated from the stack?

I wrote a single c program that prints input to std output. Then I converted it to assembly language. By the way I am using AT&T Syntax. This is the simple C code. #include int main() { int c; while ((c = getchar ()) != EOF) …
user8862019
0
votes
0 answers

Why do we need `pushl %ebp` at the start of every assembly program?

Why do we need these two functions at the start of every assembly program? pushl %ebp movl %esp,%ebp I don't know what they do and they don't seem to contribute to the code functionality. I come from the Python world so this is pretty weird.