public override DbgCodeBreakpointCheckResult ShouldBreak(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, DbgCodeBreakpointFilter filter) { if (!dbgFilterExpressionEvaluatorService.HasExpressionEvaluator) { // There's no need to localize it, the FEE is exported by the Roslyn code return(new DbgCodeBreakpointCheckResult("There's no filter expression evaluator")); } var expr = filter.Filter; Debug.Assert(expr != null); if (expr == null) { return(new DbgCodeBreakpointCheckResult("Missing expression")); } try { dbgFilterEEVariableProvider.Initialize(boundBreakpoint.Process, thread); var res = dbgFilterExpressionEvaluatorService.Evaluate(expr, dbgFilterEEVariableProvider); if (res.HasError) { return(new DbgCodeBreakpointCheckResult(res.Error)); } return(new DbgCodeBreakpointCheckResult(res.Result)); } finally { dbgFilterEEVariableProvider.Clear(); } }
public override bool ShouldBreak(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, DbgCodeBreakpointFilter filter) { // If there's no FEE, assume expression matches everything if (!dbgFilterExpressionEvaluatorService.HasExpressionEvaluator) { return(true); } var expr = filter.Filter; Debug.Assert(expr != null); if (expr == null) { return(false); } try { dbgFilterEEVariableProvider.Initialize(boundBreakpoint.Process, thread); var res = dbgFilterExpressionEvaluatorService.Evaluate(expr, dbgFilterEEVariableProvider); if (res.HasError) { return(false); //TODO: Notify user too, but only at most once per breakpoint } return(res.Result); } finally { dbgFilterEEVariableProvider.Clear(); } }
bool ShouldBreak(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread? thread) { if (thread is null) return false; var bp = (DbgCodeBreakpointImpl)boundBreakpoint.Breakpoint; if (bp.IsClosed || boundBreakpoint.IsClosed) return false; var settings = bp.Settings; if (!settings.IsEnabled) return false; if (!bp.RaiseHitCheck(boundBreakpoint, thread)) return false; DbgCodeBreakpointCheckResult checkRes; if (settings.Filter is DbgCodeBreakpointFilter filter) { checkRes = dbgCodeBreakpointFilterChecker.Value.ShouldBreak(boundBreakpoint, thread, filter); if (checkRes.ErrorMessage is not null) { boundBreakpoint.Process.DbgManager.ShowError(checkRes.ErrorMessage); return true; } if (!checkRes.ShouldBreak) return false; } if (settings.Condition is DbgCodeBreakpointCondition condition) { checkRes = dbgCodeBreakpointConditionChecker.Value.ShouldBreak(boundBreakpoint, thread, condition); if (checkRes.ErrorMessage is not null) { boundBreakpoint.Process.DbgManager.ShowError(checkRes.ErrorMessage); return true; } if (!checkRes.ShouldBreak) return false; } // This counts as a hit, even if there's no 'hit count' option int currentHitCount = dbgCodeBreakpointHitCountService.Value.Hit_DbgThread(boundBreakpoint.Breakpoint); if (settings.HitCount is DbgCodeBreakpointHitCount hitCount) { checkRes = dbgCodeBreakpointHitCountChecker.Value.ShouldBreak(boundBreakpoint, thread, hitCount, currentHitCount); if (checkRes.ErrorMessage is not null) { boundBreakpoint.Process.DbgManager.ShowError(checkRes.ErrorMessage); return true; } if (!checkRes.ShouldBreak) return false; } bool shouldBreak; if (settings.Trace is DbgCodeBreakpointTrace trace) { dbgCodeBreakpointTraceMessagePrinter.Value.Print(boundBreakpoint, thread, trace); shouldBreak = !trace.Continue; } else shouldBreak = true; if (shouldBreak) bp.RaiseHit(boundBreakpoint, thread); return shouldBreak; }
public override bool ShowNativeCode(DbgBoundCodeBreakpoint boundBreakpoint, string title) { if (!dbgNativeCodeProvider.Value.TryGetNativeCode(boundBreakpoint, GetNativeCodeOptions(), out var result)) { return(false); } Show(result, title); return(true); }
public override void Print(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, DbgCodeBreakpointTrace trace) { if (tracepointMessageListeners.Length != 0) { var message = tracepointMessageCreator.Create(boundBreakpoint, thread, trace); foreach (var lz in tracepointMessageListeners) { lz.Value.Message(message); } } }
public override bool CanGetNativeCode(DbgBoundCodeBreakpoint boundBreakpoint) { if (boundBreakpoint == null) { throw new ArgumentNullException(nameof(boundBreakpoint)); } foreach (var provider in GetProviders(boundBreakpoint.Runtime)) { if (provider.CanGetNativeCode(boundBreakpoint)) { return(true); } } return(false); }
public override bool TryGetNativeCode(DbgBoundCodeBreakpoint boundBreakpoint, DbgNativeCodeOptions options, out GetNativeCodeResult result) { if (boundBreakpoint == null) { throw new ArgumentNullException(nameof(boundBreakpoint)); } foreach (var provider in GetProviders(boundBreakpoint.Runtime)) { if (provider.TryGetNativeCode(boundBreakpoint, options, out result)) { return(true); } } result = default; return(false); }
public override bool ShouldBreak(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, DbgCodeBreakpointHitCount hitCount, int currentHitCount) { switch (hitCount.Kind) { case DbgCodeBreakpointHitCountKind.Equals: return(currentHitCount == hitCount.Count); case DbgCodeBreakpointHitCountKind.MultipleOf: if (hitCount.Count <= 0) { return(false); } return((currentHitCount % hitCount.Count) == 0); case DbgCodeBreakpointHitCountKind.GreaterThanOrEquals: return(currentHitCount >= hitCount.Count); default: Debug.Fail($"Unknown hit count kind: {hitCount.Kind}"); return(false); } }
public override DbgCodeBreakpointCheckResult ShouldBreak(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, DbgCodeBreakpointHitCount hitCount, int currentHitCount) { switch (hitCount.Kind) { case DbgCodeBreakpointHitCountKind.Equals: return(new DbgCodeBreakpointCheckResult(currentHitCount == hitCount.Count)); case DbgCodeBreakpointHitCountKind.MultipleOf: if (hitCount.Count <= 0) { return(new DbgCodeBreakpointCheckResult($"Invalid hit count value: {hitCount.Count}")); } return(new DbgCodeBreakpointCheckResult((currentHitCount % hitCount.Count) == 0)); case DbgCodeBreakpointHitCountKind.GreaterThanOrEquals: return(new DbgCodeBreakpointCheckResult(currentHitCount >= hitCount.Count)); default: Debug.Fail($"Unknown hit count kind: {hitCount.Kind}"); return(new DbgCodeBreakpointCheckResult($"Unknown hit count kind: {hitCount.Kind}")); } }
public abstract bool CanShowNativeCode(DbgBoundCodeBreakpoint boundBreakpoint);
public override DbgCodeBreakpointCheckResult ShouldBreak(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, in DbgCodeBreakpointHitCount hitCount, int currentHitCount)
public abstract DbgCodeBreakpointCheckResult ShouldBreak(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, DbgCodeBreakpointHitCount hitCount, int currentHitCount);
public override DbgCodeBreakpointCheckResult ShouldBreak(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, in DbgCodeBreakpointFilter filter)
public abstract void Print(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, DbgCodeBreakpointTrace trace);
/// <summary> /// Tries to get the native code /// </summary> /// <param name="boundBreakpoint">A bound breakpoint</param> /// <param name="options">Options</param> /// <param name="result">Native code if successful</param> /// <returns></returns> public abstract bool TryGetNativeCode(DbgBoundCodeBreakpoint boundBreakpoint, DbgNativeCodeOptions options, out GetNativeCodeResult result);
public abstract DbgCodeBreakpointCheckResult ShouldBreak(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, in DbgCodeBreakpointFilter filter);
public abstract bool ShouldBreak(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, DbgCodeBreakpointCondition condition);
public override bool ShouldBreak(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, DbgCodeBreakpointCondition condition) { //TODO: return(false); }
public abstract DbgCodeBreakpointCheckResult ShouldBreak(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, DbgCodeBreakpointCondition condition);
bool ShouldBreak(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread) { var bp = (DbgCodeBreakpointImpl)boundBreakpoint.Breakpoint; if (bp.IsClosed || boundBreakpoint.IsClosed) { return(false); } var settings = bp.Settings; if (!settings.IsEnabled) { return(false); } if (!bp.RaiseHitCheck(boundBreakpoint, thread)) { return(false); } // Don't reorder these checks. This seems to be the order VS' debugger checks everything: // condition && hitCount && filter if (settings.Condition is DbgCodeBreakpointCondition condition) { if (!dbgCodeBreakpointConditionChecker.Value.ShouldBreak(boundBreakpoint, thread, condition)) { return(false); } } // This counts as a hit, even if there's no 'hit count' option int currentHitCount = dbgCodeBreakpointHitCountService.Value.Hit_DbgThread(boundBreakpoint.Breakpoint); if (settings.HitCount is DbgCodeBreakpointHitCount hitCount) { if (!dbgCodeBreakpointHitCountChecker.Value.ShouldBreak(boundBreakpoint, thread, hitCount, currentHitCount)) { return(false); } } if (settings.Filter is DbgCodeBreakpointFilter filter) { if (!dbgCodeBreakpointFilterChecker.Value.ShouldBreak(boundBreakpoint, thread, filter)) { return(false); } } bool shouldBreak; if (settings.Trace is DbgCodeBreakpointTrace trace) { dbgCodeBreakpointTraceMessagePrinter.Value.Print(boundBreakpoint, thread, trace); shouldBreak = !trace.Continue; } else { shouldBreak = true; } if (shouldBreak) { bp.RaiseHit(boundBreakpoint, thread); } return(shouldBreak); }
public override void Print(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, in DbgCodeBreakpointTrace trace)
public abstract bool ShowNativeCode(DbgBoundCodeBreakpoint boundBreakpoint, string title = null);
public override bool CanShowNativeCode(DbgBoundCodeBreakpoint boundBreakpoint) => dbgNativeCodeProvider.Value.CanGetNativeCode(boundBreakpoint);
/// <summary> /// Constructor /// </summary> /// <param name="boundBreakpoint">Breakpoint</param> /// <param name="thread">Thread or null if it's not known</param> /// <param name="messageFlags">Message flags</param> public DbgMessageBreakpoint(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, DbgEngineMessageFlags messageFlags) : base(messageFlags) { BoundBreakpoint = boundBreakpoint ?? throw new ArgumentNullException(nameof(boundBreakpoint)); Thread = thread; }
public abstract bool ShouldBreak(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, DbgCodeBreakpointFilter filter);