views:

18

answers:

1

I'm looking for a way to get the return value of a method via the Visual Studio Debugger (using DTE). Is it possible to obtain it if I'm at the closing brace of the method, but not yet exited? Also, it would be best if this could be possible without evaluating the function again via the immediate window.

+1  A: 

Nope. The debugger doesn't have enough information about the exact way the JIT compiler generated the code to return the value. It is a heavy duty implementation detail of the jitter and the specific architecture it generates code for.

Simple types like objects and integral types are not much of a problem, usually the EAX/RAX register, FPU stack or XMM0 register. It gets convoluted when the method returns a struct. That gets mapped to registers it the struct fits, but needs to spill over in a temporary stack buffer when the struct is too large.

I suspect they'll need to do a lot of work on the metadata that the jitter generates to get that working. You'll know when that work is complete, it will become visible in the Autos window. Like it used to be, back in the simple days.

Hans Passant
+1, one other option we considered was having in intermediate step in code gen that saved every method call into a stack variable that we could then put into the watch window. That was abandoned though due to complexity + confusion.
JaredPar