I am writing a Visual Studio Extension to test for specific data types in Visual Studio Debugger. For this, I would like to examine the contents of a large .NET array, for example. array byte []. But I struggle for how effective it is. So far, I registered my class to receive DebugEvents and saved the last thread every time an event occurs:
IVsDebugger debugService = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsShellDebugger)) as IVsDebugger;
debugService.AdviseDebugEventCallback(this);
...
public int Event(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent, ref Guid riidEvent, uint dwAttrib)
{
lastThread = pThread;
}
To test the object, I hold the Stackframe from the lastThread object and get the IDebugExpressionContext2 from the Stackframe. Assuming there is an Oject called a test that has a byte [] proberty Matrix, I do the following
IDebugExpression2 expression;
string error;
uint errorCharIndex;
epressionContext.ParseText("test.Matrix", (enum_PARSEFLAGS.PARSE_EXPRESSION), 10,
out expression, out error, out errorCharIndex);
IDebugProperty2 debugProperty = null;
expression.EvaluateSync(enum_EVALFLAGS.EVAL_NOSIDEEFFECTS,1000, null, out
debugProperty);
DEBUG_PROPERTY_INFO[] info = new DEBUG_PROPERTY_INFO[1];
debugProperty.GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ALL, 0, 1000,
null, 0, info);
, . IDebugMemoryByte2 byte [], null.
IDebugMemoryContext2 memoryContext;
debugProperty.GetMemoryContext(out memoryContext);
IDebugMemoryBytes2 memoryBytes;
debugProperty.GetMemoryBytes(out memoryBytes);
DEBUG_PROPERTY_STRUCTURE , . , ?