Visual Studio Extension for User Memory Window

My custom tool window in the Visual Studio Extension package should evaluate custom expressions during debugging sessions for VS2012 and VS2013. The ultimate goal is to create a graphical viewport. Therefore, I should get the value of the result of the expression from the debugging mechanism.

Evaluation works fine through

IDebugStackFrame2 -> IDebugExpressionContext2 -> ParseText 
IDebugExpression2 -> EvaluateSync -> IDebugProperty2

The first problem is here: Visual Studio 2013 ParseText()reports errors incorrectly. But the extracted is IDebugProperty2valid (for valid expressions). On VS2012, I get the correct errors for invalid expressions.

This is where the real problem begins. Result Property2 is a complex user object. To visualize it, you need to get a specific property from one of its base classes. In my current attempt, I use IDebugProperty2.EnumChildren()to move through my members to the right place in the class hierarchy, as it would in the Locals window in Visual Studio:

[result] -> base -> Raw -> base -> Non-public Members -> [private field] ... a.s.o.

This somehow works, but introduces the following problems:

Task 1: Get the inner member of some complex object

, EnumChildren(), -, , : * ? (VS2013 enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE_RAW EnumChildren + "Raw View" node, VS2012 , ) * " " node? , - , * " " (" , ) *... ?

. ? IDebugProperty3 Visualizer? .

2: VS2012

, IDebugProperty2.GetMemoryBytes() , "" ( System.Array) . VS2013, VS2012 IDebugProperty2.GetMemoryBytes() VS_Constants.S_FALSE. . VS2012 , - ? ?

, API- :

IDebugMemoryContext2 memCtx = null;
IDebugMemoryBytes2 memBytes = null;

// getting the memory context is working ok
if (tmpProperty2.GetMemoryContext(out memCtx) == VSConstants.S_OK

  // VS2012 fails here, always returns S_FALSE, memBytes remains null:
  && (tmpProperty2.GetMemoryBytes(out memBytes) == VSConstants.S_OK)) { 
  ...

:

OS: Windows 8 and 8.1 
Visual Studio: 2012 / 2013
Tool Window built with MPF (C#) in VS2013, (removed all vers. 12 references from the package before deploying to VS2012)
Debug engines: C# and Visual Basic
+4

Source: https://habr.com/ru/post/1535716/


All Articles