public CorObjectValue GetObject() { ICorDebugObjectValue ov; m_boxVal.GetObject(out ov); return((ov == null) ? null : new CorObjectValue(ov)); }
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); }