/// <summary> /// Should be called each time the IL offset has been updated /// </summary> bool UpdateStackFrameLines(DecompilerTextView decompilerTextView, bool moveCaret = false) { Remove(decompilerTextView); bool movedCaret = false; var cm = decompilerTextView == null ? null : decompilerTextView.CodeMappings; bool updateReturnStatements = cm != null && DebugManager.Instance.ProcessState == DebuggerProcessState.Stopped; if (updateReturnStatements) { int frameNo = -1; bool tooManyFrames; foreach (var frame in GetFrames(MAX_STACKFRAME_LINES, out tooManyFrames)) { frameNo++; if (!frame.IsILFrame) { continue; } var ip = frame.ILFrameIP; if (!ip.IsExact && !ip.IsApproximate && !ip.IsProlog && !ip.IsEpilog) { continue; } uint token = frame.Token; if (token == 0) { continue; } var serAsm = frame.GetSerializedDnModuleWithAssembly(); if (serAsm == null) { continue; } StackFrameLineType type; if (frameNo == 0) { type = StackFrameLineType.CurrentStatement; } else { type = currentState.FrameNumber == frameNo ? StackFrameLineType.SelectedReturnStatement : StackFrameLineType.ReturnStatement; } var key = MethodKey.Create(token, serAsm.Value.Module); uint offset = frame.GetILOffset(); MethodDef methodDef; TextLocation location, endLocation; if (cm != null && cm.ContainsKey(key) && cm[key].GetInstructionByTokenAndOffset(offset, out methodDef, out location, out endLocation)) { var rs = new StackFrameLine(type, decompilerTextView, key, offset); stackFrameLines.Add(rs); TextLineObjectManager.Instance.Add(rs); if (moveCaret && frameNo == currentState.FrameNumber) { decompilerTextView.ScrollAndMoveCaretTo(location.Line, location.Column); movedCaret = true; } } } } return(movedCaret); }
/// <summary> /// Should be called each time the IL offset has been updated /// </summary> bool UpdateStackFrameLines(DecompilerTextView decompilerTextView, bool moveCaret = false) { Remove(decompilerTextView); bool movedCaret = false; var cm = decompilerTextView == null ? null : decompilerTextView.CodeMappings; bool updateReturnStatements = cm != null && DebugManager.Instance.ProcessState == DebuggerProcessState.Stopped; if (updateReturnStatements) { int frameNo = -1; bool tooManyFrames; foreach (var frame in GetFrames(MAX_STACKFRAME_LINES, out tooManyFrames)) { frameNo++; if (!frame.IsILFrame) continue; var ip = frame.ILFrameIP; if (!ip.IsExact && !ip.IsApproximate && !ip.IsProlog && !ip.IsEpilog) continue; uint token = frame.Token; if (token == 0) continue; var serAsm = frame.GetSerializedDnModuleWithAssembly(); if (serAsm == null) continue; StackFrameLineType type; if (frameNo == 0) type = StackFrameLineType.CurrentStatement; else type = currentState.FrameNumber == frameNo ? StackFrameLineType.SelectedReturnStatement : StackFrameLineType.ReturnStatement; var key = MethodKey.Create(token, serAsm.Value.Module); uint offset = frame.GetILOffset(); MethodDef methodDef; TextLocation location, endLocation; if (cm != null && cm.ContainsKey(key) && cm[key].GetInstructionByTokenAndOffset(offset, out methodDef, out location, out endLocation)) { var rs = new StackFrameLine(type, decompilerTextView, key, offset); stackFrameLines.Add(rs); TextLineObjectManager.Instance.Add(rs); if (moveCaret && frameNo == currentState.FrameNumber) { decompilerTextView.ScrollAndMoveCaretTo(location.Line, location.Column); movedCaret = true; } } } } return movedCaret; }
/// <summary> /// Should be called each time the IL offset has been updated /// </summary> bool UpdateStackFrameLines(ITextEditorUIContext uiContext, bool moveCaret = false) { if (uiContext == null) return false; Remove(uiContext); bool movedCaret = false; var cm = uiContext.TryGetCodeMappings(); bool updateReturnStatements = cm != null && theDebugger.ProcessState == DebuggerProcessState.Stopped; if (updateReturnStatements) { int frameNo = -1; bool tooManyFrames; foreach (var frame in GetFrames(MAX_STACKFRAME_LINES, out tooManyFrames)) { frameNo++; if (!frame.IsILFrame) continue; var ip = frame.ILFrameIP; if (!ip.IsExact && !ip.IsApproximate && !ip.IsProlog && !ip.IsEpilog) continue; uint token = frame.Token; if (token == 0) continue; var serAsm = frame.SerializedDnModule; if (serAsm == null) continue; StackFrameLineType type; if (frameNo == 0) type = StackFrameLineType.CurrentStatement; else type = currentState.FrameNumber == frameNo ? StackFrameLineType.SelectedReturnStatement : StackFrameLineType.ReturnStatement; var key = new SerializedDnToken(serAsm.Value, token); uint offset = frame.GetILOffset(moduleLoader.Value); MethodDef methodDef; TextPosition location, endLocation; var mm = cm.TryGetMapping(key); if (mm != null && mm.GetInstructionByTokenAndOffset(offset, out methodDef, out location, out endLocation)) { var rs = new StackFrameLine(type, uiContext, key, offset); stackFrameLines.Add(rs); textLineObjectManager.Add(rs); if (moveCaret && frameNo == currentState.FrameNumber) { uiContext.ScrollAndMoveCaretTo(location.Line, location.Column); movedCaret = true; } } } } return movedCaret; }
/// <summary> /// Should be called each time the IL offset has been updated /// </summary> bool UpdateStackFrameLines(ITextEditorUIContext uiContext, bool moveCaret = false) { if (uiContext == null) { return(false); } Remove(uiContext); bool movedCaret = false; var cm = uiContext.TryGetCodeMappings(); bool updateReturnStatements = cm != null && theDebugger.ProcessState == DebuggerProcessState.Paused; if (updateReturnStatements) { int frameNo = -1; bool tooManyFrames; foreach (var frame in GetFrames(MAX_STACKFRAME_LINES, out tooManyFrames)) { frameNo++; if (!frame.IsILFrame) { continue; } var ip = frame.ILFrameIP; if (!ip.IsExact && !ip.IsApproximate && !ip.IsProlog && !ip.IsEpilog) { continue; } uint token = frame.Token; if (token == 0) { continue; } var serAsm = frame.SerializedDnModule; if (serAsm == null) { continue; } StackFrameLineType type; if (frameNo == 0) { type = StackFrameLineType.CurrentStatement; } else { type = currentState.FrameNumber == frameNo ? StackFrameLineType.SelectedReturnStatement : StackFrameLineType.ReturnStatement; } var key = new SerializedDnToken(serAsm.Value, token); uint offset = frame.GetILOffset(moduleLoader.Value); MethodDef methodDef; TextPosition location, endLocation; var mm = cm.TryGetMapping(key); if (mm != null && mm.GetInstructionByTokenAndOffset(offset, out methodDef, out location, out endLocation)) { var rs = new StackFrameLine(type, uiContext, key, offset); stackFrameLines.Add(rs); textLineObjectManager.Add(rs); if (moveCaret && frameNo == currentState.FrameNumber) { uiContext.ScrollAndMoveCaretTo(location.Line, location.Column); movedCaret = true; } } } } return(movedCaret); }