Ejemplo n.º 1
0
		public static List<AbstractNode> GetDebugInfo(Process process, ICorDebugValue corValue)
		{
			List<AbstractNode> items = new List<AbstractNode>();
			
			if (corValue.Is<ICorDebugValue>()) {
				InfoNode info = new InfoNode("ICorDebugValue", "");
				info.AddChild("Address", corValue.Address.ToString("X8"));
				info.AddChild("Type", ((CorElementType)corValue.Type).ToString());
				info.AddChild("Size", corValue.Size.ToString());
				items.Add(info);
			}
			if (corValue.Is<ICorDebugValue2>()) {
				InfoNode info = new InfoNode("ICorDebugValue2", "");
				ICorDebugValue2 corValue2 = corValue.CastTo<ICorDebugValue2>();
				string fullname;
				try {
					fullname = DebugType.Create(process, corValue2.ExactType).FullName;
				} catch (DebuggerException e) {
					fullname = e.Message;
				}
				info.AddChild("ExactType", fullname);
				items.Add(info);
			}
			if (corValue.Is<ICorDebugGenericValue>()) {
				InfoNode info = new InfoNode("ICorDebugGenericValue", "");
				try {
					byte[] bytes = corValue.CastTo<ICorDebugGenericValue>().RawValue;
					for(int i = 0; i < bytes.Length; i += 8) {
						string val = "";
						for(int j = i; j < bytes.Length && j < i + 8; j++) {
							val += bytes[j].ToString("X2") + " ";
						}
						info.AddChild("Value" + i.ToString("X2"), val);
					}
				} catch (ArgumentException) {
					info.AddChild("Value", "N/A");
				}
				items.Add(info);
			}
			if (corValue.Is<ICorDebugReferenceValue>()) {
				InfoNode info = new InfoNode("ICorDebugReferenceValue", "");
				ICorDebugReferenceValue refValue = corValue.CastTo<ICorDebugReferenceValue>();
				info.AddChild("IsNull", (refValue.IsNull != 0).ToString());
				if (refValue.IsNull == 0) {
					info.AddChild("Value", refValue.Value.ToString("X8"));
					if (refValue.Dereference() != null) {
						info.AddChild("Dereference", "", GetDebugInfo(process, refValue.Dereference()));
					} else {
						info.AddChild("Dereference", "N/A");
					}
					
				}
				items.Add(info);
			}
			if (corValue.Is<ICorDebugHeapValue>()) {
				InfoNode info = new InfoNode("ICorDebugHeapValue", "");
				items.Add(info);
			}
			if (corValue.Is<ICorDebugHeapValue2>()) {
				InfoNode info = new InfoNode("ICorDebugHeapValue2", "");
				items.Add(info);
			}
			if (corValue.Is<ICorDebugObjectValue>()) {
				InfoNode info = new InfoNode("ICorDebugObjectValue", "");
				ICorDebugObjectValue objValue = corValue.CastTo<ICorDebugObjectValue>();
				info.AddChild("Class", objValue.Class.Token.ToString("X8"));
				info.AddChild("IsValueClass", (objValue.IsValueClass != 0).ToString());
				items.Add(info);
			}
			if (corValue.Is<ICorDebugObjectValue2>()) {
				InfoNode info = new InfoNode("ICorDebugObjectValue2", "");
				items.Add(info);
			}
			if (corValue.Is<ICorDebugBoxValue>()) {
				InfoNode info = new InfoNode("ICorDebugBoxValue", "");
				ICorDebugBoxValue boxValue = corValue.CastTo<ICorDebugBoxValue>();
				info.AddChild("Object", "", GetDebugInfo(process, boxValue.Object.CastTo<ICorDebugValue>()));
				items.Add(info);
			}
			if (corValue.Is<ICorDebugStringValue>()) {
				InfoNode info = new InfoNode("ICorDebugStringValue", "");
				ICorDebugStringValue stringValue = corValue.CastTo<ICorDebugStringValue>();
				info.AddChild("Length", stringValue.Length.ToString());
				info.AddChild("String", stringValue.String);
				items.Add(info);
			}
			if (corValue.Is<ICorDebugArrayValue>()) {
				InfoNode info = new InfoNode("ICorDebugArrayValue", "");
				info.AddChild("...", "...");
				items.Add(info);
			}
			if (corValue.Is<ICorDebugHandleValue>()) {
				InfoNode info = new InfoNode("ICorDebugHandleValue", "");
				ICorDebugHandleValue handleValue = corValue.CastTo<ICorDebugHandleValue>();
				info.AddChild("HandleType", handleValue.HandleType.ToString());
				items.Add(info);
			}
			
			return items;
		}
