示例#1
0
        bool ShouldStopOnExceptionCatchpoint(Catchpoint catchpoint, int frameId)
        {
            if (!catchpoint.Enabled)
            {
                return(false);
            }

            // global:: is necessary if the exception type is contained in current namespace,
            // and it also contains a class with the same name as the namespace itself.
            // Example: "Tests.Tests" and "Tests.TestException"
            var qualifiedExceptionType = catchpoint.ExceptionName.Contains("::") ? catchpoint.ExceptionName : $"global::{catchpoint.ExceptionName}";

            if (catchpoint.IncludeSubclasses)
            {
                if (EvaluateCondition(frameId, $"$exception is {qualifiedExceptionType}") == false)
                {
                    return(false);
                }
            }
            else
            {
                if (EvaluateCondition(frameId, $"$exception.GetType() == typeof({qualifiedExceptionType})") == false)
                {
                    return(false);
                }
            }

            return(string.IsNullOrWhiteSpace(catchpoint.ConditionExpression) || EvaluateCondition(frameId, catchpoint.ConditionExpression) != false);
        }
        void InsertCatchpoint(Catchpoint cp, BreakInfo bi, TypeMirror excType)
        {
            var request = bi.Req = vm.CreateExceptionRequest(excType, true, true);

            request.Count  = cp.HitCount;
            bi.Req.Enabled = bi.Enabled;
        }
        void ResolvePendingCatchpoint(Catchpoint cp, TypeMirror type)
        {
            BreakInfo bi = GetBreakInfo(cp);

            InsertCatchpoint(cp, bi, type);
            SetBreakEventStatus(cp, true);
        }
示例#4
0
        void SetInitialCatchpointData(Catchpoint cp)
        {
            stopOnFunction.Visible = false;
            hboxFunction.Visible   = false;
            stopOnLocation.Visible = false;
            vboxLocation.Visible   = false;

            stopOnException.Active      = true;
            entryExceptionType.Text     = cp.ExceptionName;
            checkIncludeSubclass.Active = cp.IncludeSubclasses;
        }
示例#5
0
        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);
        }
示例#6
0
 /// <summary>
 ///     Removes the specified catchpoint.
 /// </summary>
 /// <param name="catchpoint">The catchpoint.</param>
 public void Remove(Catchpoint catchpoint)
 {
     _catchpoints.Remove(catchpoint.ExceptionName);
 }
示例#7
0
 /// <summary>
 ///     Adds the specified catchpoint.
 /// </summary>
 /// <param name="catchpoint">The catchpoint.</param>
 public void Add(Catchpoint catchpoint)
 {
     _catchpoints[catchpoint.ExceptionName] = catchpoint;
 }
示例#8
0
 void SaveCatchpoint(Catchpoint cp)
 {
     cp.ExceptionName     = entryExceptionType.Text;
     cp.IncludeSubclasses = checkIncludeSubclass.Active;
 }