string GetHitCondition(Mono.Debugging.Client.Breakpoint breakpoint) { if (breakpoint.HitCountMode == HitCountMode.None) { return(null); } return(conditions [breakpoint.HitCountMode] + breakpoint.HitCount); }
internal void Bind (PinnedWatch watch, Breakpoint be) { lock (watches) { if (be == null) { if (watch.BoundTracer != null) liveWatches.Remove (watch.BoundTracer); watch.LiveUpdate = false; } else { watch.BoundTracer = be; liveWatches [be] = watch; watch.LiveUpdate = true; } } }
public BreakpointPropertiesDialog (Breakpoint bp, bool isNew) { this.Build(); this.bp = bp; entryFile.Text = bp.FileName; entryLine.Text = bp.Line.ToString (); if (!isNew) { entryFile.IsEditable = false; entryLine.IsEditable = false; entryFile.ModifyBase (Gtk.StateType.Normal, Style.Backgrounds [(int)Gtk.StateType.Insensitive]); entryFile.ModifyBase (Gtk.StateType.Active, Style.Backgrounds [(int)Gtk.StateType.Insensitive]); entryLine.ModifyBase (Gtk.StateType.Normal, Style.Backgrounds [(int)Gtk.StateType.Insensitive]); entryLine.ModifyBase (Gtk.StateType.Active, Style.Backgrounds [(int)Gtk.StateType.Insensitive]); } if (string.IsNullOrEmpty (bp.ConditionExpression)) { radioBreakAlways.Active = true; } else { entryCondition.Text = bp.ConditionExpression; if (bp.BreakIfConditionChanges) radioBreakChange.Active = true; else radioBreakTrue.Active = true; } spinHitCount.Value = bp.HitCount; if (bp.HitAction == HitAction.Break) radioActionBreak.Active = true; else { radioActionTrace.Active = true; entryTraceExpr.Text = bp.TraceExpression; } Project project = IdeApp.Workspace.GetProjectContainingFile (bp.FileName); if (project != null) { // Check the startup project of the solution too, since the current project may be a library SolutionEntityItem startup = project.ParentSolution.StartupItem; boxConditionOptions.Sensitive = DebuggingService.IsFeatureSupported (project, DebuggerFeatures.ConditionalBreakpoints) || DebuggingService.IsFeatureSupported (startup, DebuggerFeatures.ConditionalBreakpoints); boxAction.Sensitive = DebuggingService.IsFeatureSupported (project, DebuggerFeatures.Tracepoints) || DebuggingService.IsFeatureSupported (startup, DebuggerFeatures.Tracepoints); } UpdateControls (); }
void SetInitialBreakpointData (Breakpoint bp) { stopOnFunction.Visible = false; hboxFunction.Visible = false; stopOnException.Visible = false; vboxException.Visible = false; stopOnLocation.Active = true; breakpointLocation.Update (bp); entryLocationFile.Text = breakpointLocation.ToString (); Project project = null; if (!string.IsNullOrEmpty (bp.FileName)) project = IdeApp.Workspace.GetProjectsContainingFile (bp.FileName).FirstOrDefault (); if (project != null) { // Check the startup project of the solution too, since the current project may be a library SolutionEntityItem startup = project.ParentSolution.StartupItem; entryConditionalExpression.Sensitive = DebuggingService.IsFeatureSupported (project, DebuggerFeatures.ConditionalBreakpoints) || DebuggingService.IsFeatureSupported (startup, DebuggerFeatures.ConditionalBreakpoints); bool canTrace = DebuggingService.IsFeatureSupported (project, DebuggerFeatures.Tracepoints) || DebuggingService.IsFeatureSupported (startup, DebuggerFeatures.Tracepoints); breakpointActionPause.Sensitive = canTrace; entryPrintExpression.Sensitive = canTrace; } }
public Breakpoint AddBreakpoint (string breakpointMarker, int offset = 0, string statement = null) { int col, line; GetLineAndColumn (breakpointMarker, offset, statement, out line, out col); var bp = new Breakpoint (SourceFile.Name, line, col); Session.Breakpoints.Add (bp); return bp; }
public static bool ShowBreakpointProperties (Breakpoint bp, bool editNew) { var dlg = new BreakpointPropertiesDialog (bp, editNew); if (MessageService.ShowCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) return true; return false; }
protected virtual void OnBreakpointBound (Breakpoint bp, BreakpointEventRequest request) { }
void AddBreakpoint (Breakpoint bp) { if (DebuggingService.PinnedWatches.IsWatcherBreakpoint (bp)) return; FilePath fp = Name; if (fp.FullPath == bp.FileName) { DocumentLine line = widget.TextEditor.Document.GetLine (bp.Line); var status = bp.GetStatus (DebuggingService.DebuggerSession); if (line == null) return; if (!bp.Enabled) { if (bp.HitAction == HitAction.Break) widget.TextEditor.Document.AddMarker (line, new DisabledBreakpointTextMarker (widget.TextEditor, false)); else widget.TextEditor.Document.AddMarker (line, new DisabledBreakpointTextMarker (widget.TextEditor, true)); } else if (status == BreakEventStatus.Bound || status == BreakEventStatus.Disconnected) { if (bp.HitAction == HitAction.Break) widget.TextEditor.Document.AddMarker (line, new BreakpointTextMarker (widget.TextEditor, false)); else widget.TextEditor.Document.AddMarker (line, new BreakpointTextMarker (widget.TextEditor, true)); } else widget.TextEditor.Document.AddMarker (line, new InvalidBreakpointTextMarker (widget.TextEditor)); widget.TextEditor.QueueDraw (); breakpointSegments.Add (line); } }
protected override void Run () { Breakpoint bp = new Breakpoint (IdeApp.Workbench.ActiveDocument.FileName, IdeApp.Workbench.ActiveDocument.Editor.Caret.Line, IdeApp.Workbench.ActiveDocument.Editor.Caret.Column); if (DebuggingService.ShowBreakpointProperties (bp, true)) DebuggingService.Breakpoints.Add (bp); }
void ResolvePendingBreakpoint (Breakpoint bp, Location l) { BreakInfo bi = GetBreakInfo (bp); if (bi != null) { bi.Location = l; InsertBreakpoint (bp, bi); SetBreakEventStatus (bp, true, null); } }
public bool IsWatcherBreakpoint (Breakpoint bp) { lock (watches) { return liveWatches.ContainsKey (bp); } }
public void Update (Breakpoint bp) { Update (bp.FileName, bp.Line, bp.Column); }
internal bool UpdateLiveWatch (Breakpoint bp, string trace) { lock (watches) { PinnedWatch w; if (!liveWatches.TryGetValue (bp, out w)) return false; w.UpdateFromTrace (trace); return true; } }
bool BreakEventCheck(MD.TargetEventArgs args) { MD.StackFrame frame = args.Frame; if (!(args.Data is int)) { return(true); } int eventHandle = (int)args.Data; DL.BreakEvent be; if (!events.TryGetValue(eventHandle, out be)) { return(true); } // Check hit count if (be.HitCount > 0) { be.HitCount--; DispatchEvent(delegate { NotifyBreakEventUpdate(eventHandle, be.HitCount, null); }); return(false); } MdbEvaluationContext ctx = new MdbEvaluationContext(frame.Thread, frame, null, SessionOptions.EvaluationOptions); DL.Breakpoint bp = be as DL.Breakpoint; if (bp != null && !string.IsNullOrEmpty(bp.ConditionExpression)) { ML.TargetObject val = EvaluateExp(ctx, bp.ConditionExpression); if (val == null) { return(false); } if (bp.BreakIfConditionChanges) { string current = evaluator.TargetObjectToExpression(ctx, val).Value; string last; bool found = lastConditionValue.TryGetValue(eventHandle, out last); lastConditionValue [eventHandle] = current; if (!found || last == current) { return(false); } } else { ML.TargetFundamentalObject fob = val as ML.TargetFundamentalObject; if (fob == null) { return(false); } object ob = fob.GetObject(frame.Thread); if (!(ob is bool) || !(bool)ob) { return(false); } } } switch (be.HitAction) { case HitAction.Break: return(true); case HitAction.CustomAction: return(controller.OnCustomBreakpointAction(be.CustomActionId, eventHandle)); case HitAction.PrintExpression: if (string.IsNullOrEmpty(be.TraceExpression) || frame == null) { return(false); } ML.TargetObject val = EvaluateExp(ctx, be.TraceExpression); if (val != null) { string str = evaluator.TargetObjectToString(ctx, val); DispatchEvent(delegate { NotifyBreakEventUpdate(eventHandle, -1, str); }); } return(false); } return(false); }
public int InsertBreakEvent(DL.BreakEvent be, bool enable) { CancelRuntimeInvokes(); DL.Breakpoint bp = be as DL.Breakpoint; MD.Event ev = null; if (bp != null) { MD.SourceLocation location = new MD.SourceLocation(bp.FileName, bp.Line); MD.SourceBreakpoint sbp = new MD.SourceBreakpoint(session, ThreadGroup.Global, location); mdbAdaptor.InitializeBreakpoint(sbp); session.AddEvent(sbp); ev = sbp; } else if (be is Catchpoint) { lock (pendingCatchpoints) { Catchpoint cp = (Catchpoint)be; ML.TargetType exc = null; if (process != null) { foreach (Module mod in process.Modules) { exc = mod.Language.LookupType(cp.ExceptionName); if (exc != null) { break; } } } if (exc != null) { ev = session.InsertExceptionCatchPoint(process.MainThread, ThreadGroup.Global, exc); } else { pendingCatchpoints.Add(cp); return(-1); } } } ev.IsEnabled = enable; if (!initializing) { lock (debugger) { mdbAdaptor.ActivateEvent(ev); } } if (bp != null && !running && !initializing && activeThread.CurrentFrame != null && !string.IsNullOrEmpty(bp.ConditionExpression) && bp.BreakIfConditionChanges) { // Initial expression evaluation MdbEvaluationContext ctx = new MdbEvaluationContext(activeThread, activeThread.CurrentFrame, null, SessionOptions.EvaluationOptions); ML.TargetObject ob = EvaluateExp(ctx, bp.ConditionExpression); if (ob != null) { lastConditionValue [ev.Index] = evaluator.TargetObjectToExpression(ctx, ob).Value; } } events [ev.Index] = be; return(ev.Index); }
public BreakpointEventArgs (Breakpoint bp) { this.bp = bp; }
void InsertBreakpoint (Breakpoint bp, BreakInfo bi) { bi.Req = vm.SetBreakpoint (bi.Location.Method, bi.Location.ILOffset); bi.Req.Enabled = bi.Enabled; breakpoints [bi.Req] = bi; }
void SaveBreakpoint (Breakpoint bp) { bp.SetColumn (breakpointLocation.Column); bp.SetLine (breakpointLocation.Line); }
void AddBreakpoint (Breakpoint bp) { if (DebuggingService.PinnedWatches.IsWatcherBreakpoint (bp)) return; var textEditor = widget.TextEditor; if (textEditor == null) return; var document = textEditor.Document; if (document == null) return; FilePath fp = Name; if (fp.FullPath == bp.FileName) { if (bp.Line <= 0 || bp.Line > textEditor.Document.LineCount) { LoggingService.LogWarning ("Invalid breakpoint :" + bp +" in line " + bp.Line); return; } DocumentLine line = document.GetLine (bp.Line); var status = bp.GetStatus (DebuggingService.DebuggerSession); bool tracepoint = (bp.HitAction & HitAction.Break) == HitAction.None; if (line == null) return; if (!bp.Enabled) { document.AddMarker (line, new DisabledBreakpointTextMarker (textEditor, tracepoint)); } else if (status == BreakEventStatus.Bound || status == BreakEventStatus.Disconnected) { document.AddMarker (line, new BreakpointTextMarker (textEditor, tracepoint)); } else { document.AddMarker (line, new InvalidBreakpointTextMarker (textEditor, tracepoint)); } textEditor.QueueDraw (); breakpointSegments.Add (line); } }
void AddBreakpoint (Breakpoint bp) { if (DebuggingService.PinnedWatches.IsWatcherBreakpoint (bp)) return; var textEditor = widget.TextEditor; if (textEditor == null) return; var document = textEditor.Document; if (document == null) return; FilePath fp = Name; if (fp.FullPath == bp.FileName) { if (bp.Line <= 0 || bp.Line > textEditor.Document.LineCount) { LoggingService.LogWarning ("Invalid breakpoint :" + bp + " in line " + bp.Line); return; } DocumentLine line = document.GetLine (bp.Line); var status = bp.GetStatus (DebuggingService.DebuggerSession); bool tracepoint = (bp.HitAction & HitAction.Break) == HitAction.None; if (line == null) return; //TODO: 1. When not in debug mode use Microsoft.CodeAnalysis.CSharp.EditAndContinue.BreakpointSpans.TryGetBreakpointSpan //TODO: 2. When in debug mode extend Breakpoint class to have endLine and endColumn set if .mdb/.pdb has endLine/endColumn var offset = line.Offset; var lenght = line.Length; DebugMarkerPair marker; if (!bp.Enabled) { marker = new DisabledBreakpointTextMarker (textEditor, offset, lenght, tracepoint); } else if (status == BreakEventStatus.Bound || status == BreakEventStatus.Disconnected) { marker = new BreakpointTextMarker (textEditor, offset, lenght, tracepoint); } else { marker = new InvalidBreakpointTextMarker (textEditor, offset, lenght, tracepoint); } textEditor.QueueDraw (); breakpointSegments.Add (marker); marker.AddTo (document, line); } }
void InsertBreakpoint (Breakpoint bp, BreakInfo bi) { bi.Req = vm.SetBreakpoint (bi.Location.Method, bi.Location.ILOffset); bi.Req.Enabled = bi.BreakEvent.Enabled; breakpoints [bi.Req] = bi; if (bi.Location.LineNumber != bp.Line) bi.AdjustBreakpointLocation (bi.Location.LineNumber); }
void InsertBreakpoint (Breakpoint bp, BreakInfo bi) { bi.Req = vm.SetBreakpoint (bi.Location.Method, bi.Location.ILOffset); bi.Req.Enabled = bi.Enabled; breakpoints [bi.Req] = bi; OnBreakpointBound (bp, (BreakpointEventRequest) bi.Req); }
internal void AdjustBreakpointLocation (Breakpoint b, int newLine) { lock (breakpoints) { try { adjustingBreakpoints = true; Breakpoints.AdjustBreakpointLine (b, newLine); } finally { adjustingBreakpoints = false; } } }
void InsertBreakpoint (Breakpoint bp, BreakInfo bi) { EventRequest request; request = vm.SetBreakpoint (bi.Location.Method, bi.Location.ILOffset); request.Enabled = bp.Enabled; bi.Requests.Add (request); breakpoints[request] = bi; if (bi.Location.LineNumber != bp.Line) bi.AdjustBreakpointLocation (bi.Location.LineNumber); }
public BreakpointPropertiesDialog (Breakpoint bp, bool isNew) { this.Build (); this.isNew = isNew; this.bp = bp; spinColumn.Adjustment.Upper = int.MaxValue; spinColumn.Adjustment.Lower = 1; spinLine.Adjustment.Upper = int.MaxValue; spinLine.Adjustment.Lower = 1; if (bp is FunctionBreakpoint) { FunctionBreakpoint fb = (FunctionBreakpoint) bp; labelFileFunction.LabelProp = GettextCatalog.GetString ("Function:"); if (fb.ParamTypes != null) { // FIXME: support non-C# syntax based on fb.Language entryFileFunction.Text = fb.FunctionName + " (" + string.Join (", ", fb.ParamTypes) + ")"; } else entryFileFunction.Text = fb.FunctionName; if (!isNew) { // We don't use ".Sensitive = false" because we want the user to be able to select & copy the text. entryFileFunction.ModifyBase (Gtk.StateType.Normal, Style.Backgrounds [(int)Gtk.StateType.Insensitive]); entryFileFunction.ModifyBase (Gtk.StateType.Active, Style.Backgrounds [(int)Gtk.StateType.Insensitive]); entryFileFunction.IsEditable = false; } // Function breakpoints only support breaking on the first line hboxLineColumn.Destroy (); labelLine.Destroy (); table1.NRows--; } else { labelFileFunction.LabelProp = GettextCatalog.GetString ("File:"); entryFileFunction.Text = ((Breakpoint) bp).FileName; // We don't use ".Sensitive = false" because we want the user to be able to select & copy the text. entryFileFunction.ModifyBase (Gtk.StateType.Normal, Style.Backgrounds [(int)Gtk.StateType.Insensitive]); entryFileFunction.ModifyBase (Gtk.StateType.Active, Style.Backgrounds [(int)Gtk.StateType.Insensitive]); entryFileFunction.IsEditable = false; spinColumn.Value = bp.Column; spinLine.Value = bp.Line; if (!isNew) { spinColumn.IsEditable = false; spinColumn.Sensitive = false; spinLine.IsEditable = false; spinLine.Sensitive = false; } } if (string.IsNullOrEmpty (bp.ConditionExpression)) { radioBreakAlways.Active = true; } else { entryCondition.Text = bp.ConditionExpression; if (bp.BreakIfConditionChanges) radioBreakChange.Active = true; else radioBreakTrue.Active = true; } spinHitCount.Value = bp.HitCount; if (bp.HitAction == HitAction.Break) radioActionBreak.Active = true; else { radioActionTrace.Active = true; entryTraceExpr.Text = bp.TraceExpression; } Project project = null; if (!string.IsNullOrEmpty (bp.FileName)) project = IdeApp.Workspace.GetProjectContainingFile (bp.FileName); if (project != null) { // Check the startup project of the solution too, since the current project may be a library SolutionEntityItem startup = project.ParentSolution.StartupItem; boxConditionOptions.Sensitive = DebuggingService.IsFeatureSupported (project, DebuggerFeatures.ConditionalBreakpoints) || DebuggingService.IsFeatureSupported (startup, DebuggerFeatures.ConditionalBreakpoints); boxAction.Sensitive = DebuggingService.IsFeatureSupported (project, DebuggerFeatures.Tracepoints) || DebuggingService.IsFeatureSupported (startup, DebuggerFeatures.Tracepoints); } UpdateControls (); }
public static void SetLiveUpdateMode (PinnedWatch watch, bool liveUpdate) { if (watch.LiveUpdate == liveUpdate) return; watch.LiveUpdate = liveUpdate; if (liveUpdate) { Breakpoint bp = new Breakpoint (watch.File, watch.Line); bp.TraceExpression = "{" + watch.Expression + "}"; bp.HitAction = HitAction.PrintExpression; breakpoints.Add (bp); pinnedWatches.Bind (watch, bp); } else { pinnedWatches.Bind (watch, null); breakpoints.Remove (watch.BoundTracer); } }
void AddBreakpoint (Breakpoint bp) { if (DebuggingService.PinnedWatches.IsWatcherBreakpoint (bp)) return; FilePath fp = Name; if (fp.FullPath == bp.FileName) { LineSegment line = widget.TextEditor.Document.GetLine (bp.Line-1); if (line == null) return; if (!bp.Enabled) { if (bp.HitAction == HitAction.Break) widget.TextEditor.Document.AddMarker (line, breakpointDisabledMarker); else widget.TextEditor.Document.AddMarker (line, tracepointDisabledMarker); } else if (bp.IsValid (DebuggingService.DebuggerSession)) { if (bp.HitAction == HitAction.Break) widget.TextEditor.Document.AddMarker (line, breakpointMarker); else widget.TextEditor.Document.AddMarker (line, tracepointMarker); } else widget.TextEditor.Document.AddMarker (line, breakpointInvalidMarker); widget.TextEditor.QueueDraw (); breakpointSegments.Add (line); } }
public static void ShowAddTracepointDialog (string file, int line) { AddTracePointDialog dlg = new AddTracePointDialog (); if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok && dlg.Text.Length > 0) { Breakpoint bp = new Breakpoint (file, line); bp.HitAction = HitAction.PrintExpression; bp.TraceExpression = dlg.Text; bp.ConditionExpression = dlg.Condition; Breakpoints.Add (bp); } dlg.Destroy (); }
public BreakpointEventArgs(Breakpoint bp) { Breakpoint = bp; }