Ejemplo n.º 2
0
		public static List<TreeNode> GetDebugInfo(AppDomain appDomain, ICorDebugValue corValue)
		{
			List<TreeNode> items = new List<TreeNode>();
			
			if (corValue is ICorDebugValue) {
				InfoNode info = new InfoNode("ICorDebugValue", "");
				info.AddChild("Address", corValue.GetAddress().ToString("X8"));
				info.AddChild("Type", ((CorElementType)corValue.GetTheType()).ToString());
				info.AddChild("Size", corValue.GetSize().ToString());
				items.Add(info);
			}
			if (corValue is ICorDebugValue2) {
				InfoNode info = new InfoNode("ICorDebugValue2", "");
				ICorDebugValue2 corValue2 = (ICorDebugValue2)corValue;
				string fullname;
				try {
					fullname = DebugType.CreateFromCorType(appDomain, corValue2.GetExactType()).FullName;
				} catch (DebuggerException e) {
					fullname = e.Message;
				}
				info.AddChild("ExactType", fullname);
				items.Add(info);
			}
			if (corValue is ICorDebugGenericValue) {
				InfoNode info = new InfoNode("ICorDebugGenericValue", "");
				try {
					byte[] bytes = ((ICorDebugGenericValue)corValue).GetRawValue();
					for(int i = 0; i < bytes.Length; i += 8) {
						string val = "";
						for(int j = i; j < bytes.Length && j < i + 8; j++) {
							val += bytes[j].ToString("X2") + " ";
						}
						info.AddChild("Value" + i.ToString("X2"), val);
					}
				} catch (System.ArgumentException) {
					info.AddChild("Value", "N/A");
				}
				items.Add(info);
			}
			if (corValue is ICorDebugReferenceValue) {
				InfoNode info = new InfoNode("ICorDebugReferenceValue", "");
				ICorDebugReferenceValue refValue = (ICorDebugReferenceValue)corValue;
				info.AddChild("IsNull", (refValue.IsNull() != 0).ToString());
				if (refValue.IsNull() == 0) {
					info.AddChild("Value", refValue.GetValue().ToString("X8"));
					if (refValue.Dereference() != null) {
						info.AddChild("Dereference", "", GetDebugInfo(appDomain, refValue.Dereference()));
					} else {
						info.AddChild("Dereference", "N/A");
					}
				}
				items.Add(info);
			}
			if (corValue is ICorDebugHeapValue) {
				InfoNode info = new InfoNode("ICorDebugHeapValue", "");
				items.Add(info);
			}
			if (corValue is ICorDebugHeapValue2) {
				InfoNode info = new InfoNode("ICorDebugHeapValue2", "");
				items.Add(info);
			}
			if (corValue is ICorDebugObjectValue) {
				InfoNode info = new InfoNode("ICorDebugObjectValue", "");
				ICorDebugObjectValue objValue = (ICorDebugObjectValue)corValue;
				info.AddChild("Class", objValue.GetClass().GetToken().ToString("X8"));
				info.AddChild("IsValueClass", (objValue.IsValueClass() != 0).ToString());
				items.Add(info);
			}
			if (corValue is ICorDebugObjectValue2) {
				InfoNode info = new InfoNode("ICorDebugObjectValue2", "");
				items.Add(info);
			}
			if (corValue is ICorDebugBoxValue) {
				InfoNode info = new InfoNode("ICorDebugBoxValue", "");
				ICorDebugBoxValue boxValue = (ICorDebugBoxValue)corValue;
				info.AddChild("Object", "", GetDebugInfo(appDomain, boxValue.GetObject()));
				items.Add(info);
			}
			if (corValue is ICorDebugStringValue) {
				InfoNode info = new InfoNode("ICorDebugStringValue", "");
				ICorDebugStringValue stringValue = (ICorDebugStringValue)corValue;
				info.AddChild("Length", stringValue.GetLength().ToString());
				info.AddChild("String", stringValue.GetString());
				items.Add(info);
			}
			if (corValue is ICorDebugArrayValue) {
				InfoNode info = new InfoNode("ICorDebugArrayValue", "");
				info.AddChild("...", "...");
				items.Add(info);
			}
			if (corValue is ICorDebugHandleValue) {
				InfoNode info = new InfoNode("ICorDebugHandleValue", "");
				ICorDebugHandleValue handleValue = (ICorDebugHandleValue)corValue;
				info.AddChild("HandleType", handleValue.GetHandleType().ToString());
				items.Add(info);
			}
			
			return items;
		}
