Exemplo n.º 1
0
        // Binds this pending breakpoint to one or more code locations.
        int IDebugPendingBreakpoint2.Bind()
        {
            if (CanBind())
            {
                // Get the location in the document that the breakpoint is in.
                var    startPosition = new TEXT_POSITION[1];
                var    endPosition   = new TEXT_POSITION[1];
                string fileName;
                var    docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(_bpRequestInfo.bpLocation.unionmember2));
                EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));
                EngineUtils.CheckOk(docPosition.GetFileName(out fileName));

                _breakpoint = _engine.Process.AddBreakpoint(
                    fileName,
                    (int)startPosition[0].dwLine,
                    (int)startPosition[0].dwColumn,
                    _enabled,
                    AD7BoundBreakpoint.GetBreakOnForPassCount(_bpRequestInfo.bpPassCount),
                    _bpRequestInfo.bpCondition.bstrCondition);

                _bpManager.AddPendingBreakpoint(_breakpoint, this);
                _breakpoint.BindAsync().WaitAsync(TimeSpan.FromSeconds(2)).Wait();

                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);
        }