Exemple #1
0
        // Binds this pending breakpoint to one or more code locations.
        int IDebugPendingBreakpoint2.Bind()
        {
            if (CanBind())
            {
                var docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(_bpRequestInfo.bpLocation.unionmember2));

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

                // Get the location in the document that the breakpoint is in.
                var startPosition = new TEXT_POSITION[1];
                var endPosition   = new TEXT_POSITION[1];

                EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));

                _breakpoint = new NodeBreakpoint(_engine.Process.Debugger, documentName,
                                                 (int)startPosition[0].dwLine,
                                                 (int)startPosition[0].dwColumn,
                                                 _bpRequestInfo.bpCondition.bstrCondition);

                try
                {
                    _engine.Process.Debugger.AddBreakpointAsync(_breakpoint).Wait();
                }
                catch (Exception)
                {
                    return(VSConstants.E_FAIL);
                }

                var breakpointResolution = new AD7BreakpointResolution(_engine, _breakpoint, GetDocumentContext(_breakpoint));
                var boundBreakpoint      = new AD7BoundBreakpoint(_engine, _breakpoint, this, breakpointResolution);
                _boundBreakpoints.Add(boundBreakpoint);
                _bpManager.AddBoundBreakpoint(_breakpoint, boundBreakpoint);

                return(VSConstants.S_OK);
            }

            // The breakpoint could not be bound. This may occur for many reasons such as an invalid location, an invalid expression, etc...
            // The sample engine does not support this, but a real world engine will want to send an instance of IDebugBreakpointErrorEvent2 to the
            // UI and return a valid instance of IDebugErrorBreakpoint2 from IDebugPendingBreakpoint2::EnumErrorBreakpoints. The debugger will then
            // display information about why the breakpoint did not bind to the user.
            return(VSConstants.S_FALSE);
        }
Exemple #2
0
        private void OnBreakpointBindSucceeded(object sender, BreakpointEventArgs e)
        {
            IDebugPendingBreakpoint2 pendingBreakpoint;
            AD7BoundBreakpoint       boundBreakpoint = _breakpointManager.GetBreakpoint(e.Breakpoint);

            ((IDebugBoundBreakpoint2)boundBreakpoint).GetPendingBreakpoint(out pendingBreakpoint);

            Send(
                new AD7BreakpointBoundEvent((AD7PendingBreakpoint)pendingBreakpoint, boundBreakpoint),
                AD7BreakpointBoundEvent.IID,
                null
                );

            EventHandler <AD7EngineEventArgs> breakpointHit = EngineBreakpointHit;

            if (breakpointHit != null)
            {
                breakpointHit(this, new AD7EngineEventArgs(this));
            }
        }
        // Binds this pending breakpoint to one or more code locations.
        int IDebugPendingBreakpoint2.Bind()
        {
            if (CanBind())
            {
                var docPosition = (IDebugDocumentPosition2) (Marshal.GetObjectForIUnknown(_bpRequestInfo.bpLocation.unionmember2));

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

                // Get the location in the document that the breakpoint is in.
                var startPosition = new TEXT_POSITION[1];
                var endPosition = new TEXT_POSITION[1];

                EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));

                _breakpoint = new NodeBreakpoint(_engine.Process.Debugger, documentName,
                    (int) startPosition[0].dwLine,
                    (int) startPosition[0].dwColumn,
                    _bpRequestInfo.bpCondition.bstrCondition);

                try
                {
                    _engine.Process.Debugger.AddBreakpointAsync(_breakpoint).Wait();
                }
                catch (Exception)
                {
                    return VSConstants.E_FAIL;
                }

                var breakpointResolution = new AD7BreakpointResolution(_engine, _breakpoint, GetDocumentContext(_breakpoint));
                var boundBreakpoint = new AD7BoundBreakpoint(_engine, _breakpoint, this, breakpointResolution);
                _boundBreakpoints.Add(boundBreakpoint);
                _bpManager.AddBoundBreakpoint(_breakpoint, boundBreakpoint);

                return VSConstants.S_OK;
            }

            // The breakpoint could not be bound. This may occur for many reasons such as an invalid location, an invalid expression, etc...
            // The sample engine does not support this, but a real world engine will want to send an instance of IDebugBreakpointErrorEvent2 to the
            // UI and return a valid instance of IDebugErrorBreakpoint2 from IDebugPendingBreakpoint2::EnumErrorBreakpoints. The debugger will then
            // display information about why the breakpoint did not bind to the user.
            return VSConstants.S_FALSE;
        }
 // Called by bound breakpoints when they are being deleted.
 public void OnBoundBreakpointDeleted(AD7BoundBreakpoint boundBreakpoint)
 {
     _boundBreakpoints.Remove(boundBreakpoint);
 }
Exemple #5
0
 public AD7BreakpointBoundEvent(AD7PendingBreakpoint pendingBreakpoint, AD7BoundBreakpoint boundBreakpoint)
 {
     m_pendingBreakpoint = pendingBreakpoint;
     m_boundBreakpoint = boundBreakpoint;
 }
Exemple #6
0
 public AD7BreakpointBoundEvent(AD7PendingBreakpoint pendingBreakpoint, AD7BoundBreakpoint boundBreakpoint)
 {
     m_pendingBreakpoint = pendingBreakpoint;
     m_boundBreakpoint   = boundBreakpoint;
 }
 public void AddBoundBreakpoint(NodeBreakpoint breakpoint, AD7BoundBreakpoint boundBreakpoint)
 {
     _breakpointMap[breakpoint] = boundBreakpoint;
 }
Exemple #8
0
 // Called by bound breakpoints when they are being deleted.
 public void OnBoundBreakpointDeleted(AD7BoundBreakpoint boundBreakpoint)
 {
     _boundBreakpoints.Remove(boundBreakpoint);
 }