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
1 answer

Too large (overaligned?) stack frame with GCC but not with Clang

Consider this simple code: class X { int i_; public: X(); }; void f() { X x; } The stack frame of f is 32-byte long with GCC, which is unnecessarily long. The return address and x just need 12 bytes and 16-byte alignment should be required…
Daniel Langr
  • 22,196
  • 3
  • 50
  • 93
0
votes
2 answers

Get Class Name with extension in C#?

I am trying to get class name with the extension (e.g. Employee.cs or Employee.aspx.cs) in my code. I was able to get the name of the class without the extension but does anybody know how can i also get extension of the class?? This is what i did to…
sanjeev40084
  • 9,227
  • 18
  • 67
  • 99
0
votes
0 answers

x86-64 gcc doesn't assign a stack frame for local variable

I had some problem when I learned about assembly code. I use "compiler explorer" that is a website that supporting a lot of compiler. I made a simple code and compiled it as x86-64 gcc. : int sum(int a, int b) { return a + b; } int…
0
votes
2 answers

MIPS - Why restore the stack when calling subroutines

Assume we are passing arguments to a subroutine using the stack frame as follows: addi $sp, $sp, -8 sw $s0, 0($sp) jal sub lw $s1, 4($sp) addi $sp, $sp, 8 sub: lw $t0, 0($sp) ... do stuff ... sw $t1, 4($sp) jr $ra I understand the concepts of…
hendrix
  • 21
  • 4
0
votes
0 answers

Inconveniences with maintaining Stack Frames and Symbol Tables Separately

Intoduction I'm creating a statically typed language where all variables are treated as static global variables. Therefore the amount of memory required is known at compile time (similar to how Fortran 66 works). I've observed that the structure of…
Tom
  • 1,235
  • 9
  • 22
0
votes
0 answers

Why doesn't the stack/base pointer change here?

I've written the following function to play around with inline assembly a bit and print out various registers: void run(void) { long rsp, rbp; asm("mov %%rsp, %0;" "mov %%rbp, %1;" : "=r" (rsp), "=r" (rbp)); printf("Middle\n%%rsp =…
samuelbrody1249
  • 4,379
  • 1
  • 15
  • 58
0
votes
0 answers

Approximate stack location

Would the following work as a way to approximate the stack position of the current frame? int main(int argc, char *argv[]) { char a = 'a'; printf("The current stack is around: %p\n", &a); ... } I would think this would give be where…
samuelbrody1249
  • 4,379
  • 1
  • 15
  • 58
0
votes
1 answer

Can infinite recursion be implemented?

I understand that for C at least the stack frame and return address are written to the stack every time the recursive function is called, but is there an obscure way of making it not run out of memory? Obviously this is purely a hypothetical…
Boba0514
  • 181
  • 1
  • 3
  • 15
0
votes
1 answer

How can I view instance variables in other stack frames with Eclipse Java debugger?

When I'm at a breakpoint in my Java app under Eclipse debugger, I click on another frame in the stack frame list (on the same thread), expecting to be able to view some of my variables. There's only one variable, this, and when I reveal what it…
Chap
  • 3,649
  • 2
  • 46
  • 84
0
votes
1 answer

Can someone provide a visualization or detailed flow of the stack frame in this Assembly MIPS code block?

addi $sp, $sp, -32 # stack frame is 32 bytes long sw $ra, 20($sp) # save return address sw $fp, 16($sp) # save frame pointer addi $fp, $sp, 28 # set up frame pointer sw $a0, 0($fp) # save argument (n) I'm a bit lost…
maboo
  • 1
0
votes
0 answers

Address of C++ local variable is before the address returned by gdb info frame locals

I have the following source code (in a file named vuln.cpp) in C: #include #include int main(int argc, char ** argv) { char real[20]; char pass[20] = "dddddddddddddddd"; if(argc < 2) { …
Rwitaban Goswami
  • 427
  • 3
  • 13
0
votes
0 answers

Weird stack frame generated by MSVC

I was reading assembly tutorials and got stuck on stack operations and function calls. As said here, when fuction A calls function B, it passes first 4 arguments in registers(by value or pointer) and next ones are passed via stack. Also, caller…
Poseydon
  • 59
  • 1
  • 9
0
votes
1 answer

Does the if block create a entry in stack frame in JAVA?

I was going through the stack frame, so every function call gets pushed into stack frame and popped when completed, so when the if block is executed does it gets pushed onto stack frame, or will it get executed in current method stack entry?
0
votes
0 answers

How does stack destruction happen?

I'm interested in how the stack works and have a problem with understanding how the stack frame destruction occurs. I'm playing with code below: public class Container { public unsafe int* t1; public unsafe int* t2; public unsafe int*…
Evgeniy Terekhin
  • 596
  • 3
  • 10
0
votes
1 answer

Understanding stack frames and rbp and rsp with gdb

I'm new to assembly lang and I'm a bit confused on some things. For an assignment, I'm given a C program and asked to asked to put breakpoints at two points and count the stack frames and their locations. This is the code : int swap_n_add(int *xp,…
Uberi_Puip
  • 19
  • 6