/// <summary> /// Should be called each time the IL offset has been updated /// </summary> static bool UpdateReturnStatementBookmarks(DecompilerTextView decompilerTextView, bool moveCaret = false) { Remove(decompilerTextView); bool movedCaret = false; var cm = decompilerTextView == null ? null : decompilerTextView.CodeMappings; bool updateReturnStatements = cm != null && DebuggerService.CurrentDebugger != null && DebuggerService.CurrentDebugger.IsDebugging && !DebuggerService.CurrentDebugger.IsProcessRunning; if (updateReturnStatements) { int frameNo = -1; foreach (var frame in DebuggerService.CurrentDebugger.GetStackFrames(100)) { frameNo++; StackFrameStatementType type; if (frameNo == 0) { type = StackFrameStatementType.CurrentStatement; } else { type = selectedFrame == frameNo ? StackFrameStatementType.SelectedReturnStatement : StackFrameStatementType.ReturnStatement; } if (frame.ILOffset == null) { continue; } var key = frame.MethodKey; int offset = frame.ILOffset.Value; MethodDef methodDef; ICSharpCode.NRefactory.TextLocation location, endLocation; if (cm != null && cm.ContainsKey(key) && cm[key].GetInstructionByTokenAndOffset((uint)offset, out methodDef, out location, out endLocation)) { var rs = new StackFrameStatementBookmark(decompilerTextView, methodDef, location, endLocation, type, (uint)offset); returnStatementBookmarks.Add(rs); BookmarkManager.AddMark(rs); if (moveCaret && frameNo == selectedFrame) { decompilerTextView.ScrollAndMoveCaretTo(location.Line, location.Column); movedCaret = true; } } } } return(movedCaret); }
/// <summary> /// Should be called each time the IL offset has been updated /// </summary> static bool UpdateReturnStatementBookmarks(DecompilerTextView decompilerTextView, bool moveCaret = false) { Remove(decompilerTextView); bool movedCaret = false; var cm = decompilerTextView == null ? null : decompilerTextView.CodeMappings; bool updateReturnStatements = cm != null && DebuggerService.CurrentDebugger != null && DebuggerService.CurrentDebugger.IsDebugging && !DebuggerService.CurrentDebugger.IsProcessRunning; if (updateReturnStatements) { int frameNo = -1; foreach (var frame in DebuggerService.CurrentDebugger.GetStackFrames(100)) { frameNo++; StackFrameStatementType type; if (frameNo == 0) type = StackFrameStatementType.CurrentStatement; else type = selectedFrame == frameNo ? StackFrameStatementType.SelectedReturnStatement : StackFrameStatementType.ReturnStatement; if (frame.ILOffset == null) continue; var key = frame.MethodKey; int offset = frame.ILOffset.Value; MethodDef methodDef; ICSharpCode.NRefactory.TextLocation location, endLocation; if (cm != null && cm.ContainsKey(key) && cm[key].GetInstructionByTokenAndOffset((uint)offset, out methodDef, out location, out endLocation)) { var rs = new StackFrameStatementBookmark(decompilerTextView, methodDef, location, endLocation, type, (uint)offset); returnStatementBookmarks.Add(rs); BookmarkManager.AddMark(rs); if (moveCaret && frameNo == selectedFrame) { decompilerTextView.ScrollAndMoveCaretTo(location.Line, location.Column); movedCaret = true; } } } } return movedCaret; }