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
280
votes
6 answers

What is exactly the base pointer and stack pointer? To what do they point?

Using this example coming from wikipedia, in which DrawSquare() calls DrawLine(), (Note that this diagram has high addresses at the bottom and low addresses at the top.) Could anyone explain me what ebp and esp are in this context? From what I see,…
devoured elysium
  • 101,373
  • 131
  • 340
  • 557
116
votes
9 answers

What is the direction of stack growth in most modern systems?

I am preparing some training materials in C and I want my examples to fit the typical stack model. What direction does a C stack grow in Linux, Windows, Mac OSX (PPC and x86), Solaris, and most recent Unixes?
Uri
  • 88,451
  • 51
  • 221
  • 321
110
votes
3 answers

Trying to understand gcc option -fomit-frame-pointer

I asked Google to give me the meaning of the gcc option -fomit-frame-pointer, which redirects me to the below statement. -fomit-frame-pointer Don't keep the frame pointer in a register for functions that don't need one. This avoids the instructions…
rashok
  • 12,790
  • 16
  • 88
  • 100
91
votes
1 answer

What is the difference between parent.frame() and parent.env() in R; how do they differ in call by reference?

It would be helpful if someone can illustrate this with a simple example? Also, where would it be useful to use parent.frame() instead of parent.env() and vice versa.
suncoolsu
  • 1,414
  • 1
  • 11
  • 12
66
votes
4 answers

What are the ESP and the EBP registers?

I found that the ESP register is the current stack pointer and EBP is the base pointer for the current stack frame. However, I don't understand these definitions (I am just starting to learn how to code in assembler). What I understand is that ESP…
Lucas Alanis
  • 1,208
  • 3
  • 15
  • 30
64
votes
9 answers

Do any languages / compilers utilize the x86 ENTER instruction with a nonzero nesting level?

Those familiar with x86 assembly programming are very used to the typical function prologue / epilogue: push ebp ; Save old frame pointer. mov ebp, esp ; Point frame pointer to top-of-stack. sub esp, [size of local variables] ... mov esp, ebp ;…
Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
64
votes
1 answer

What is a stack map frame

I've recently been looking at The Java Virtual Machine Specifications (JVMS) to try to better understand the what makes my programs work, but I've found a section that I'm not quite getting... Section 4.7.4 describes the StackMapTable Attribute, and…
Steven
  • 1,709
  • 3
  • 17
  • 27
61
votes
4 answers

"enter" vs "push ebp; mov ebp, esp; sub esp, imm" and "leave" vs "mov esp, ebp; pop ebp"

What is the difference between the enter and push ebp mov ebp, esp sub esp, imm instructions? Is there a performance difference? If so, which is faster and why do compilers always use the latter? Similarly with the leave and mov esp, ebp pop …
小太郎
  • 5,510
  • 6
  • 37
  • 48
57
votes
4 answers

GetEntryAssembly for web applications

Assembly.GetEntryAssembly() does not work for web applications. But... I really need something like that. I work with some deeply-nested code that is used in both web and non-web applications. My current solution is to browse the StackTrace to find…
Mose
  • 1,781
  • 3
  • 16
  • 35
51
votes
2 answers

explanation about push ebp and pop ebp instruction in assembly

i used stack in assembly but i didn't got idea about push ebp and pop ebp. .intel_syntax noprefix .include "console.i" .text askl: .asciz "Enter length: " askb: .asciz "Enter breadth: " ans: .asciz "Perimeter = " _entry: push…
bunty
  • 2,665
  • 8
  • 30
  • 27
45
votes
4 answers

How does alloca() work on a memory level?

I'm trying to figure out how alloca() actually works on a memory level. From the linux man page: The alloca() function allocates size bytes of space in the stack frame of the caller. This temporary space is automatically freed when the function…
glades
  • 3,778
  • 1
  • 12
  • 34
41
votes
2 answers

What is between ESP and EBP?

Right, I'm sure this is implicitly answered many times, but I seem not to be able to quite get to it. If you have a (x86) stack trace (say, looking at it in WinDbg), and you look at the registers, what does it mean for EBP and ESP values to be x…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
35
votes
1 answer

Does omitting the frame pointers really have a positive effect on performance and a negative effect on debug-ability?

As was advised long time ago, I always build my release executables without frame pointers (which is the default if you compile with /Ox). However, now I read in the paper http://research.microsoft.com/apps/pubs/default.aspx?id=81176, that frame…
Patrick
  • 23,217
  • 12
  • 67
  • 130
28
votes
3 answers

ENTER and LEAVE in Assembly?

I was reading The Art of Assembly Language (Randall Hyde, link to Amazon) and I tried out a console application in that book. It was a program that created a new console for itself using Win32 API functions. The program contains a procedure called…
devjeetroy
  • 1,855
  • 6
  • 26
  • 43
24
votes
1 answer

x86_64 : is stack frame pointer almost useless?

Linux x86_64. gcc 5.x I was studying the output of two codes, with -fomit-frame-pointer and without (gcc at "-O3" enables that option by default). pushq %rbp movq %rsp, %rbp ... popq %rbp My question is : If I globally disable that…
Kroma
  • 1,109
  • 9
  • 18
1
2 3
19 20