Exemplo n.º 1
0
 void NotifyLoaded(PendingBreakpoint pendingBreakpoint)
 {
     if (!pendingBreakpoint.BoundBreakpoint.BoundCodeBreakpoint.IsClosed)
     {
         pendingBreakpoint.OnTypeLoaded();
     }
 }
Exemplo n.º 2
0
        internal async Task DeletePendingDelete()
        {
            Debug.Assert(PendingDelete, "Breakpoint is not marked for deletion");
            PendingBreakpoint bp = null;

            lock (_boundBreakpoints)
            {
                bp  = _bp;
                _bp = null;
            }
            if (bp != null)
            {
                await bp.DeleteAsync(_engine.DebuggedProcess);
            }
        }
Exemplo n.º 3
0
            public void AddBreakpoint(int typeToken, DbgEngineBoundCodeBreakpoint boundBreakpoint, Action onTypeLoaded)
            {
                var pendingBreakpoint = new PendingBreakpoint(boundBreakpoint, onTypeLoaded);

                if (loadedTypes.Contains(typeToken))
                {
                    NotifyLoaded(pendingBreakpoint);
                }
                else
                {
                    if (!pendingBreakpoints.TryGetValue(typeToken, out var list))
                    {
                        pendingBreakpoints.Add(typeToken, list = new List <PendingBreakpoint>());
                    }
                    list.Add(pendingBreakpoint);
                }
            }
Exemplo n.º 4
0
        public AD7PendingBreakpoint(IDebugBreakpointRequest2 pBPRequest, AD7Engine engine, BreakpointManager bpManager)
        {
            _pBPRequest = pBPRequest;
            BP_REQUEST_INFO[] requestInfo = new BP_REQUEST_INFO[1];
            EngineUtils.CheckOk(_pBPRequest.GetRequestInfo(enum_BPREQI_FIELDS.BPREQI_BPLOCATION | enum_BPREQI_FIELDS.BPREQI_CONDITION | enum_BPREQI_FIELDS.BPREQI_PASSCOUNT, requestInfo));
            _bpRequestInfo = requestInfo[0];

            _engine           = engine;
            _bpManager        = bpManager;
            _boundBreakpoints = new List <AD7BoundBreakpoint>();

            _enabled       = true;
            _deleted       = false;
            _pendingDelete = false;

            _bp      = null; // no underlying breakpoint created yet
            _BPError = null;
        }
Exemplo n.º 5
0
        // Deletes this pending breakpoint and all breakpoints bound from it.
        int IDebugPendingBreakpoint2.Delete()
        {
            lock (_boundBreakpoints)
            {
                for (int i = _boundBreakpoints.Count - 1; i >= 0; i--)
                {
                    _boundBreakpoints[i].Delete();
                }
                _deleted = true;
                if (_engine.DebuggedProcess.ProcessState != ProcessState.Stopped)
                {
                    _pendingDelete = true;
                }
                else if (_bp != null)
                {
                    _bp.Delete(_engine.DebuggedProcess);
                    _bp = null;
                }
            }

            return(VSConstants.S_OK);
        }
Exemplo n.º 6
0
        int IDebugPendingBreakpoint2.SetCondition(BP_CONDITION bpCondition)
        {
            PendingBreakpoint bp = null;

            lock (_boundBreakpoints)
            {
                if (!VerifyCondition(bpCondition))
                {
                    _BPError = new AD7ErrorBreakpoint(this, ResourceStrings.UnsupportedConditionalBreakpoint, enum_BP_ERROR_TYPE.BPET_GENERAL_ERROR);
                    _engine.Callback.OnBreakpointError(_BPError);
                    return(VSConstants.E_FAIL);
                }
                if ((_bpRequestInfo.dwFields & enum_BPREQI_FIELDS.BPREQI_CONDITION) != 0 &&
                    _bpRequestInfo.bpCondition.styleCondition == bpCondition.styleCondition &&
                    _bpRequestInfo.bpCondition.bstrCondition == bpCondition.bstrCondition)
                {
                    return(VSConstants.S_OK);  // this condition was already set
                }
                _bpRequestInfo.bpCondition = bpCondition;
                _bpRequestInfo.dwFields   |= enum_BPREQI_FIELDS.BPREQI_CONDITION;
                if (_bp != null)
                {
                    bp = _bp;
                }
            }
            if (bp != null)
            {
                _engine.DebuggedProcess.WorkerThread.RunOperation(() =>
                {
                    _engine.DebuggedProcess.AddInternalBreakAction(
                        () => bp.SetConditionAsync(bpCondition.bstrCondition, _engine.DebuggedProcess)
                        );
                });
            }
            return(VSConstants.S_OK);
        }
