// 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); }
private void ChildTest(string filename, int lineNo, string text, params ChildInfo[] children) { var debugger = new PythonDebugger(); PythonThread thread = null; var process = DebugProcess(debugger, DebuggerTestPath + filename, (newproc, newthread) => { var breakPoint = newproc.AddBreakPoint(filename, lineNo); breakPoint.Add(); thread = newthread; }); AutoResetEvent brkHit = new AutoResetEvent(false); process.BreakpointHit += (sender, args) => { brkHit.Set(); }; process.ExceptionRaised += (sender, args) => { // some versions of Python raise exceptions during startup args.Thread.Resume(); }; process.Start(); brkHit.WaitOne(); var frames = thread.GetFrames(); AutoResetEvent evalComplete = new AutoResetEvent(false); PythonEvaluationResult evalRes = null; frames[0].ExecuteText(text, (completion) => { evalRes = completion; evalComplete.Set(); }); evalComplete.WaitOne(); Assert.IsTrue(evalRes != null); if (children == null) { Assert.IsTrue(!evalRes.IsExpandable); Assert.IsTrue(evalRes.GetChildren(Int32.MaxValue) == null); } else { Assert.IsTrue(evalRes.IsExpandable); var childrenReceived = new List <PythonEvaluationResult>(evalRes.GetChildren(Int32.MaxValue)); Assert.IsTrue(children.Length == childrenReceived.Count); for (int i = 0; i < children.Length; i++) { bool foundChild = false; for (int j = 0; j < childrenReceived.Count; j++) { if (childrenReceived[j].ChildText == children[i].ChildText && childrenReceived[j].StringRepr == children[i].Repr) { foundChild = true; if (children[i].ChildText.StartsWith("[")) { Assert.AreEqual(childrenReceived[j].Expression, text + children[i].ChildText); } else { Assert.AreEqual(childrenReceived[j].Expression, text + "." + children[i].ChildText); } Assert.AreEqual(childrenReceived[j].Frame, frames[0]); childrenReceived.RemoveAt(j); break; } } Assert.IsTrue(foundChild); } Assert.IsTrue(childrenReceived.Count == 0); } process.Continue(); process.WaitForExit(); }