stackframe

How do I get the executing object for a stackframe?

When using reflection it is possible to obtain the call stack (apart from that it can be a crude approximation due to JIT optimizations) using System.Diagnostics.StackTrace and examine the StackFrame objects contained. How can I get a reference to the object (the this-pointer) on which a method in a stack frame is executing? I know I c...

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 function and I'm trying to determine if my caller is a generator or a regular function? I nee...

Determining which code line threw the exception

In dotNet a line throws an exception and is caught, how can I figure out which line in which file threw the exception? Seems relatively straightforward, but I can't figure it out... ...

c/c++ passing argument by pointer / argument by reference stackframelayout?

hi! foo1(int* val){(*val)++;} foo2(int &val){val++;} will the compiler create in both cases the same code? will it simply write a pointer into the parameterpart of foo's stackframe? or will in the second case the callers' and foos' stackframes somehow overlap such that the callers' local variable takes the same memory on the stack as...

Identifying a function call in a python script line in runtime

I have a python script that I run with 'exec'. When a function is called by the script, I would like it to know the line number and offset in line for that call. Here is an example. If my script is: foo1(); foo2(); foo1() foo3() And if I have code that prints (line,offset) in every function, I should get (0,0), (0,8), (0,16), (1,0) ...

Is Powershell's stack trace broken?

I am writing a simple unit test harness in powershell I designed the harness such that its assert functions takes a script-block as a parameter to allow the harness to run the code from within the assert function and treat any exceptions are thrown as a test failure. If the tests fail I want to return line in the unit test in which the...

using session variables in predispatch of zend framework controller gives Fatal Error

I am using zend framework v1.9.6 and written a piece of code in preDispatch method of one of the controllers as if(!isset($_SESSION['myvar']){ //do something and assign a value to the session variable } ..so that the code executes only once. However I am getting a fatal error at the end of the page everytime except for when th...