Exemplo n.º 7
0
        public DebugEventManager(Runspace runspace)
        {
            _runspace    = runspace;
            _breakpoints = new List <PendingBreakpoint>();

            var dte2 = Package.GetGlobalService(typeof(DTE)) as DTE2;

            foreach (Breakpoint bp in dte2.Debugger.Breakpoints)
            {
                if (bp.File.ToLower().EndsWith(".ps1"))
                {
                    var pbp = new PendingBreakpoint
                    {
                        BreakpointType = BreakpointType.Line,
                        Column         = bp.FileColumn,
                        Line           = bp.FileLine,
                        Context        = bp.File,
                        Language       = bp.Language
                    };

                    _breakpoints.Add(pbp);
                }
            }
        }
Exemplo n.º 8
0
        internal async Task BindAsync()
        {
            if (CanBind())
            {
                string          documentName  = null;
                string          functionName  = null;
                TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
                TEXT_POSITION[] endPosition   = new TEXT_POSITION[1];
                string          condition     = null;

                lock (_boundBreakpoints)
                {
                    if (_bp != null)   // already bound
                    {
                        Debug.Fail("Breakpoint already bound");
                        return;
                    }
                    if ((_bpRequestInfo.dwFields & enum_BPREQI_FIELDS.BPREQI_BPLOCATION) != 0)
                    {
                        if (_bpRequestInfo.bpLocation.bpLocationType == (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET)
                        {
                            IDebugFunctionPosition2 functionPosition = HostMarshal.GetDebugFunctionPositionForIntPtr(_bpRequestInfo.bpLocation.unionmember2);
                            EngineUtils.CheckOk(functionPosition.GetFunctionName(out functionName));
                        }
                        else if (_bpRequestInfo.bpLocation.bpLocationType == (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE)
                        {
                            IDebugDocumentPosition2 docPosition = HostMarshal.GetDocumentPositionForIntPtr(_bpRequestInfo.bpLocation.unionmember2);

                            // Get the name of the document that the breakpoint was put in
                            EngineUtils.CheckOk(docPosition.GetFileName(out documentName));

                            // Get the location in the document that the breakpoint is in.
                            EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));
                        }
                    }
                    if ((_bpRequestInfo.dwFields & enum_BPREQI_FIELDS.BPREQI_CONDITION) != 0 &&
                        _bpRequestInfo.bpCondition.styleCondition == enum_BP_COND_STYLE.BP_COND_WHEN_TRUE)
                    {
                        condition = _bpRequestInfo.bpCondition.bstrCondition;
                    }
                }
                PendingBreakpoint.BindResult bindResult;
                // Bind all breakpoints that match this source and line number.
                if (documentName != null)
                {
                    bindResult = await PendingBreakpoint.Bind(documentName, startPosition[0].dwLine + 1, startPosition[0].dwColumn, _engine.DebuggedProcess, condition, this);
                }
                else
                {
                    bindResult = await PendingBreakpoint.Bind(functionName, _engine.DebuggedProcess, condition, this);
                }

                lock (_boundBreakpoints)
                {
                    if (bindResult.PendingBreakpoint != null)
                    {
                        _bp = bindResult.PendingBreakpoint;    // an MI breakpoint object exists: TODO: lock?
                    }
                    if (bindResult.BoundBreakpoints == null || bindResult.BoundBreakpoints.Count == 0)
                    {
                        _BPError = new AD7ErrorBreakpoint(this, bindResult.ErrorMessage);
                        _engine.Callback.OnBreakpointError(_BPError);
                    }
                    else
                    {
                        Debug.Assert(_bp != null);
                        foreach (BoundBreakpoint bp in bindResult.BoundBreakpoints)
                        {
                            AddBoundBreakpoint(bp);
                        }
                    }
                }
            }
        }