views:

43

answers:

1

I have a VSPackage that I would like to get information similar to that shown in the locals window when in debug mode (the values of variables for the current context).

I have been experimenting with the DTE.Debugger.CurrentStackFrame instance which looked interesting because it exposed Argument and Local collections of expressions. However, I can't see a way of getting the value of an expression as an object - the Value property just seems to be the ToString value.

Any ideas?

+1  A: 

It is not possible to get ahold of the value as an object. Mainly because the value doesn't exist in the same process as your VS Package. It exists in the debugee process. The Visual Studio Debugger has to go through the CLR API's to manipulate the value. The best you can do is get ahold of the string value from the VS Package.

JaredPar
Does the debugger not expose this information? I expected a central store that the various debugging views interact with (i.e. the Locals, Watch, Immediate windows and when hovering over variables in the code). Also, can you elaborate on the CLR APIs that you mentioned?
Alan Spark
@Alan, the Visual Studio debugger exposes the view of this information but not the underlying data. The VS debugger itself doesn't actually know what these values are and instead relies on language specific expression evaluators (EEs) to talk with the actual debugee process. Essentially VS asks each EE to give the current set of locals which are returned as IDebugProperty objects. The VS debugger can use this interface to inspect the values but it never actually gets back the raw debugger object. The CLR APIs are the ICorDebug APIs
JaredPar
Thanks for your detailed response Jared. I appreciate your help.
Alan Spark