Ejemplo n.º 1
0
        // Binds this pending breakpoint to one or more code locations.
        int IDebugPendingBreakpoint2.Bind()
        {
            if (CanBind())
            {
                IDebugDocumentPosition2 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.
                TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
                TEXT_POSITION[] endPosition   = new TEXT_POSITION[1];
                EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));

                lock (_boundBreakpoints) {
                    var bp = _engine.Process.AddBreakPoint(documentName, (int)(startPosition[0].dwLine + 1), _bpRequestInfo.bpCondition.bstrCondition, _bpRequestInfo.bpCondition.styleCondition == enum_BP_COND_STYLE.BP_COND_WHEN_TRUE ? false : true);
                    AD7BreakpointResolution breakpointResolution = new AD7BreakpointResolution(_engine, bp, GetDocumentContext(bp));
                    AD7BoundBreakpoint      boundBreakpoint      = new AD7BoundBreakpoint(_engine, bp, this, breakpointResolution);
                    _boundBreakpoints.Add(boundBreakpoint);
                    _bpManager.AddBoundBreakpoint(bp, boundBreakpoint);

                    if (_enabled)
                    {
                        bp.Add();
                    }
                }

                return(VSConstants.S_OK);
            }
            else
            {
                // 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);
            }
        }
Ejemplo n.º 2
0
 public void AddBoundBreakpoint(PythonBreakpoint breakpoint, AD7BoundBreakpoint boundBreakpoint)
 {
     _breakpointMap[breakpoint] = boundBreakpoint;
 }
Ejemplo n.º 3
0
 // Called by bound breakpoints when they are being deleted.
 public void OnBoundBreakpointDeleted(AD7BoundBreakpoint boundBreakpoint)
 {
     lock (_boundBreakpoints) {
         _boundBreakpoints.Remove(boundBreakpoint);
     }
 }
Ejemplo n.º 4
0
        // Binds this pending breakpoint to one or more code locations.
        int IDebugPendingBreakpoint2.Bind()
        {
            if (CanBind())
            {
                IDebugDocumentPosition2 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.
                TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
                TEXT_POSITION[] endPosition   = new TEXT_POSITION[1];
                EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));

                lock (_boundBreakpoints) {
                    if (_bpRequestInfo.guidLanguage == DebuggerConstants.guidLanguagePython)
                    {
                        var bp = _engine.Process.AddBreakPoint(
                            documentName,
                            (int)(startPosition[0].dwLine + 1),
                            _bpRequestInfo.bpCondition.styleCondition.ToPython(),
                            _bpRequestInfo.bpCondition.bstrCondition,
                            _bpRequestInfo.bpPassCount.stylePassCount.ToPython(),
                            (int)_bpRequestInfo.bpPassCount.dwPassCount);

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

                        if (_enabled)
                        {
                            bp.Add();
                        }

                        return(VSConstants.S_OK);
                    }
                    else if (_bpRequestInfo.guidLanguage == DebuggerConstants.guidLanguageDjangoTemplate)
                    {
                        // bind a Django template
                        var bp = _engine.Process.AddDjangoBreakPoint(
                            documentName,
                            (int)(startPosition[0].dwLine + 1)
                            );

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

                        if (_enabled)
                        {
                            bp.Add();
                        }

                        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 Python engine does not support this.
            // TODO: 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);
        }
Ejemplo n.º 5
0
        // Binds this pending breakpoint to one or more code locations.
        int IDebugPendingBreakpoint2.Bind() {
            if (CanBind()) {
                IDebugDocumentPosition2 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.
                TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
                TEXT_POSITION[] endPosition = new TEXT_POSITION[1];
                EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));
                
                lock (_boundBreakpoints) {
                    if (_bpRequestInfo.guidLanguage == DebuggerConstants.guidLanguagePython) {
                        var bp = _engine.Process.AddBreakPoint(
                            documentName,
                            (int)(startPosition[0].dwLine + 1),
                            _bpRequestInfo.bpCondition.styleCondition.ToPython(),
                            _bpRequestInfo.bpCondition.bstrCondition,
                            _bpRequestInfo.bpPassCount.stylePassCount.ToPython(),
                            (int)_bpRequestInfo.bpPassCount.dwPassCount);

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

                        if (_enabled) {
                            bp.Add();
                        }

                        return VSConstants.S_OK;
                    } else if (_bpRequestInfo.guidLanguage == DebuggerConstants.guidLanguageDjangoTemplate) {
                        
                        // bind a Django template 
                        var bp = _engine.Process.AddDjangoBreakPoint(
                            documentName,
                            (int)(startPosition[0].dwLine + 1)
                        );

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

                        if (_enabled) {
                            bp.Add();
                        }

                        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 Python engine does not support this.
            // TODO: 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;            
        }
Ejemplo n.º 6
0
 // Called by bound breakpoints when they are being deleted.
 public void OnBoundBreakpointDeleted(AD7BoundBreakpoint boundBreakpoint) {
     lock (_boundBreakpoints) {
         _boundBreakpoints.Remove(boundBreakpoint);
     }
 }
Ejemplo n.º 7
0
 public AD7BreakpointBoundEvent(AD7PendingBreakpoint pendingBreakpoint, AD7BoundBreakpoint boundBreakpoint)
 {
     m_pendingBreakpoint = pendingBreakpoint;
     m_boundBreakpoint   = boundBreakpoint;
 }
Ejemplo n.º 8
0
 public void AddBoundBreakpoint(PythonBreakpoint breakpoint, AD7BoundBreakpoint boundBreakpoint) {
     _breakpointMap[breakpoint] = boundBreakpoint;
 }
Ejemplo n.º 9
0
 public AD7BreakpointBoundEvent(AD7PendingBreakpoint pendingBreakpoint, AD7BoundBreakpoint boundBreakpoint) {
     m_pendingBreakpoint = pendingBreakpoint;
     m_boundBreakpoint = boundBreakpoint;
 }