A .NET application can get a managed StackTrace that describes which methods were called and contains references to them to get their name, token and signature, and on which the IL offset in the method body caused the call. But it does not contain the values โโof the arguments that were passed to each method.
The values โโof the arguments are somewhere in the memory of the process stack for sure, but this is its own representation, which can be a little inconvenient and unpredictable for evaluation.
There is also a managed stack that essentially executes the CLR, before the JIT compiler. In MSIL code, arguments are pushed onto this stack before the call operation code is executed. Therefore, these values โโmust also be on the CLR stack.
The question is, can a managed application check its own managed stack at runtime to extract such information?
I am not talking about individual debugger processes such as Visual Studio. I want to do this from within the process. I also understand that any executable code will be added to the stack, so this thing would have to set a certain โentry pointโ from which I could check the stack up (i.e. towards the root, if the CLR also holds stacks hanging down from the ceiling ...), ignoring what my current method and its called methods are doing.
source share