Ejemplo n.º 3
0
        public static List <TreeNode> GetDebugInfo(TreeNode parent, AppDomain appDomain, ICorDebugValue corValue)
        {
            List <TreeNode> items = new List <TreeNode>();

            if (corValue is ICorDebugValue)
            {
                InfoNode info = new InfoNode(parent, "ICorDebugValue", "");
                info.AddChild("Address", corValue.GetAddress().ToString("X8"));
                info.AddChild("Type", ((CorElementType)corValue.GetTheType()).ToString());
                info.AddChild("Size", corValue.GetSize().ToString());
                items.Add(info);
            }
            if (corValue is ICorDebugValue2)
            {
                InfoNode        info      = new InfoNode(parent, "ICorDebugValue2", "");
                ICorDebugValue2 corValue2 = (ICorDebugValue2)corValue;
                string          fullname;
                try {
                    fullname = DebugType.CreateFromCorType(appDomain, corValue2.GetExactType()).FullName;
                } catch (DebuggerException e) {
                    fullname = e.Message;
                }
                info.AddChild("ExactType", fullname);
                items.Add(info);
            }
            if (corValue is ICorDebugGenericValue)
            {
                InfoNode info = new InfoNode(parent, "ICorDebugGenericValue", "");
                try {
                    byte[] bytes = ((ICorDebugGenericValue)corValue).GetRawValue();
                    for (int i = 0; i < bytes.Length; i += 8)
                    {
                        string val = "";
                        for (int j = i; j < bytes.Length && j < i + 8; j++)
                        {
                            val += bytes[j].ToString("X2") + " ";
                        }
                        info.AddChild("Value" + i.ToString("X2"), val);
                    }
                } catch (ArgumentException) {
                    info.AddChild("Value", "N/A");
                }
                items.Add(info);
            }
            if (corValue is ICorDebugReferenceValue)
            {
                InfoNode info = new InfoNode(parent, "ICorDebugReferenceValue", "");
                ICorDebugReferenceValue refValue = (ICorDebugReferenceValue)corValue;
                info.AddChild("IsNull", (refValue.IsNull() != 0).ToString());
                if (refValue.IsNull() == 0)
                {
                    info.AddChild("Value", refValue.GetValue().ToString("X8"));
                    if (refValue.Dereference() != null)
                    {
                        info.AddChild("Dereference", "", p => GetDebugInfo(p, appDomain, refValue.Dereference()));
                    }
                    else
                    {
                        info.AddChild("Dereference", "N/A");
                    }
                }
                items.Add(info);
            }
            if (corValue is ICorDebugHeapValue)
            {
                InfoNode info = new InfoNode(parent, "ICorDebugHeapValue", "");
                items.Add(info);
            }
            if (corValue is ICorDebugHeapValue2)
            {
                InfoNode info = new InfoNode(parent, "ICorDebugHeapValue2", "");
                items.Add(info);
            }
            if (corValue is ICorDebugObjectValue)
            {
                InfoNode             info     = new InfoNode(parent, "ICorDebugObjectValue", "");
                ICorDebugObjectValue objValue = (ICorDebugObjectValue)corValue;
                info.AddChild("Class", objValue.GetClass().GetToken().ToString("X8"));
                info.AddChild("IsValueClass", (objValue.IsValueClass() != 0).ToString());
                items.Add(info);
            }
            if (corValue is ICorDebugObjectValue2)
            {
                InfoNode info = new InfoNode(parent, "ICorDebugObjectValue2", "");
                items.Add(info);
            }
            if (corValue is ICorDebugBoxValue)
            {
                InfoNode          info     = new InfoNode(parent, "ICorDebugBoxValue", "");
                ICorDebugBoxValue boxValue = (ICorDebugBoxValue)corValue;
                info.AddChild("Object", "", p => GetDebugInfo(p, appDomain, boxValue.GetObject()));
                items.Add(info);
            }
            if (corValue is ICorDebugStringValue)
            {
                InfoNode             info        = new InfoNode(parent, "ICorDebugStringValue", "");
                ICorDebugStringValue stringValue = (ICorDebugStringValue)corValue;
                info.AddChild("Length", stringValue.GetLength().ToString());
                info.AddChild("String", stringValue.GetString());
                items.Add(info);
            }
            if (corValue is ICorDebugArrayValue)
            {
                InfoNode info = new InfoNode(parent, "ICorDebugArrayValue", "");
                info.AddChild("...", "...");
                items.Add(info);
            }
            if (corValue is ICorDebugHandleValue)
            {
                InfoNode             info        = new InfoNode(parent, "ICorDebugHandleValue", "");
                ICorDebugHandleValue handleValue = (ICorDebugHandleValue)corValue;
                info.AddChild("HandleType", handleValue.GetHandleType().ToString());
                items.Add(info);
            }

            return(items);
        }
