public int EnumChildren(enum_DEBUGPROP_INFO_FLAGS dwFields, uint dwRadix, ref Guid guidFilter, enum_DBG_ATTRIB_FLAGS dwAttribFilter, string pszNameFilter, uint dwTimeout, out IEnumDebugPropertyInfo2 ppEnum) { DEBUG_PROPERTY_INFO[] properties = new DEBUG_PROPERTY_INFO[_group.Count]; int i = 0; foreach (var reg in _engine.DebuggedProcess.GetRegisterDescriptions()) { if (reg.Group == _group) { properties[i].dwFields = 0; if ((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_NAME) != 0) { properties[i].bstrName = reg.Name; properties[i].dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_NAME; } if ((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE) != 0) { var desc = Array.Find(_values, (v) => { return v.Item1 == reg.Index; }); properties[i].bstrValue = desc == null ? "??" : desc.Item2; properties[i].dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE; } if ((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ATTRIB) != 0) { properties[i].dwAttrib = enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_VALUE_READONLY; properties[i].dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ATTRIB; } i++; } } Debug.Assert(i == _group.Count, "Failed to find registers in group."); ppEnum = new AD7PropertyEnum(properties); return Constants.S_OK; }
// 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; try { var children = TaskHelpers.RunSynchronouslyOnUIThread(ct => { var timeoutToken = CancellationTokens.GetToken(TimeSpan.FromMilliseconds(dwTimeout)); var linkedSource = CancellationTokenSource.CreateLinkedTokenSource(ct, timeoutToken); return(_evalResult.GetChildrenAsync(linkedSource.Token)); }); 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); } catch (OperationCanceledException) { return(VSConstants.S_FALSE); } }
public int EnumChildren(enum_DEBUGPROP_INFO_FLAGS dwFields, uint dwRadix, ref Guid guidFilter, enum_DBG_ATTRIB_FLAGS dwAttribFilter, string pszNameFilter, uint dwTimeout, out IEnumDebugPropertyInfo2 ppEnum) { string error = null; var attributeInfo = enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_NONE; Value value = _arrayValue ?? GetValue(_currentMirror, out attributeInfo, out error); //System.Diagnostics.Debug.WriteLine($"--- EnumChildren from Type {_currentMirror?.GetType().FullName} - _arrayValue: {_arrayValue != null} ValueInternalType: {value?.GetType().FullName}"); if (value is ArrayMirror) { var array = ((ArrayMirror)value); if (array.Rank == 1) { ppEnum = new AD7PropertyEnum(array.GetValues(0, array.Length).Select((x, i) => new MonoProperty(_stackFrame, _currentMirror, array.Type.GetElementType(), x, i.ToString()).GetDebugPropertyInfo(dwFields)).ToArray()); } else { // multidim array [,,] DEBUG_PROPERTY_INFO[] arrayValues = CreateMultiDimArrayPropertyInfos(dwFields, array); ppEnum = new AD7PropertyEnum(arrayValues); } return(VSConstants.S_OK); } else if (value is StructMirror) { var obj = value as StructMirror; var properties = obj.Type.GetProperties().Cast <Mirror>(); var fields = obj.Type.GetFields(); var children = properties.Concat(fields).ToList(); ppEnum = new AD7PropertyEnum(children.Select(x => new MonoProperty(_stackFrame, x, obj).GetDebugPropertyInfo(dwFields)).ToArray()); return(VSConstants.S_OK); } else if (value is ObjectMirror) { var obj = value as ObjectMirror; var properties = obj.Type.GetProperties().Cast <Mirror>(); var fields = obj.Type.GetFields(); var children = properties.Concat(fields).ToList(); ppEnum = new AD7PropertyEnum(children.Select(x => new MonoProperty(_stackFrame, x, obj).GetDebugPropertyInfo(dwFields)).ToArray()); return(VSConstants.S_OK); } else { //TODO } //TODO ppEnum = new AD7PropertyEnum(new DEBUG_PROPERTY_INFO[0]); return(VSConstants.S_OK); }
public int EnumChildren(enum_DEBUGPROP_INFO_FLAGS dwFields, uint dwRadix, ref Guid guidFilter, enum_DBG_ATTRIB_FLAGS dwAttribFilter, string pszNameFilter, uint dwTimeout, out IEnumDebugPropertyInfo2 ppEnum) { var typeMirror = variable.Type; var properties = typeMirror.GetProperties().Cast <Mirror>(); var methods = typeMirror.GetMethods(); var fields = typeMirror.GetFields(); var children = properties.Concat(methods).Concat(fields).ToList(); ppEnum = new AD7PropertyEnum(children.Select(x => new MonoProperty(frame, variable, typeMirror, x).GetDebugPropertyInfo(dwFields)).ToArray()); return(VSConstants.S_OK); }
public int EnumChildren(enum_DEBUGPROP_INFO_FLAGS dwFields, uint dwRadix, ref Guid guidFilter, enum_DBG_ATTRIB_FLAGS dwAttribFilter, string pszNameFilter, uint dwTimeout, out IEnumDebugPropertyInfo2 ppEnum) { var typeMirror = variable.Type; var properties = typeMirror.GetProperties().Cast<Mirror>(); var methods = typeMirror.GetMethods(); var fields = typeMirror.GetFields(); var children = properties.Concat(methods).Concat(fields).ToList(); ppEnum = new AD7PropertyEnum(children.Select(x => new MonoProperty(frame, variable, typeMirror, x).GetDebugPropertyInfo(dwFields)).ToArray()); return VSConstants.S_OK; }
// 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; if (this.m_variableInformation.HasChildren()) { DEBUG_PROPERTY_INFO[] properties = new DEBUG_PROPERTY_INFO[1]; properties[0] = (new AD7Property(this.m_variableInformation.Children[0])).ConstructDebugPropertyInfo(dwFields); ppEnum = new AD7PropertyEnum(properties); return VSConstants.S_OK; } return VSConstants.S_FALSE; }
// 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 Guid guidFilter, enum_DBG_ATTRIB_FLAGS dwAttribFilter, string pszNameFilter, uint dwTimeout, out IEnumDebugPropertyInfo2 ppEnum) { TimeSpan timeout = TimeSpan.FromMilliseconds(dwTimeout); var tokenSource = new CancellationTokenSource(timeout); List<NodeEvaluationResult> children = _evaluationResult.GetChildrenAsync(tokenSource.Token) .WaitAsync(timeout, tokenSource.Token).Result; DEBUG_PROPERTY_INFO[] properties; if (children == null || children.Count == 0) { properties = new[] { new DEBUG_PROPERTY_INFO { dwFields = enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_NAME, bstrValue = "No children" } }; } else { properties = new DEBUG_PROPERTY_INFO[children.Count]; for (int i = 0; i < children.Count; i++) { properties[i] = new AD7Property(_frame, children[i], this).ConstructDebugPropertyInfo(dwRadix, dwFields); } } if (dwFields.HasFlag(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_NAME)) { properties = properties.OrderBy(p => p.bstrName, _comparer).ToArray(); } ppEnum = new AD7PropertyEnum(properties); return VSConstants.S_OK; }
/// <summary> /// Enumerates the children of a property. This provides support for dereferencing pointers, displaying members of an array, or /// fields of a class or struct. (http://msdn.microsoft.com/en-us/library/bb161791.aspx) /// </summary> /// <param name="dwFields"> A combination of flags from the DEBUGPROP_INFO_FLAGS enumeration that specifies which fields in /// the enumerated DEBUG_PROPERTY_INFO structures are to be filled in. </param> /// <param name="dwRadix"> Specifies the radix to be used in formatting any numerical information. </param> /// <param name="guidFilter"> GUID of the filter used with the dwAttribFilter and pszNameFilter parameters to select which /// DEBUG_PROPERTY_INFO children are to be enumerated. For example, guidFilterLocals filters for local variables. </param> /// <param name="dwAttribFilter"> A combination of flags from the DBG_ATTRIB_FLAGS enumeration that specifies what type of /// objects to enumerate, for example DBG_ATTRIB_METHOD for all methods that might be children of this property. Used in /// combination with the guidFilter and pszNameFilter parameters. </param> /// <param name="pszNameFilter"> The name of the filter used with the guidFilter and dwAttribFilter parameters to select which /// DEBUG_PROPERTY_INFO children are to be enumerated. For example, setting this parameter to "MyX" filters for all children /// with the name "MyX." </param> /// <param name="dwTimeout"> Specifies the maximum time, in milliseconds, to wait before returning from this method. Use /// INFINITE to wait indefinitely. </param> /// <param name="ppEnum"> Returns an IEnumDebugPropertyInfo2 object containing a list of the child properties. </param> /// <returns> If successful, returns S_OK; otherwise returns S_FALSE. </returns> 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; if (_variableInfo != null) { if (_variableInfo._children != null) { if (_variableInfo._children.Count == 0) { // This is an array, struct, union, or pointer. // Create a variable object so we can list this variable's children. /// Some VS variable names cannot be used by GDB. When that happens, it is added the prefix VsNdK_ to the GDB variable /// name and it is stored in the GDBNames array. At the same time, the VS name is stored in the VSNames array using the /// same index position. This bool variable just indicate if this prefix is used or not. bool hasVsNdK_ = false; string numChildren = AD7StackFrame.m_dispatcher.createVar(_variableInfo._name, ref hasVsNdK_); ArrayList GDBNames = new ArrayList(); ArrayList VSNames = new ArrayList(); if (hasVsNdK_) { _variableInfo._GDBName = "VsNdK_" + _variableInfo._name; GDBNames.Add("VsNdK_" + _variableInfo._name); VSNames.Add(_variableInfo._name); } try // Catch non-numerical data { if (Convert.ToInt32(numChildren) > 0) // If the variable has children evaluate { if (_variableInfo._type.Contains("struct")) if (_variableInfo._type[_variableInfo._type.Length - 1] == '*') _variableInfo.listChildren(AD7StackFrame.m_dispatcher, "*", GDBNames, VSNames, hasVsNdK_, null); else if (_variableInfo._type.Contains("[")) _variableInfo.listChildren(AD7StackFrame.m_dispatcher, "struct[]", GDBNames, VSNames, hasVsNdK_, null); else _variableInfo.listChildren(AD7StackFrame.m_dispatcher, "struct", GDBNames, VSNames, hasVsNdK_, null); else if (_variableInfo._type.Contains("[")) _variableInfo.listChildren(AD7StackFrame.m_dispatcher, "[]", GDBNames, VSNames, hasVsNdK_, null); else if (_variableInfo._type.Contains("*")) _variableInfo.listChildren(AD7StackFrame.m_dispatcher, "*", GDBNames, VSNames, hasVsNdK_, null); else _variableInfo.listChildren(AD7StackFrame.m_dispatcher, "", GDBNames, VSNames, hasVsNdK_, null); } } catch (FormatException e) { } AD7StackFrame.m_dispatcher.deleteVar(_variableInfo._name, hasVsNdK_); } DEBUG_PROPERTY_INFO[] properties = new DEBUG_PROPERTY_INFO[_variableInfo._children.Count]; int i = 0; foreach (VariableInfo child in _variableInfo._children) { VariableInfo.evaluateExpression(child._name, ref child._value, child._GDBName); properties[i] = new AD7Property(child).ConstructDebugPropertyInfo(dwFields); i++; } ppEnum = new AD7PropertyEnum(properties); return VSConstants.S_OK; } } else if (_stackFrame != null) { uint elementsReturned = 0; _stackFrame.CreateLocalsPlusArgsProperties(dwFields, out elementsReturned, out ppEnum); return VSConstants.S_OK; } return VSConstants.S_FALSE; }
// Enumerates the children of a property. This provides support for dereferencing pointers, displaying members of an array, or fields of a class or struct. public int EnumChildren(enum_DEBUGPROP_INFO_FLAGS dwFields, uint dwRadix, ref Guid guidFilter, enum_DBG_ATTRIB_FLAGS dwAttribFilter, string pszNameFilter, uint dwTimeout, out IEnumDebugPropertyInfo2 ppEnum) { ppEnum = null; _variableInformation.EnsureChildren(); if (_variableInformation.CountChildren != 0) { try { DebuggedProcess.g_Process.Natvis.WaitDialog.ShowWaitDialog(_variableInformation.Name); var children = DebuggedProcess.g_Process.Natvis.Expand(_variableInformation); DEBUG_PROPERTY_INFO[] properties = new DEBUG_PROPERTY_INFO[children.Length]; for (int i = 0; i < children.Length; i++) { properties[i] = (new AD7Property(children[i])).ConstructDebugPropertyInfo(dwFields); } ppEnum = new AD7PropertyEnum(properties); return Constants.S_OK; } finally { DebuggedProcess.g_Process.Natvis.WaitDialog.EndWaitDialog(); } } return Constants.S_FALSE; }
// 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; }
// 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(DIF dwFields, uint dwRadix, ref System.Guid guidFilter, enum_DBG_ATTRIB_FLAGS dwAttribFilter, string pszNameFilter, uint dwTimeout, out IEnumDebugPropertyInfo2 ppEnum) { ppEnum = null; try { ppEnum = new AD7PropertyEnum(m_variableInformation .GetChildren().OrderBy(v => v.m_name) .Select(v => new AD7Property(v).ConstructDebugPropertyInfo(dwFields)) ); return Constants.S_OK; } catch { return Constants.S_FALSE; } }
// 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; if (_variableInfo._children != null) { if (_variableInfo._children.Count == 0) { // This is an array, struct, union, or pointer. // Create a variable object so we can list this variable's children. bool hasVsNdK_ = false; string numChildren = AD7StackFrame.m_dispatcher.createVar(_variableInfo._name, ref hasVsNdK_); ArrayList GDBNames = new ArrayList(); ArrayList VSNames = new ArrayList(); if (hasVsNdK_) { _variableInfo._GDBName = "VsNdK_" + _variableInfo._name; GDBNames.Add("VsNdK_" + _variableInfo._name); VSNames.Add(_variableInfo._name); } try // Catch non-numerical data { if (Convert.ToInt32(numChildren) > 0) // If the variable has children evaluate { if (_variableInfo._type.Contains("struct")) if (_variableInfo._type[_variableInfo._type.Length - 1] == '*') _variableInfo.listChildren(AD7StackFrame.m_dispatcher, "*", GDBNames, VSNames, hasVsNdK_, null); else if (_variableInfo._type.Contains("[")) _variableInfo.listChildren(AD7StackFrame.m_dispatcher, "struct[]", GDBNames, VSNames, hasVsNdK_, null); else _variableInfo.listChildren(AD7StackFrame.m_dispatcher, "struct", GDBNames, VSNames, hasVsNdK_, null); else if (_variableInfo._type.Contains("[")) _variableInfo.listChildren(AD7StackFrame.m_dispatcher, "[]", GDBNames, VSNames, hasVsNdK_, null); else if (_variableInfo._type.Contains("*")) _variableInfo.listChildren(AD7StackFrame.m_dispatcher, "*", GDBNames, VSNames, hasVsNdK_, null); else _variableInfo.listChildren(AD7StackFrame.m_dispatcher, "", GDBNames, VSNames, hasVsNdK_, null); } } catch (FormatException e) { } AD7StackFrame.m_dispatcher.deleteVar(_variableInfo._name, hasVsNdK_); } DEBUG_PROPERTY_INFO[] properties = new DEBUG_PROPERTY_INFO[_variableInfo._children.Count]; int i = 0; foreach (VariableInfo child in _variableInfo._children) { VariableInfo.evaluateExpression(child._name, ref child._value, child._GDBName); properties[i] = new AD7Property(child).ConstructDebugPropertyInfo(dwFields); i++; } ppEnum = new AD7PropertyEnum(properties); return VSConstants.S_OK; } return VSConstants.S_FALSE; }
public int EnumChildren(enum_DEBUGPROP_INFO_FLAGS dwFields, uint dwRadix, ref Guid guidFilter, enum_DBG_ATTRIB_FLAGS dwAttribFilter, string pszNameFilter, uint dwTimeout, out IEnumDebugPropertyInfo2 ppEnum) { ppEnum = null; IList<NodeEvaluationResult> children = _variable.Children; if (children == null) { return VSConstants.S_FALSE; } var properties = new DEBUG_PROPERTY_INFO[children.Count]; for (int i = 0; i < children.Count; i++) { properties[i] = new AD7Property(children[i]).ConstructDebugPropertyInfo(dwRadix, dwFields); } ppEnum = new AD7PropertyEnum(properties); return VSConstants.S_OK; }