/// <summary> /// Creates a JObject for an expression which raised an exception instead of returning a value. /// </summary> public JEvaluationResult(JProcess process, string exceptionText, string expression, JStackFrame frame) { _process = process; _expression = expression; _frame = frame; _exceptionText = exceptionText; }
/// <summary> /// Creates a JObject for an expression which successfully returned a value. /// </summary> public JEvaluationResult(JProcess process, string objRepr, string hexRepr, string typeName, string expression, string childText, bool childIsIndex, bool childIsEnumerate, JStackFrame frame, bool isExpandable) { _process = process; _expression = expression; _frame = frame; _objRepr = objRepr; _hexRepr = hexRepr; _typeName = typeName; _isExpandable = isExpandable; _childText = childText; _childIsIndex = childIsIndex; _childIsEnumerate = childIsEnumerate; }
internal void ExecuteText(string text, JStackFrame jStackFrame, Action<JEvaluationResult> completion) { int executeId = _ids.Allocate(); DebugWriteCommand("ExecuteText to thread " + jStackFrame.Thread.Id + " " + executeId); lock (_pendingExecutes) { _pendingExecutes[executeId] = new CompletionInfo(completion, text, jStackFrame); } lock (_socketLock) { _stream.Write(ExecuteTextCommandBytes); _stream.WriteString(text); _stream.WriteInt64(jStackFrame.Thread.Id); _stream.WriteInt32(jStackFrame.FrameId); _stream.WriteInt32(executeId); _stream.WriteInt32((int)jStackFrame.Kind); } }
internal bool SetLineNumber(JStackFrame jStackFrame, int lineNo) { if (_stoppedForException) { return false; } DebugWriteCommand("Set Line Number"); lock (_socketLock) { _setLineResult = false; _stream.Write(SetLineNumberCommand); _stream.WriteInt64(jStackFrame.Thread.Id); _stream.WriteInt32(jStackFrame.FrameId); _stream.WriteInt32(lineNo); } // wait up to 2 seconds for line event... for (int i = 0; i < 20 && _socket.Connected && WaitForSingleObject(_lineEvent.SafeWaitHandle, 100) != 0; i++) { } return _setLineResult; }
internal void EnumChildren(string text, JStackFrame jStackFrame, bool childIsEnumerate, Action<JEvaluationResult[]> completion) { DebugWriteCommand("Enum Children"); int executeId = _ids.Allocate(); lock (_pendingChildEnums) { _pendingChildEnums[executeId] = new ChildrenInfo(completion, text, jStackFrame); } lock (_socketLock) { _stream.Write(GetChildrenCommandBytes); _stream.WriteString(text); _stream.WriteInt64(jStackFrame.Thread.Id); _stream.WriteInt32(jStackFrame.FrameId); _stream.WriteInt32(executeId); _stream.WriteInt32((int)jStackFrame.Kind); _stream.WriteInt32(childIsEnumerate ? 1 : 0); } }
public CompletionInfo(Action<JEvaluationResult> completion, string text, JStackFrame frame) { Completion = completion; Text = text; Frame = frame; }
private JEvaluationResult ReadJObject(Stream stream, string text, string childText, bool childIsIndex, bool childIsEnumerate, JStackFrame frame) { string objRepr = stream.ReadString(); string hexRepr = stream.ReadString(); string typeName = stream.ReadString(); bool isExpandable = stream.ReadInt32() == 1; if ((typeName == "unicode" && LanguageVersion.Is6x()) || (typeName == "str" && LanguageVersion.Is7x())) { objRepr = objRepr.FixupEscapedUnicodeChars(); } return new JEvaluationResult(this, objRepr, hexRepr, typeName, text, childText, childIsIndex, childIsEnumerate, frame, isExpandable); }
private void HandleThreadFrameList(Stream stream) { // list of thread frames var frames = new List<JStackFrame>(); long tid = stream.ReadInt64(); JThread thread; _threads.TryGetValue(tid, out thread); var threadName = stream.ReadString(); int frameCount = stream.ReadInt32(); for (int i = 0; i < frameCount; i++) { int startLine = stream.ReadInt32(); int endLine = stream.ReadInt32(); int lineNo = stream.ReadInt32(); string frameName = stream.ReadString(); string filename = stream.ReadString(); int argCount = stream.ReadInt32(); var frameKind = (FrameKind)stream.ReadInt32(); JStackFrame frame = null; if (thread != null) { switch (frameKind) { case FrameKind.Django: string sourceFile = stream.ReadString(); var sourceLine = stream.ReadInt32(); frame = new DjangoStackFrame(thread, frameName, filename, startLine, endLine, lineNo, argCount, i, sourceFile, sourceLine); break; default: frame = new JStackFrame(thread, frameName, filename, startLine, endLine, lineNo, argCount, i, frameKind); break; } } int varCount = stream.ReadInt32(); JEvaluationResult[] variables = new JEvaluationResult[varCount]; for (int j = 0; j < variables.Length; j++) { string name = stream.ReadString(); if (frame != null) { variables[j] = ReadJObject(stream, name, "", false, false, frame); } } if (frame != null) { frame.SetVariables(variables); frames.Add(frame); } } Debug.WriteLine("Received frames for thread {0}", tid); if (thread != null) { thread.Frames = frames; if (threadName != null) { thread.Name = threadName; } } }
internal void SwitchFrame(JStackFrame frame) { _frameId = frame.FrameId; SetThreadAndFrameCommand(frame.Thread.Id, frame.FrameId, frame.Kind); Window.WriteLine(String.Format("Current frame changed to {0}", frame.FrameId)); }