Ejemplo n.º 4
0
        public static List <AbstractNode> GetDebugInfo(Process process, ICorDebugValue corValue)
        {
            List <AbstractNode> items = new List <AbstractNode>();

            if (corValue.Is <ICorDebugValue>())
            {
                InfoNode info = new InfoNode("ICorDebugValue", "");
                info.AddChild("Address", corValue.Address.ToString("X8"));
                info.AddChild("Type", ((CorElementType)corValue.Type).ToString());
                info.AddChild("Size", corValue.Size.ToString());
                items.Add(info);
            }
            if (corValue.Is <ICorDebugValue2>())
            {
                InfoNode        info      = new InfoNode("ICorDebugValue2", "");
                ICorDebugValue2 corValue2 = corValue.CastTo <ICorDebugValue2>();
                string          fullname;
                try {
                    fullname = DebugType.Create(process, corValue2.ExactType).FullName;
                } catch (DebuggerException e) {
                    fullname = e.Message;
                }
                info.AddChild("ExactType", fullname);
                items.Add(info);
            }
            if (corValue.Is <ICorDebugGenericValue>())
            {
                InfoNode info = new InfoNode("ICorDebugGenericValue", "");
                try {
                    byte[] bytes = corValue.CastTo <ICorDebugGenericValue>().RawValue;
                    for (int i = 0; i < bytes.Length; i += 8)
                    {
                        string val = "";
                        for (int j = i; j < bytes.Length && j < i + 8; j++)
                        {
                            val += bytes[j].ToString("X2") + " ";
                        }
                        info.AddChild("Value" + i.ToString("X2"), val);
                    }
                } catch (ArgumentException) {
                    info.AddChild("Value", "N/A");
                }
                items.Add(info);
            }
            if (corValue.Is <ICorDebugReferenceValue>())
            {
                InfoNode info = new InfoNode("ICorDebugReferenceValue", "");
                ICorDebugReferenceValue refValue = corValue.CastTo <ICorDebugReferenceValue>();
                info.AddChild("IsNull", (refValue.IsNull != 0).ToString());
                if (refValue.IsNull == 0)
                {
                    info.AddChild("Value", refValue.Value.ToString("X8"));
                    if (refValue.Dereference() != null)
                    {
                        info.AddChild("Dereference", "", GetDebugInfo(process, refValue.Dereference()));
                    }
                    else
                    {
                        info.AddChild("Dereference", "N/A");
                    }
                }
                items.Add(info);
            }
            if (corValue.Is <ICorDebugHeapValue>())
            {
                InfoNode info = new InfoNode("ICorDebugHeapValue", "");
                items.Add(info);
            }
            if (corValue.Is <ICorDebugHeapValue2>())
            {
                InfoNode info = new InfoNode("ICorDebugHeapValue2", "");
                items.Add(info);
            }
            if (corValue.Is <ICorDebugObjectValue>())
            {
                InfoNode             info     = new InfoNode("ICorDebugObjectValue", "");
                ICorDebugObjectValue objValue = corValue.CastTo <ICorDebugObjectValue>();
                info.AddChild("Class", objValue.Class.Token.ToString("X8"));
                info.AddChild("IsValueClass", (objValue.IsValueClass != 0).ToString());
                items.Add(info);
            }
            if (corValue.Is <ICorDebugObjectValue2>())
            {
                InfoNode info = new InfoNode("ICorDebugObjectValue2", "");
                items.Add(info);
            }
            if (corValue.Is <ICorDebugBoxValue>())
            {
                InfoNode          info     = new InfoNode("ICorDebugBoxValue", "");
                ICorDebugBoxValue boxValue = corValue.CastTo <ICorDebugBoxValue>();
                info.AddChild("Object", "", GetDebugInfo(process, boxValue.Object.CastTo <ICorDebugValue>()));
                items.Add(info);
            }
            if (corValue.Is <ICorDebugStringValue>())
            {
                InfoNode             info        = new InfoNode("ICorDebugStringValue", "");
                ICorDebugStringValue stringValue = corValue.CastTo <ICorDebugStringValue>();
                info.AddChild("Length", stringValue.Length.ToString());
                info.AddChild("String", stringValue.String);
                items.Add(info);
            }
            if (corValue.Is <ICorDebugArrayValue>())
            {
                InfoNode info = new InfoNode("ICorDebugArrayValue", "");
                info.AddChild("...", "...");
                items.Add(info);
            }
            if (corValue.Is <ICorDebugHandleValue>())
            {
                InfoNode             info        = new InfoNode("ICorDebugHandleValue", "");
                ICorDebugHandleValue handleValue = corValue.CastTo <ICorDebugHandleValue>();
                info.AddChild("HandleType", handleValue.HandleType.ToString());
                items.Add(info);
            }

            return(items);
        }