/********* ** Private methods *********/ /// <summary>Get a formatted representation of a set of debug fields.</summary> /// <param name="fields">The debug fields to display.</param> private IEnumerable <IFormattedText> GetFormattedText(IDebugField[] fields) { for (int i = 0, last = fields.Length - 1; i <= last; i++) { IDebugField field = fields[i]; yield return(new FormattedText("*", Color.Red, bold: true)); yield return(new FormattedText($"{field.Label}:")); yield return(i != last ? new FormattedText($"{field.Value}{Environment.NewLine}") : new FormattedText(field.Value)); } }
internal static IDebugType DebugTypeFromField(IDebugField field, IDebugContext context) { IDebugType type = null; FIELD_KIND kind; field.GetKind(out kind); if (0 != (FIELD_KIND.FIELD_KIND_TYPE & kind)) { if (0 != (kind & FIELD_KIND.FIELD_TYPE_PRIMITIVE)){ type = new CDebugPrimitiveType(field, context); } else if (0 != (kind & (FIELD_KIND.FIELD_TYPE_CLASS|FIELD_KIND.FIELD_TYPE_STRUCT|FIELD_KIND.FIELD_TYPE_INNERCLASS))) { IDebugClassField classField = null; if (null != (classField = field as IDebugClassField)) { if (classField.DoesInterfaceExist("StructuralTypes.TupleType") == (int)HResult.S_OK) type = new CDebugStructuralType(classField, context, StructTypes.Tuple); else if(classField.DoesInterfaceExist("StructuralTypes.TypeUnion") == (int)HResult.S_OK) type = new CDebugStructuralType(classField, context, StructTypes.Union); else if(classField.DoesInterfaceExist("StructuralTypes.TypeIntersection") == (int)HResult.S_OK) type = new CDebugStructuralType(classField, context, StructTypes.Intersection); else{ FIELD_INFO name = new FIELD_INFO(); classField.GetInfo(FIELD_INFO_FIELDS.FIF_NAME, out name); if (name.bstrName.IndexOf("IEnumerableOf") >=0) type = new CDebugStreamType(classField, context, StreamType.GenericIEnumerable); else if (name.bstrName.IndexOf("NonEmptyIEnumerableOf") >=0) type = new CDebugStreamType(classField, context, StreamType.GenericNonEmptyIEnumerable); else if (name.bstrName.IndexOf("NonNullOf") >=0) type = new CDebugStreamType(classField, context, StreamType.GenericNonNull); else if (name.bstrName.IndexOf("BoxedOf") >=0) type = new CDebugStreamType(classField, context, StreamType.GenericBoxed); else if (name.bstrName.IndexOf("IListOf") >=0) type = new CDebugFlexArrayType(classField, context); else type = new CDebugClassType(classField, context); } } } else if (0 != (kind & FIELD_KIND.FIELD_TYPE_ENUM)) { IDebugEnumField enumField = null; if (null != (enumField = field as IDebugEnumField)) { type = new CDebugEnumType(enumField, context); } } else if (0 != (kind & FIELD_KIND.FIELD_TYPE_ARRAY)) { IDebugArrayField arrayField = null; if (null != (arrayField = field as IDebugArrayField)) { type = new CDebugArrayType(arrayField, context); } } } return type; }
public IDebugType GetType(string fullName) { IDebugField type = null; this.SymbolProvider.GetTypeByName(fullName, NAME_MATCH.nmCaseSensitive, out type); if (type != null) { return(SymbolHelper.DebugTypeFromField(type, this)); } IEnumDebugFields namespaceList = null; this.SymbolProvider.GetNamespacesUsedAtAddress(this.Address, out namespaceList); if (namespaceList != null) { int namespaceCount = 0; int fetched = 0; FIELD_INFO namespaceInfo = new FIELD_INFO(); namespaceList.GetCount(out namespaceCount); for (int i = 0; i < namespaceCount; i++) { IDebugField[] namespc = new IDebugField[1]; namespaceList.Next(1, namespc, out fetched); if (fetched > 0) { namespc[0].GetInfo(FIELD_INFO_FIELDS.FIF_FULLNAME, out namespaceInfo); this.SymbolProvider.GetTypeByName(namespaceInfo.bstrFullName + "." + fullName, NAME_MATCH.nmCaseSensitive, out type); if (type != null) { return(SymbolHelper.DebugTypeFromField(type, this)); } } } } if (type == null) { this.SymbolProvider.GetTypeByName("StructuralTypes." + fullName, NAME_MATCH.nmCaseSensitive, out type); } if (type != null) { return(SymbolHelper.DebugTypeFromField(type, this)); } return(null); }
public IDebugType GetType(string fullName) { IDebugField type = null; this.SymbolProvider.GetTypeByName(fullName, NAME_MATCH.nmCaseSensitive, out type); if (type != null) return SymbolHelper.DebugTypeFromField(type, this); IEnumDebugFields namespaceList = null; this.SymbolProvider.GetNamespacesUsedAtAddress(this.Address, out namespaceList); if (namespaceList!= null){ int namespaceCount = 0; int fetched = 0; FIELD_INFO namespaceInfo = new FIELD_INFO(); namespaceList.GetCount(out namespaceCount); for (int i = 0; i < namespaceCount; i++){ IDebugField[] namespc = new IDebugField[1]; namespaceList.Next(1, namespc, out fetched); if (fetched > 0){ namespc[0].GetInfo(FIELD_INFO_FIELDS.FIF_FULLNAME, out namespaceInfo); this.SymbolProvider.GetTypeByName(namespaceInfo.bstrFullName+"."+fullName, NAME_MATCH.nmCaseSensitive, out type); if (type != null) return SymbolHelper.DebugTypeFromField(type, this); } } } if (type == null) this.SymbolProvider.GetTypeByName("StructuralTypes."+fullName, NAME_MATCH.nmCaseSensitive, out type); if (type != null) return SymbolHelper.DebugTypeFromField(type, this); return null; }
public CDebugValue(IDebugObject pObject, IDebugContext pContext) { this.m_Object = pObject; this.m_Context = pContext; this.m_RuntimeType = null; }
public void SetValue(object val) { byte[] valueBytes = null; IDebugBinder binder = this.m_Context.Binder; if (null == this.m_RuntimeType) { binder.ResolveRuntimeType(this.m_Object, out this.m_RuntimeType); } if (null != this.m_RuntimeType) { IDebugObject pObject = this.m_Object; IDebugField type = this.m_RuntimeType; if (null != pObject) { uint size = 0; pObject.GetSize(out size); if (0 < size) { valueBytes = new byte[size]; if (null != valueBytes) { FIELD_KIND fieldKind = 0; type.GetKind(out fieldKind); if (0 != fieldKind) { if (0 != (fieldKind & FIELD_KIND.FIELD_TYPE_PRIMITIVE)) { FIELD_INFO fieldInfo; type.GetInfo(FIELD_INFO_FIELDS.FIF_NAME, out fieldInfo); if (null != fieldInfo.bstrName) { switch (size) { case 1: if (0 == String.Compare("whole", fieldInfo.bstrName, true)) { valueBytes[0] = (byte )val; } else if (0 == String.Compare("uwhole", fieldInfo.bstrName, true)) { valueBytes[0] = (byte )val; } break; case 2: if (0 == String.Compare("whole", fieldInfo.bstrName, true)) { Int16 temp = (Int16)val; valueBytes[0] = System.Convert.ToByte(temp & 0x00FF); valueBytes[1] = System.Convert.ToByte(temp >> 8); } else if (0 == String.Compare("char", fieldInfo.bstrName, true)) { UInt16 temp = (UInt16)val; valueBytes[0] = System.Convert.ToByte(temp & 0x00FF); valueBytes[1] = System.Convert.ToByte(temp >> 8); } else if (0 == String.Compare("uwhole", fieldInfo.bstrName, true)) { UInt16 temp = (UInt16)val; valueBytes[0] = System.Convert.ToByte(temp & 0x00FF); valueBytes[1] = System.Convert.ToByte(temp >> 8); } break; case 4: if (0 == String.Compare("whole", fieldInfo.bstrName, true)) { Int32 temp = (Int32)val; valueBytes[0] = System.Convert.ToByte(temp & 0xFF); valueBytes[1] = System.Convert.ToByte((temp >> 8) & 0xFF); valueBytes[2] = System.Convert.ToByte((temp >> 8) & 0xFF); valueBytes[3] = System.Convert.ToByte(temp >> 8); } else if (0 == String.Compare("uwhole", fieldInfo.bstrName, true)) { UInt32 temp = (UInt32)val; valueBytes[0] = System.Convert.ToByte(temp & 0xFF); valueBytes[1] = System.Convert.ToByte((temp >> 8) & 0xFF); valueBytes[2] = System.Convert.ToByte((temp >> 8) & 0xFF); valueBytes[3] = System.Convert.ToByte(temp >> 8); } else if (0 == String.Compare("real", fieldInfo.bstrName, true)) { UInt32 temp = (UInt32)val; valueBytes[0] = System.Convert.ToByte(temp & 0xFF); valueBytes[1] = System.Convert.ToByte((temp >> 8) & 0xFF); valueBytes[2] = System.Convert.ToByte((temp >> 8) & 0xFF); valueBytes[3] = System.Convert.ToByte(temp >> 8); } break; case 8: if (0 == String.Compare("whole", fieldInfo.bstrName, true)) { //pRetVal->vt = VT_I8; //pRetVal->llVal = *reinterpret_cast<LONGLONG*>(valueBytes); } else if (0 == String.Compare("uwhole", fieldInfo.bstrName, true)) { //pRetVal->vt = VT_UI8; //pRetVal->ullVal = *reinterpret_cast<ULONGLONG*>(valueBytes); } else if (0 == String.Compare("real", fieldInfo.bstrName, true)) { //pRetVal->vt = VT_R8; //pRetVal->dblVal = *reinterpret_cast<DOUBLE*>(valueBytes); } break; } if (0 == String.Compare("bool", fieldInfo.bstrName, true)) { //pRetVal->vt = VT_BOOL; bool temp = (bool)val; for (uint i = 0; i < size; i++) { if (temp) { valueBytes[i] = 1; } else { valueBytes[i] = 0; } } } else if (0 == String.Compare("string", fieldInfo.bstrName, true)) { //VSASSERT(size >= 2, "String length is too short"); //VSASSERT(size % 2 == 0, "String of odd byte length"); //UINT chars = (size-2)/2; // Debug engine adds 2 for terminating L'\0' //pRetVal->vt = VT_BSTR; //pRetVal->bstrVal = SysAllocStringLen(NULL, chars); //wcsncpy(pRetVal->bstrVal, reinterpret_cast<WCHAR*>(valueBytes), chars); //pRetVal->bstrVal[chars] = L'\0'; String temp = val as String; char[] charArray = temp.ToCharArray(); valueBytes = new byte[2 * charArray.Length + 2]; int i = 0; for ( ; i < charArray.Length; i++) { UInt16 temp1 = (UInt16)charArray[i]; valueBytes[2 * i] = System.Convert.ToByte(temp1 & 0x00FF); valueBytes[2 * i + 1] = System.Convert.ToByte(temp1 >> 8); } valueBytes[2 * i] = valueBytes[2 * i + 1] = 0; } } } } } } } } this.m_Object.SetValue(valueBytes, (uint)valueBytes.Length); }
public Object GetValue() { Object pRetVal = null; IDebugBinder binder = this.m_Context.Binder; if (null == this.m_RuntimeType) { binder.ResolveRuntimeType(this.m_Object, out this.m_RuntimeType); } if (null != this.m_RuntimeType) { IDebugObject pObject = this.m_Object; IDebugField type = this.m_RuntimeType; IDebugEnumField enumField = null; enumField = this.m_RuntimeType as IDebugEnumField; if (null != enumField) { IDebugField underlyingField = null; enumField.GetUnderlyingSymbol(out underlyingField); if (null != underlyingField) { IDebugObject underlyingObject = null; binder.Bind(this.m_Object, underlyingField, out underlyingObject); if (null != underlyingObject) { pObject = underlyingObject; } IDebugField underlyingType = null; underlyingField.GetType(out underlyingType); if (null != underlyingType) { type = underlyingType; } } } if (null != pObject) { uint size = 0; pObject.GetSize(out size); if (0 < size) { byte[] valueBytes = new byte[size]; if (null != valueBytes) { pObject.GetValue(valueBytes, size); if (null != valueBytes) { FIELD_KIND fieldKind = 0; type.GetKind(out fieldKind); if (0 != fieldKind) { if (0 != (fieldKind & FIELD_KIND.FIELD_TYPE_PRIMITIVE)) { FIELD_INFO fieldInfo; type.GetInfo(FIELD_INFO_FIELDS.FIF_NAME, out fieldInfo); if (null != fieldInfo.bstrName) { switch (size) { case 1: if (0 == String.Compare("whole", fieldInfo.bstrName, true)) { pRetVal = valueBytes[0]; } else if (0 == String.Compare("uwhole", fieldInfo.bstrName, true)) { pRetVal = valueBytes[0]; } break; case 2: if (0 == String.Compare("whole", fieldInfo.bstrName, true)) { UInt16 temp = 0; for (int i = 0; i < 2; i++) { temp <<= 8; temp |= valueBytes[1 - i]; } pRetVal = (Int16 )temp; //pRetVal->vt = VT_I2; //pRetVal->iVal = *reinterpret_cast<SHORT*>(valueBytes); } else if (0 == String.Compare("char", fieldInfo.bstrName, true)) { UInt16 temp = 0; for (int i = 0; i < 2; i++) { temp <<= 8; temp |= valueBytes[1 - i]; } pRetVal = temp; //pRetVal->vt = VT_UI2; //pRetVal->uiVal = *reinterpret_cast<USHORT*>(valueBytes); } else if (0 == String.Compare("uwhole", fieldInfo.bstrName, true)) { UInt16 temp = 0; for (int i = 0; i < 2; i++) { temp <<= 8; temp |= valueBytes[1 - i]; } pRetVal = temp; //pRetVal->vt = VT_UI2; //pRetVal->uiVal = *reinterpret_cast<USHORT*>(valueBytes); } break; case 4: if (0 == String.Compare("whole", fieldInfo.bstrName, true)) { Int32 temp = 0; for (int i = 0; i < 4; i++) { temp <<= 8; temp |= valueBytes[3 - i]; } pRetVal = temp; //pRetVal->vt = VT_I4; //pRetVal->lVal = *reinterpret_cast<LONG*>(valueBytes); } else if (0 == String.Compare("uwhole", fieldInfo.bstrName, true)) { UInt32 temp = 0; for (int i = 0; i < 4; i++) { temp <<= 8; temp |= valueBytes[3 - i]; } pRetVal = temp; //pRetVal->vt = VT_UI4; //pRetVal->ulVal = *reinterpret_cast<ULONG*>(valueBytes); } else if (0 == String.Compare("real", fieldInfo.bstrName, true)) { Int32 temp = 0; for (int i = 0; i < 4; i++) { temp <<= 8; temp |= valueBytes[3 - i]; } pRetVal = temp; //pRetVal->vt = VT_R4; //pRetVal->fltVal = *reinterpret_cast<FLOAT*>(valueBytes); } break; case 8: if (0 == String.Compare("whole", fieldInfo.bstrName, true)) { //pRetVal->vt = VT_I8; //pRetVal->llVal = *reinterpret_cast<LONGLONG*>(valueBytes); } else if (0 == String.Compare("uwhole", fieldInfo.bstrName, true)) { //pRetVal->vt = VT_UI8; //pRetVal->ullVal = *reinterpret_cast<ULONGLONG*>(valueBytes); } else if (0 == String.Compare("real", fieldInfo.bstrName, true)) { //pRetVal->vt = VT_R8; //pRetVal->dblVal = *reinterpret_cast<DOUBLE*>(valueBytes); } break; } if (0 == String.Compare("bool", fieldInfo.bstrName, true)) { //pRetVal->vt = VT_BOOL; pRetVal = false; for (uint i = 0; i < size; i++) { if (valueBytes[i] != 0) { pRetVal = true; } } } else if (0 == String.Compare("string", fieldInfo.bstrName, true)) { //VSASSERT(size >= 2, "String length is too short"); //VSASSERT(size % 2 == 0, "String of odd byte length"); //UINT chars = (size-2)/2; // Debug engine adds 2 for terminating L'\0' //pRetVal->vt = VT_BSTR; //pRetVal->bstrVal = SysAllocStringLen(NULL, chars); //wcsncpy(pRetVal->bstrVal, reinterpret_cast<WCHAR*>(valueBytes), chars); //pRetVal->bstrVal[chars] = L'\0'; pRetVal = (new System.Text.UnicodeEncoding()).GetString(valueBytes); } } } } } } } } } return(pRetVal); }
public static String GetURTName(IDebugField type) { String translated = null; FIELD_INFO fieldInfo; uint size = 0; String name = null; type.GetInfo(FIELD_INFO_FIELDS.FIF_NAME, out fieldInfo); name = fieldInfo.bstrName; type.GetSize(out size); if (0 <= size ){ switch(size){ case 0: if (0 == String.Compare("string", name, true)) translated = "System.String"; else if (0 == String.Compare("void", name, true)) translated = "System.Void"; break; case 1: if (0 == String.Compare("whole", name, true)) translated = "System.SByte"; else if (0 == String.Compare("uwhole", name, true)) translated = "System.Byte"; else if (0 == String.Compare("bool", name, true)) translated = "System.Boolean"; break; case 2: if (0 == String.Compare("whole", name, true)) translated = "System.Int16"; else if (0 == String.Compare("char", name, true)) translated = "System.Char"; else if (0 == String.Compare("uwhole", name, true)) translated = "System.UInt16"; else if (0 == String.Compare("bool", name, true)) translated = "System.Boolean"; break; case 4: if (0 == String.Compare("whole", name, true)) translated = "System.Int32"; else if (0 == String.Compare("uwhole", name, true)) translated = "System.UIn32"; else if (0 == String.Compare("real", name, true)) translated = "System.Float"; else if (0 == String.Compare("bool", name, true)) translated = "System.Boolean"; break; case 8: if (0 == String.Compare("whole", name, true)) translated = "System.Int64"; else if (0 == String.Compare("uwhole", name, true)) translated = "System.UInt64"; else if (0 == String.Compare("real", name, true)) translated = "System.Double"; break; } } return translated; }
public bool MoveNext() { bool pRetVal = false; if (null != this.m_Current) { this.m_Current = null; } else { // Skip the first element this.m_Fields.Skip(1); } IDebugField field = null; IDebugField[] fields = new IDebugField[1]; int fetched = 0; this.m_Fields.Next(1, fields, out fetched); if (null != fields[0]){ field = fields[0]; IDebugType type = null; type = SymbolHelper.DebugTypeFromField(field, this.m_Context); if (null != type) { this.m_Current = type; pRetVal = true; } } return pRetVal; }
public CDebugType(IDebugField field, IDebugContext context) { this.m_Field = field; this.m_Context = context; }
public bool MoveNext() { bool pRetVal = false; IDebugSymbol saveCurrent = this.m_Current; if (null != this.m_Current) { this.m_Current = null; } else { // Skip the first element this.m_Current = this.Current; this.m_Current = null; } if (this.m_IsEnumeratingClosureClass){ if (this.m_ClosureClassFields.MoveNext()){ this.m_Current = this.m_ClosureClassFields.Current; pRetVal = true; } else{ this.m_IsEnumeratingClosureClass = false; this.m_Current = saveCurrent; pRetVal = this.MoveNext(); } } else{ IDebugField field = null; int fetched = 0; IDebugField[] fields = new IDebugField[1]; this.m_Fields.Next(1, fields, out fetched); if (null != fields[0]){ field = fields[0]; IDebugSymbol symbol = null; symbol = SymbolHelper.SymbolFromDebugField(this.m_Context, field); if (null != symbol){ if (symbol.Name.StartsWith("SS$Closure Class Local")){ this.m_IsEnumeratingClosureClass = true; this.m_ClosureClassFields = new CEnumClosureClassSymbols(((IDebugFieldSymbol) symbol).GetValue(null), this.m_Context); this.m_Current = this.m_ClosureClassFields.Current; pRetVal = true; } else if (String.Compare(symbol.Name, "return value") == 0){ this.m_ReturnLocal = symbol; if (this.m_DisplayRetunLocal){ this.m_Current = symbol; pRetVal = true; } else{ this.m_Current = symbol; pRetVal = this.MoveNext(); } } else if (String.Compare(symbol.Name, "SS$Display Return Local") == 0){ if (this.m_ReturnLocal != null){ this.m_Current = this.m_ReturnLocal; pRetVal = true; } else{ this.m_DisplayRetunLocal = true; pRetVal = this.MoveNext(); } } else{ this.m_Current = symbol; pRetVal = true; } } } } return pRetVal; }
public bool MoveNext() { bool pRetVal = false; if (null != this.m_Current) { this.m_Current = null; } else { // Skip the first element this.m_Fields.Skip(1); } IDebugField field = null; int fetched = 0; IDebugField[] fields = new IDebugField[1]; this.m_Fields.Next(1, fields, out fetched); if (null != fields[0]){ field = fields[0]; IDebugSymbol symbol = null; symbol = SymbolHelper.SymbolFromDebugField(this.m_Context, field); if (null != symbol) { this.m_Current = symbol; pRetVal = true; } } return pRetVal; }
public static CDebugFieldSymbol Create(IDebugField field, IDebugContext context) { return new CDebugFieldSymbol(field, context); }
public CDebugFieldSymbol(IDebugField field, IDebugValue parent, IDebugContext context) : this(field, context){ this.m_Parent = parent; }
public CDebugFieldSymbol(IDebugField field, IDebugContext context) : base(field, context){ this.m_Parent = null; }
public CDebugValue(IDebugObject pObject, IDebugContext pContext){ this.m_Object = pObject; this.m_Context = pContext; this.m_RuntimeType = null; }
public CDebugPrimitiveType(IDebugField field, IDebugContext context) : base(field, context) { }
internal static IDebugSymbol SymbolFromDebugField(IDebugContext context, IDebugField field) { IDebugSymbol symbol = null; FIELD_KIND fieldKind; field.GetKind(out fieldKind); if (0 != (fieldKind & FIELD_KIND.FIELD_KIND_SYMBOL)) { if (0 != (fieldKind & FIELD_KIND.FIELD_TYPE_METHOD)) { IDebugMethodField methodField = null; methodField = field as IDebugMethodField; if (null != methodField){ CDebugMethodSymbol methodSymbol = null; methodSymbol = CDebugMethodSymbol.Create(methodField, context); if (null != methodSymbol) { symbol = methodSymbol; } } } else if (0 != (fieldKind & FIELD_KIND.FIELD_TYPE_PROP)) { IDebugPropertyField propertyField = null; propertyField = field as IDebugPropertyField; if (null != propertyField){ CDebugPropertySymbol propertySymbol = null; propertySymbol = CDebugPropertySymbol.Create(propertyField, context); if (null != propertySymbol) { symbol = propertySymbol; } } } else{ CDebugFieldSymbol fieldSymbol = null; fieldSymbol = CDebugFieldSymbol.Create(field, context); if (null != fieldSymbol) { symbol = fieldSymbol; } } } return symbol; }