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

What is the address returned by the function from the stack?

I have the following code int isBST(struct node* node) { return(isBSTUtil(node, INT_MIN, INT_MAX)); } int isBSTUtil(struct node* node, int min, int max) { if (node==NULL) return 1; if (node->data <= min || node->data > max)…
user1886376
1
vote
2 answers

how to I get the total number of stack frames used in recursion in Python?

here is the simple code for calculating fibonacci series: def fib(n): if n==0 or n==1: return 1 else: return fib(n-1)+fib(n-2) if n=10, I want to know how many stack frames are involved for this calculation. Is there a way to…
brain storm
  • 30,124
  • 69
  • 225
  • 393
1
vote
3 answers

Do cpp object methods have their own stack frame?

I have a hypothesis here, but it's a little tough to verify. Is there a unique stack frame for each calling thread when two threads invoke the same method of the same object instance? In a compiled binary, I understand a class to be a static code…
Joey Carson
  • 2,973
  • 7
  • 36
  • 60
1
vote
2 answers

why do structure's data members memory allocated from lower to higher address in stack growing higher to lower

why do structure's data members memory allocated from lower to higher address in stack growing higher to lower? What is the mechanism in this process?
SeasonedNoob
  • 121
  • 1
  • 9
1
vote
1 answer

Using calling method name as condition for conditional statement

Is it possible to get the name of the calling method, and execute code based on those results? Below, I have two methods that are used for database CRUD operations. One adds an object to the database, another updates. Both return an object which…
Klue
  • 59
  • 7
1
vote
2 answers

Python Class Stack Frame Limitations

If I have a class of the following format: class TestClass: def __init__(self): self.value = 0 def getNewObject(self): return TestClass() Is there a limitation to the amount of times I can call the function? For example: obj =…
cytinus
  • 5,467
  • 8
  • 36
  • 47
1
vote
2 answers

I sometimes can't get the method name from my method in Silverlight

I have this method that logs errors from the Silverlight client: [MethodImpl(MethodImplOptions.NoInlining)] public static bool ErrorHandler(Exception error, bool showError = true) { string callingMethod = new StackFrame(1).GetMethod().Name; …
Rumplin
  • 2,703
  • 21
  • 45
1
vote
2 answers

Obtaining references to function objects on the execution stack from the frame object?

Given the output of inspect.stack(), is it possible to get the function objects from anywhere from the stack frame and call these? If so, how? (I already know how to get the names of the functions.) Here is what I'm getting at: Let's say I'm a…
Marcin
  • 12,245
  • 9
  • 42
  • 49
0
votes
1 answer

In C, what happens to the stack when we have a return statement which returns a function call?

im uderstanding the stack in C lenguage, but I have a question; please look at this simple code: #include void function(int x){ if(x==0){ return; } else{ printf("x is equal to 1"); } return…
Cblue X
  • 143
  • 6
0
votes
1 answer

Frame, Stack Frame in process Stacking Unstacking

Stacking process When I talked about the stacking process I was talking about the frame that it would store the data of CPU registers like PC(Program counter) or LR but the advisor said it wasn't and didn't dig deep. But when I look up on google,…
ttd2409
  • 1
  • 1
0
votes
1 answer

Get parameter value in Assembly

I'm a beginner in Assembly, so I'm confused about passing parameters in function call from another function. Specifically I have code like this: Assembly: bar: pushl %ebp movl %esp, %ebp subl $16, %esp movl $555, -4(%ebp) movl …
0
votes
1 answer

How did alloca() interact with other stack allocation?

Let's start from a simple example of stack allocation: void f() { int a, b; ... } If I understand correctly. Then address of a and b has a fixed offset from stack base, namely the register ebp. That's the how compiler find them if we need…
Peter Wu
  • 193
  • 6
0
votes
1 answer

Why do we use the stack for the return address of a function?

I kind of understand how stack frames work. Why do we use them to store the return address? It looks like that is why buffer overflows happen. Wouldn't it be more secure to allocate a certain memory region to just keep return addresses, fully…
Mach
  • 5
  • 3
0
votes
0 answers

C# find what the last interacted with instance in the call stack is

I am working on a personal C# project where I want to redirect console streams to different inputs/outputs for different object instances. So for example I have a class User that I do not have source access to. I have multiple instances of User, and…
Jakob Tinhofer
  • 313
  • 3
  • 16
0
votes
0 answers

Cortex-M0+Determining stack frame size at run time

How can one determine the size of a stack frame for a function call at run time? I could use CMSIS __get_MSP before and after the call and get the difference, but I would prefer to not require the caller to do anything before the call. Knowing the…
Kay
  • 123
  • 8