public static BreakpointKind GetBreakpointKind(DbgCodeBreakpoint breakpoint) { var settings = breakpoint.Settings; bool isAdvanced = !(settings.Condition is null) || !(settings.HitCount is null) || !(settings.Filter is null); var msg = breakpoint.BoundBreakpointsMessage; if (settings.Trace is null || !settings.Trace.Value.Continue) { switch (msg.Severity) { case DbgBoundCodeBreakpointSeverity.None: break; case DbgBoundCodeBreakpointSeverity.Warning: return(isAdvanced ? BreakpointKind.AdvancedBreakpointWarning : BreakpointKind.BreakpointWarning); case DbgBoundCodeBreakpointSeverity.Error: return(isAdvanced ? BreakpointKind.AdvancedBreakpointError : BreakpointKind.BreakpointError); default: Debug.Fail($"Unknown severity: {msg.Severity}"); break; } if (isAdvanced) { return(settings.IsEnabled ? BreakpointKind.AdvancedBreakpointEnabled : BreakpointKind.AdvancedBreakpointDisabled); } return(settings.IsEnabled ? BreakpointKind.BreakpointEnabled : BreakpointKind.BreakpointDisabled); }
public override GlyphTextMarkerLocationInfo GetLocation(DbgCodeBreakpoint breakpoint) { if (breakpoint.Location is DbgDotNetCodeLocation loc) { return(new DotNetMethodBodyGlyphTextMarkerLocationInfo(loc.Module, loc.Token, loc.Offset)); } return(null); }
public override int?GetHitCount(DbgCodeBreakpoint breakpoint) { if (breakpoint is null) { throw new ArgumentNullException(nameof(breakpoint)); } lock (lockObj) return(GetHitCount_NoLock_DbgThread(breakpoint)); }
public DbgBoundCodeBreakpointImpl(DbgRuntimeImpl runtime, DbgCodeBreakpoint breakpoint, DbgModule?module, ulong address, DbgBoundCodeBreakpointMessage message) { lockObj = new object(); this.runtime = runtime ?? throw new ArgumentNullException(nameof(runtime)); this.breakpoint = breakpoint ?? throw new ArgumentNullException(nameof(breakpoint)); this.module = module; this.address = address; this.message = message; }
int?GetHitCount_NoLock_DbgThread(DbgCodeBreakpoint breakpoint) { if (dbgManager?.IsDebugging != true) { return(null); } if (bpToHitCount.TryGetValue(breakpoint, out var hitCount)) { return(hitCount); } return(0); }
void WriteLocation(ITextColorWriter output, DbgCodeBreakpoint breakpoint, ITextView textView, SnapshotSpan span) { foreach (var lz in dbgBreakpointGlyphFormatters) { if (lz.Value.WriteLocation(output, breakpoint, textView, span)) { return; } } Debug.Fail("Missing BP location writer"); output.Write(BoxedTextColor.Error, "???"); }
public override GlyphTextMarkerLocationInfo GetLocation(DbgCodeBreakpoint breakpoint) { if (breakpoint == null) { throw new ArgumentNullException(nameof(breakpoint)); } foreach (var lz in dbgBreakpointGlyphTextMarkerLocationProviders) { var loc = lz.Value.GetLocation(breakpoint); if (loc != null) { return(loc); } } return(null); }
public override int Hit_DbgThread(DbgCodeBreakpoint breakpoint) { dbgDispatcherProvider.VerifyAccess(); if (breakpoint == null) { throw new ArgumentNullException(nameof(breakpoint)); } int hitCount; lock (lockObj) { if (!bpToHitCount.TryGetValue(breakpoint, out hitCount)) { hitCount = 0; } hitCount++; bpToHitCount[breakpoint] = hitCount; } bool start; lock (lockObj) { start = dbgManager.IsRunning == false || pendingHitCountChanged.Count == 0; pendingHitCountChanged.Add(breakpoint); if (start) { StopPendingHitCountChangedTimer_NoLock(); if (dbgManager.IsRunning == false) { Dbg(() => FlushPendingHitCountChanged_DbgThread()); } else { pendingHitCountChangedTimer = new Timer(HITCOUNT_CHANGED_DELAY_MS); pendingHitCountChangedTimer.Elapsed += PendingHitCountChangedTimer_Elapsed; pendingHitCountChangedTimer.Start(); } } } return(hitCount); }
public override GlyphTextMarkerLocationInfo?GetLocation(DbgCodeBreakpoint breakpoint) { if (breakpoint.Location is DbgDotNetCodeLocation loc) { switch (loc.ILOffsetMapping) { case DbgILOffsetMapping.Exact: case DbgILOffsetMapping.Approximate: return(new DotNetMethodBodyGlyphTextMarkerLocationInfo(loc.Module, loc.Token, loc.Offset)); case DbgILOffsetMapping.Unknown: case DbgILOffsetMapping.Prolog: case DbgILOffsetMapping.Epilog: case DbgILOffsetMapping.NoInfo: case DbgILOffsetMapping.UnmappedAddress: default: // The IL offset isn't known so use a method reference return(new DotNetTokenGlyphTextMarkerLocationInfo(loc.Module, loc.Token)); } } return(null); }
/// <summary> /// Writes the text shown after "Location: " in tooltips when hovering over the breakpoint icon in the glyph margin. /// Returns true if something was written, and false if nothing was written. /// </summary> /// <param name="output">Output</param> /// <param name="breakpoint">Breakpoint</param> /// <param name="textView">Text view</param> /// <param name="span">Span of breakpoint marker in the document</param> public abstract bool WriteLocation(ITextColorWriter output, DbgCodeBreakpoint breakpoint, ITextView textView, SnapshotSpan span);
/// <summary> /// Constructor /// </summary> /// <param name="breakpoint">Breakpoint</param> /// <param name="hitCount">Current hit count or null if we're not debugging</param> public DbgCodeBreakpointAndHitCount(DbgCodeBreakpoint breakpoint, int?hitCount) { Breakpoint = breakpoint ?? throw new ArgumentNullException(nameof(breakpoint)); HitCount = hitCount; }
/// <summary> /// Edits a breakpoint's settings /// </summary> /// <param name="breakpoint">Breakpoint</param> public void Edit(DbgCodeBreakpoint breakpoint) => Edit(new[] { breakpoint ?? throw new ArgumentNullException(nameof(breakpoint)) });
/// <summary> /// Constructor /// </summary> /// <param name="breakpoint">Breakpoint</param> /// <param name="settings">New settings</param> public DbgCodeBreakpointAndSettings(DbgCodeBreakpoint breakpoint, DbgCodeBreakpointSettings settings) { Breakpoint = breakpoint ?? throw new ArgumentNullException(nameof(breakpoint)); Settings = settings; }
public override void EditSettings(DbgCodeBreakpoint breakpoint) => showCodeBreakpointSettingsService.Value.Edit(breakpoint);
public abstract void Export(DbgCodeBreakpoint breakpoint);
public override void Remove(DbgCodeBreakpoint breakpoint) => breakpoint.Remove();
public DbgBoundCodeBreakpointImpl(DbgRuntimeImpl runtime, DbgCodeBreakpoint breakpoint, DbgModule module, ulong address, in DbgBoundCodeBreakpointMessage message)
public override void Export(DbgCodeBreakpoint breakpoint) => dbgCodeBreakpointSerializerService.Value.Save(new[] { breakpoint });
public BreakpointGlyphPopupVM(ShowCodeBreakpointSettingsService showCodeBreakpointSettingsService, DbgCodeBreakpoint breakpoint) { this.showCodeBreakpointSettingsService = showCodeBreakpointSettingsService ?? throw new ArgumentNullException(nameof(showCodeBreakpointSettingsService)); this.breakpoint = breakpoint ?? throw new ArgumentNullException(nameof(breakpoint)); }
public abstract void Toggle(DbgCodeBreakpoint breakpoint);
/// <summary> /// Gets the location of the breakpoint or null /// </summary> /// <param name="breakpoint">Breakpoint</param> /// <returns></returns> public abstract GlyphTextMarkerLocationInfo?GetLocation(DbgCodeBreakpoint breakpoint);
public abstract void EditSettings(DbgCodeBreakpoint breakpoint);
string GetToolTipContent(DbgCodeBreakpoint breakpoint, ITextView textView, SnapshotSpan span) { var output = new StringBuilderTextColorOutput(); var msg = breakpoint.BoundBreakpointsMessage; if (msg.Severity != DbgBoundCodeBreakpointSeverity.None) { output.Write(BoxedTextColor.Error, msg.Message); output.WriteLine(); output.WriteLine(); } output.Write(BoxedTextColor.Text, dnSpy_Debugger_Resources.GlyphToolTip_Location); output.Write(BoxedTextColor.Text, ": "); WriteLocation(output, breakpoint, textView, span); const string INDENTATION = " "; if (breakpoint.Condition != null || breakpoint.HitCount != null || breakpoint.Filter != null) { output.WriteLine(); output.WriteLine(); output.Write(BoxedTextColor.Text, dnSpy_Debugger_Resources.GlyphToolTip_Conditions); if (breakpoint.Condition != null) { output.WriteLine(); output.Write(BoxedTextColor.Text, INDENTATION); breakpointConditionsFormatter.WriteToolTip(output, breakpoint.Condition.Value); } if (breakpoint.HitCount != null) { output.WriteLine(); output.Write(BoxedTextColor.Text, INDENTATION); breakpointConditionsFormatter.WriteToolTip(output, breakpoint.HitCount.Value, dbgCodeBreakpointHitCountService.GetHitCount(breakpoint)); } if (breakpoint.Filter != null) { output.WriteLine(); output.Write(BoxedTextColor.Text, INDENTATION); breakpointConditionsFormatter.WriteToolTip(output, breakpoint.Filter.Value); } } if (breakpoint.Trace != null) { output.WriteLine(); output.WriteLine(); output.Write(BoxedTextColor.Text, dnSpy_Debugger_Resources.GlyphToolTip_Actions); if (!breakpoint.Trace.Value.Continue) { output.WriteLine(); output.Write(BoxedTextColor.Text, INDENTATION); output.Write(BoxedTextColor.Text, dnSpy_Debugger_Resources.Breakpoints_GlyphMargin_BreakWhenBreakpointHit); } output.WriteLine(); output.Write(BoxedTextColor.Text, INDENTATION); breakpointConditionsFormatter.WriteToolTip(output, breakpoint.Trace.Value); } return(output.ToString()); }
public override void Toggle(DbgCodeBreakpoint breakpoint) => breakpoint.IsEnabled = !breakpoint.IsEnabled;
public abstract int Hit_DbgThread(DbgCodeBreakpoint breakpoint);
public abstract void Remove(DbgCodeBreakpoint breakpoint);