Mono.Debugger.DebuggerSession.AddEvent C# (CSharp) Method

AddEvent() public method

public AddEvent ( Event handle ) : void
handle Event
return void
        public void AddEvent(Event handle)
        {
            lock (this) {
                var cp = handle as ExceptionCatchPoint;
                if (cp != null) {
                    exception_catchpoints.Add (cp.UniqueID, cp);
                    events.Add (cp.Index, cp);
                    return;
                }

                Breakpoint breakpoint = (Breakpoint) handle;
                events.Add (breakpoint.Index, breakpoint);
                if (reached_main)
                    pending_bpts.Add (breakpoint, BreakpointHandle.Action.Insert);
            }
        }

Usage Example

示例#1
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);
        }