Esempio n. 1
0
        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();
            }
        }