Beispiel #1
0
        int IDebugPendingBreakpoint2.Bind()
        {
            if (!CanBind())
            {
                // The breakpoint could not be bound. This may occur for many reasons such as an invalid location, an invalid expression, etc...
                // We may 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);
            }
            if (_boundBreakpoint != null)
            {
                throw new NotImplementedException(); // multiple bound breakpoints are not supported
            }
            IDebugDocumentPosition2 docPosition = (IDebugDocumentPosition2)
                                                  Marshal.GetObjectForIUnknown(_requestInfo.bpLocation.unionmember2);

            string documentName;

            TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
            TEXT_POSITION[] endPosition   = new TEXT_POSITION[1];

            EngineUtils.RequireOk(docPosition.GetFileName(out documentName));
            EngineUtils.RequireOk(docPosition.GetRange(startPosition, endPosition));

            var resolution = _manager.ResolveBreakpoint(startPosition[0]);

            _boundBreakpoint = new BoundBreakpoint(_backend, this, resolution);
            _boundBreakpoint.CompleteBind();

            _callbacks.OnBreakpointBound(_boundBreakpoint);

            return(VSConstants.S_OK);
        }