// This method evaluates the expression synchronously. int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult) { AutoResetEvent completion = new AutoResetEvent(false); PythonEvaluationResult result = null; _frame.StackFrame.ExecuteText(_expression, (obj) => { result = obj; completion.Set(); }); while (!_frame.StackFrame.Thread.Process.HasExited && !completion.WaitOne(Math.Min((int)dwTimeout, 100))) { if (dwTimeout <= 100) { break; } dwTimeout -= 100; } if (_frame.StackFrame.Thread.Process.HasExited || result == null) { ppResult = null; return VSConstants.E_FAIL; } else if (result == null) { ppResult = null; return DebuggerConstants.E_EVALUATE_TIMEOUT; } ppResult = new AD7Property(_frame, result, _writable); return VSConstants.S_OK; }
// Construct an instance of IEnumDebugPropertyInfo2 for the parameters collection only. private void CreateParameterProperties(uint radix, out uint elementsReturned, out IEnumDebugPropertyInfo2 enumObject) { elementsReturned = (uint)_parameters.Length; DEBUG_PROPERTY_INFO[] propInfo = new DEBUG_PROPERTY_INFO[_parameters.Length]; for (int i = 0; i < propInfo.Length; i++) { AD7Property property = new AD7Property(this, _parameters[i], true); propInfo[i] = property.ConstructDebugPropertyInfo(radix, enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_STANDARD); } enumObject = new AD7PropertyInfoEnum(propInfo); }
// Enumerates the children of a property. This provides support for dereferencing pointers, displaying members of an array, or fields of a class or struct. // The sample debugger only supports pointer dereferencing as children. This means there is only ever one child. public int EnumChildren(enum_DEBUGPROP_INFO_FLAGS dwFields, uint dwRadix, ref System.Guid guidFilter, enum_DBG_ATTRIB_FLAGS dwAttribFilter, string pszNameFilter, uint dwTimeout, out IEnumDebugPropertyInfo2 ppEnum) { ppEnum = null; var children = _evalResult.GetChildren((int)dwTimeout); if (children != null) { DEBUG_PROPERTY_INFO[] properties = new DEBUG_PROPERTY_INFO[children.Length]; for (int i = 0; i < children.Length; i++) { properties[i] = new AD7Property(_frame, children[i], true).ConstructDebugPropertyInfo(dwRadix, dwFields); } ppEnum = new AD7PropertyEnum(properties); return(VSConstants.S_OK); } return(VSConstants.S_FALSE); }
// Construct an instance of IEnumDebugPropertyInfo2 for the combined locals and parameters. private void CreateLocalsPlusArgsProperties(out uint elementsReturned, out IEnumDebugPropertyInfo2 enumObject) { elementsReturned = 0; int localsLength = 0; if (_locals != null) { localsLength = _locals.Length; elementsReturned += (uint)localsLength; } if (_parameters != null) { elementsReturned += (uint)_parameters.Length; } DEBUG_PROPERTY_INFO[] propInfo = new DEBUG_PROPERTY_INFO[elementsReturned]; if (_locals != null) { for (int i = 0; i < _locals.Length; i++) { AD7Property property = new AD7Property(this, _locals[i], true); propInfo[i] = property.ConstructDebugPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_STANDARD); } } if (_parameters != null) { for (int i = 0; i < _parameters.Length; i++) { AD7Property property = new AD7Property(this, _parameters[i], true); propInfo[localsLength + i] = property.ConstructDebugPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_STANDARD); } } enumObject = new AD7PropertyInfoEnum(propInfo); }
// Construct an instance of IEnumDebugPropertyInfo2 for the combined locals and parameters. private void CreateLocalsPlusArgsProperties(uint radix, out uint elementsReturned, out IEnumDebugPropertyInfo2 enumObject) { elementsReturned = 0; int localsLength = 0; if (_locals != null) { localsLength = _locals.Length; elementsReturned += (uint)localsLength; } if (_parameters != null) { elementsReturned += (uint)_parameters.Length; } DEBUG_PROPERTY_INFO[] propInfo = new DEBUG_PROPERTY_INFO[elementsReturned]; if (_locals != null) { for (int i = 0; i < _locals.Length; i++) { AD7Property property = new AD7Property(this, _locals[i], true); propInfo[i] = property.ConstructDebugPropertyInfo(radix, enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_STANDARD); } } if (_parameters != null) { for (int i = 0; i < _parameters.Length; i++) { AD7Property property = new AD7Property(this, _parameters[i], true); propInfo[localsLength + i] = property.ConstructDebugPropertyInfo(radix, enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_STANDARD); } } enumObject = new AD7PropertyInfoEnum(propInfo); }
// Enumerates the children of a property. This provides support for dereferencing pointers, displaying members of an array, or fields of a class or struct. // The sample debugger only supports pointer dereferencing as children. This means there is only ever one child. public int EnumChildren(enum_DEBUGPROP_INFO_FLAGS dwFields, uint dwRadix, ref System.Guid guidFilter, enum_DBG_ATTRIB_FLAGS dwAttribFilter, string pszNameFilter, uint dwTimeout, out IEnumDebugPropertyInfo2 ppEnum) { ppEnum = null; var children = _evalResult.GetChildren((int)dwTimeout); if (children != null) { DEBUG_PROPERTY_INFO[] properties = new DEBUG_PROPERTY_INFO[children.Length]; for (int i = 0; i < children.Length; i++) { properties[i] = new AD7Property(_frame, children[i], true).ConstructDebugPropertyInfo(dwRadix, dwFields); } ppEnum = new AD7PropertyEnum(properties); return VSConstants.S_OK; } return VSConstants.S_FALSE; }