public StackFrame(EnvDTE.StackFrame frame) : this() { EnvDTE90a.StackFrame2 frame2 = null; try { frame2 = (EnvDTE90a.StackFrame2)frame; this.LineNumber = (int)frame2.LineNumber; this.FileName = frame2.FileName; } catch (Exception) { this.LineNumber = 0; this.FileName = ""; } this.FunctionName = frame.FunctionName; this.Module = frame.Module; this.Language = frame.Language; this.ReturnType = frame.ReturnType; foreach (Expression local in frame.Locals) { StackFrameVariable var = new StackFrameVariable() { Name = local.Name, Value = local.Value }; this.Variables.Add(var); } }
private string FunctionName(StackFrame stackFrame) { return(MeasureTime(() => { ThreadHelper.ThrowIfNotOnUIThread(); return stackFrame.FunctionName; }, ref _timeSpanFunctionName, ref _numberOfFunctionNameCalls)); }
string ConvertCallStackEntryToModule(AutomationElement selectedRow, AutomationElement callStackWindowView) { _taskContext.ThrowIfNotOnMainThread(); string rowText = selectedRow.Current.Name; // Call stack window may display the module name in a format module_name!fun_info. if (rowText.Contains("!")) { string moduleName = rowText.Substring(0, rowText.IndexOf('!')); if (ModuleExists(moduleName)) { return(moduleName); } } // When the call stack window doesn't show the module name, we will try to match // the selected row index with the i-th frame returned by DTE service. AutomationElementCollection framesRows = GetAllDescendants(callStackWindowView, _treeGridItem); int selectedFrameIndex = 0; foreach (AutomationElement frameRow in framesRows) { selectedFrameIndex++; if (frameRow == selectedRow) { break; } } // First index is 1 for frames. StackFrames frames = GetDte().Debugger.CurrentThread.StackFrames; if (selectedFrameIndex <= 0 || selectedFrameIndex > frames.Count) { throw new InvalidOperationException( "Cannot match selected row with a stack frame from DTE."); } StackFrame frame = frames.Item(selectedFrameIndex); if (!rowText.Contains(frame.FunctionName)) { throw new InvalidOperationException( "The function name of the selected call stack frame doesn't match the " + "entry in DTE."); } return(frame.Module); }
void DisableNoSourceWindow(Process newProcess, Program newProgram, Thread newThread, StackFrame newStackFrame) { RecordErrors(() => { _taskContext.ThrowIfNotOnMainThread(); if (newStackFrame != null) { Properties debuggingProperties = GetDte().Properties["Debugging", "General"]; debuggingProperties.Item(_enableAddressLevelDebugging).Value = true; debuggingProperties.Item(_showDisassembly).Value = true; } }); }
private void SetStackFrame(StackFrame stackFrame) { ThreadHelper.ThrowIfNotOnUIThread(); try { MeasureTime(() => { ThreadHelper.ThrowIfNotOnUIThread(); _debugger.CurrentStackFrame = stackFrame; return(0); }, ref _timeSpanSetStackFrame, ref _numberOfSetStackFrameCalls); } catch (Exception) { Debug.WriteLine("Caught exception"); } }
private string Substitute(string template, Identifier identifier, StackFrame stackFrame) { ThreadHelper.ThrowIfNotOnUIThread(); var result = Regex.Replace(template, @"__ARG([0-9]*)__", delegate(Match match) { ThreadHelper.ThrowIfNotOnUIThread(); string v = match.ToString(); if (!Int32.TryParse(v.Substring(5, v.Length - 7), out var index)) { return(v); } //TODO measure time var args = stackFrame.Arguments; if (args.Count < index) { _buffer.AppendLine($"{v}: argument is out of bounds"); return(v); } var expr = args.Item(index); var exprResult = new GetExpressionResult { IsValid = expr.IsValidValue, Value = expr.Value }; if (!exprResult.IsValid) { _buffer.Append($"Argument {v} is invalid:\n {exprResult.Value}\n"); } return(exprResult.Value); }); if (result.IndexOf("__CURRENT_FUNCTION__", StringComparison.Ordinal) != -1) { result = result.Replace("__CURRENT_FUNCTION__", FunctionName(stackFrame)); } return(identifier.Substitute(result)); }
private void Update(Process newprocess, Program newprogram, Thread newthread, StackFrame newstackframe) { if (_drawingMode == DrawingMode.Canceled || _drawingMode == DrawingMode.Redrawing) { return; } if (newstackframe == null) { _drawingMode = DrawingMode.NotChanged; _form?.Hide(); return; } _dispatcherTimer = new DispatcherTimer(); _dispatcherTimer.Tick += DispatcherTimer_Tick; _dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 50); _dispatcherTimer.Start(); _drawingMode = DrawingMode.ShouldBeRedrawn; }
//DebuggerEvents public void OnContextChanged(EnvDTE.Process NewProcess, EnvDTE.Program NewProgram, EnvDTE.Thread NewThread, EnvDTE.StackFrame NewStackFrame) { _outputWindowPane.OutputString("DebuggerEvents, OnContextChanged\n"); }
public void OnContextChanged(EnvDTE.Process NewProcess, Program NewProgram, Thread NewThread, EnvDTE.StackFrame NewStackFrame) { //CommandCustomWatch.Instance.MenuEnabled = false; System.Windows.Forms.MessageBox.Show("Events are attached."); }