コード例 #1
0
        public int GetRequestInfo(enum_BPREQI_FIELDS dwFields, BP_REQUEST_INFO[] pBPRequestInfo)
        {
            pBPRequestInfo[0].dwFields = enum_BPREQI_FIELDS.BPREQI_BPLOCATION;

            if ((dwFields & enum_BPREQI_FIELDS.BPREQI_BPLOCATION) != 0)
            {
                if (DocumentPosition != null)
                {
                    pBPRequestInfo[0].bpLocation.bpLocationType = (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE;
                    pBPRequestInfo[0].bpLocation.unionmember2   = HostMarshal.RegisterDocumentPosition(DocumentPosition);
                }
                else if (FunctionPosition != null)
                {
                    pBPRequestInfo[0].bpLocation.bpLocationType = (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET;
                    pBPRequestInfo[0].bpLocation.unionmember2   = HostMarshal.RegisterFunctionPosition(FunctionPosition);
                }
            }
            if ((dwFields & enum_BPREQI_FIELDS.BPREQI_CONDITION) != 0 && !string.IsNullOrWhiteSpace(Condition))
            {
                // VSCode only support when true condition for now
                pBPRequestInfo[0].dwFields |= enum_BPREQI_FIELDS.BPREQI_CONDITION;
                pBPRequestInfo[0].bpCondition.bstrCondition  = Condition;
                pBPRequestInfo[0].bpCondition.styleCondition = enum_BP_COND_STYLE.BP_COND_WHEN_TRUE;
            }
            if ((dwFields & enum_BPREQI_FIELDS.BPREQI_PASSCOUNT) != 0)
            {
                // not supported
            }
            return(0);
        }
コード例 #2
0
        // Gets the breakpoint resolution information that describes this breakpoint.
        int IDebugBreakpointResolution2.GetResolutionInfo(enum_BPRESI_FIELDS dwFields, BP_RESOLUTION_INFO[] pBPResolutionInfo)
        {
            if ((dwFields & enum_BPRESI_FIELDS.BPRESI_BPRESLOCATION) != 0)
            {
                BP_RESOLUTION_LOCATION location = new BP_RESOLUTION_LOCATION();
                location.bpType = (uint)_breakType;
                if (_breakType == enum_BP_TYPE.BPT_CODE)
                {
                    // The debugger will not QI the IDebugCodeContex2 interface returned here. We must pass the pointer
                    // to IDebugCodeContex2 and not IUnknown.
                    AD7MemoryAddress codeContext = new AD7MemoryAddress(_engine, Addr, _functionName);
                    codeContext.SetDocumentContext(_documentContext);
                    location.unionmember1 = HostMarshal.RegisterCodeContext(codeContext);
                    pBPResolutionInfo[0].bpResLocation = location;
                    pBPResolutionInfo[0].dwFields     |= enum_BPRESI_FIELDS.BPRESI_BPRESLOCATION;
                }
                else if (_breakType == enum_BP_TYPE.BPT_DATA)
                {
                    location.unionmember1 = HostMarshal.GetIntPtrForDataBreakpointAddress(EngineUtils.AsAddr(Addr, _engine.DebuggedProcess.Is64BitArch));
                    pBPResolutionInfo[0].bpResLocation = location;
                    pBPResolutionInfo[0].dwFields     |= enum_BPRESI_FIELDS.BPRESI_BPRESLOCATION;
                }
            }

            if ((dwFields & enum_BPRESI_FIELDS.BPRESI_PROGRAM) != 0)
            {
                pBPResolutionInfo[0].pProgram  = (IDebugProgram2)_engine;
                pBPResolutionInfo[0].dwFields |= enum_BPRESI_FIELDS.BPRESI_PROGRAM;
            }

            return(Constants.S_OK);
        }
コード例 #3
0
        // Gets the breakpoint resolution information that describes this breakpoint.
        int IDebugBreakpointResolution2.GetResolutionInfo(enum_BPRESI_FIELDS dwFields, BP_RESOLUTION_INFO[] pBPResolutionInfo)
        {
            if ((dwFields & enum_BPRESI_FIELDS.BPRESI_BPRESLOCATION) != 0)
            {
                // The sample engine only supports code breakpoints.
                BP_RESOLUTION_LOCATION location = new BP_RESOLUTION_LOCATION();
                location.bpType = (uint)enum_BP_TYPE.BPT_CODE;

                // The debugger will not QI the IDebugCodeContex2 interface returned here. We must pass the pointer
                // to IDebugCodeContex2 and not IUnknown.
                AD7MemoryAddress codeContext = new AD7MemoryAddress(_engine, Addr, _functionName);
                codeContext.SetDocumentContext(_documentContext);
                location.unionmember1 = HostMarshal.RegisterCodeContext(codeContext);
                pBPResolutionInfo[0].bpResLocation = location;
                pBPResolutionInfo[0].dwFields     |= enum_BPRESI_FIELDS.BPRESI_BPRESLOCATION;
            }

            if ((dwFields & enum_BPRESI_FIELDS.BPRESI_PROGRAM) != 0)
            {
                pBPResolutionInfo[0].pProgram  = (IDebugProgram2)_engine;
                pBPResolutionInfo[0].dwFields |= enum_BPRESI_FIELDS.BPRESI_PROGRAM;
            }

            return(Constants.S_OK);
        }
コード例 #4
0
        private int BindWithTimeout()
        {
            Task bindTask = null;

            _engine.DebuggedProcess.WorkerThread.RunOperation(() =>
            {
                bindTask = _engine.DebuggedProcess.AddInternalBreakAction(this.BindAsync);
            });

            bindTask.Wait(_engine.GetBPLongBindTimeout());
            if (!bindTask.IsCompleted)
            {
                //send a low severity warning bp. This will allow the UI to respond quickly, and if the mi debugger doesn't end up binding, this warning will get
                //replaced by the real mi debugger error text
                this.SetError(new AD7ErrorBreakpoint(this, ResourceStrings.LongBind, enum_BP_ERROR_TYPE.BPET_SEV_LOW | enum_BP_ERROR_TYPE.BPET_TYPE_WARNING), true);
                return(Constants.S_FALSE);
            }
            else
            {
                if ((enum_BP_LOCATION_TYPE)_bpRequestInfo.bpLocation.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_DATA_STRING)
                {
                    lock (_engine.DebuggedProcess.DataBreakpointVariables)
                    {
                        string addressName = HostMarshal.GetDataBreakpointStringForIntPtr(_bpRequestInfo.bpLocation.unionmember3);
                        if (!_engine.DebuggedProcess.DataBreakpointVariables.Contains(addressName)) // might need to expand condition
                        {
                            _engine.DebuggedProcess.DataBreakpointVariables.Add(addressName);
                        }
                    }
                }
                return(Constants.S_OK);
            }
        }
コード例 #5
0
        internal async Task BindAsync()
        {
            if (CanBind())
            {
                string          documentName  = 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;
                    }
                    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;
                    }
                }

                // Bind all breakpoints that match this source and line number.
                PendingBreakpoint.BindResult bindResult = await PendingBreakpoint.Bind(documentName, startPosition[0].dwLine + 1, startPosition[0].dwColumn, _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);
                        }
                    }
                }
            }
        }
コード例 #6
0
        // Get the document context for this pending breakpoint. A document context is a abstract representation of a source file
        // location.
        public AD7DocumentContext GetDocumentContext(ulong address, string functionName)
        {
            IDebugDocumentPosition2 docPosition = HostMarshal.GetDocumentPositionForIntPtr(_bpRequestInfo.bpLocation.unionmember2);
            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));

            AD7MemoryAddress codeContext = new AD7MemoryAddress(_engine, address, functionName);

            return(new AD7DocumentContext(new MITextPosition(documentName, startPosition[0], startPosition[0]), codeContext));
        }
コード例 #7
0
        // Get the document context for this pending breakpoint. A document context is a abstract representation of a source file
        // location.
        public AD7DocumentContext GetDocumentContext(ulong address, string functionName)
        {
            if ((enum_BP_LOCATION_TYPE)_bpRequestInfo.bpLocation.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE)
            {
                IDebugDocumentPosition2 docPosition = HostMarshal.GetDocumentPositionForIntPtr(_bpRequestInfo.bpLocation.unionmember2);
                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));

                AD7MemoryAddress codeContext = new AD7MemoryAddress(_engine, address, functionName);

                return(new AD7DocumentContext(new MITextPosition(documentName, startPosition[0], startPosition[0]), codeContext, _engine.DebuggedProcess));
            }
            else
            {
                return(null);
            }
        }
コード例 #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;
                string                 address       = null;
                ulong                  codeAddress   = 0;
                uint                   size          = 0;
                IEnumerable <Checksum> checksums     = null;

                lock (_boundBreakpoints)
                {
                    if (_bp != null)   // already bound
                    {
                        Debug.Fail("Breakpoint already bound");
                        return;
                    }
                    if ((_bpRequestInfo.dwFields & enum_BPREQI_FIELDS.BPREQI_CONDITION) != 0 &&
                        _bpRequestInfo.bpCondition.styleCondition == enum_BP_COND_STYLE.BP_COND_WHEN_TRUE)
                    {
                        condition = _bpRequestInfo.bpCondition.bstrCondition;
                    }
                    if ((_bpRequestInfo.dwFields & enum_BPREQI_FIELDS.BPREQI_BPLOCATION) != 0)
                    {
                        switch ((enum_BP_LOCATION_TYPE)_bpRequestInfo.bpLocation.bpLocationType)
                        {
                        case enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET:
                        {
                            IDebugFunctionPosition2 functionPosition = HostMarshal.GetDebugFunctionPositionForIntPtr(_bpRequestInfo.bpLocation.unionmember2);
                            EngineUtils.CheckOk(functionPosition.GetFunctionName(out functionName));
                            break;
                        }

                        case enum_BP_LOCATION_TYPE.BPLT_CODE_CONTEXT:
                        {
                            IDebugCodeContext2 codePosition = HostMarshal.GetDebugCodeContextForIntPtr(_bpRequestInfo.bpLocation.unionmember1);
                            if (!(codePosition is AD7MemoryAddress))
                            {
                                goto default;           // context is not from this engine
                            }
                            codeAddress = ((AD7MemoryAddress)codePosition).Address;
                            break;
                        }

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

                            // Get the document checksum
                            // TODO: This and all other AD7 interface calls need to be moved so that they are only
                            // executed from the main thread.
                            // Github issue: https://github.com/Microsoft/MIEngine/issues/350
                            if (_engine.DebuggedProcess.MICommandFactory.SupportsBreakpointChecksums())
                            {
                                try
                                {
                                    checksums = GetSHA1Checksums();
                                }
                                catch (Exception)
                                {
                                    // If we fail to get a checksum there's nothing else we can do
                                }
                            }

                            break;
                        }

                        case enum_BP_LOCATION_TYPE.BPLT_DATA_STRING:
                        {
                            address = HostMarshal.GetDataBreakpointStringForIntPtr(_bpRequestInfo.bpLocation.unionmember3);
                            size    = (uint)_bpRequestInfo.bpLocation.unionmember4;
                            if (condition != null)
                            {
                                goto default;           // mi has no conditions on watchpoints
                            }
                            break;
                        }

                        default:
                        {
                            this.SetError(new AD7ErrorBreakpoint(this, ResourceStrings.UnsupportedBreakpoint), true);
                            return;
                        }
                        }
                    }
                }
                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, _enabled, checksums, this);
                }
                else if (functionName != null)
                {
                    bindResult = await PendingBreakpoint.Bind(functionName, _engine.DebuggedProcess, condition, _enabled, this);
                }
                else if (codeAddress != 0)
                {
                    bindResult = await PendingBreakpoint.Bind(codeAddress, _engine.DebuggedProcess, condition, _enabled, this);
                }
                else
                {
                    bindResult = await PendingBreakpoint.Bind(address, size, _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)
                    {
                        this.SetError(new AD7ErrorBreakpoint(this, bindResult.ErrorMessage), true);
                    }
                    else
                    {
                        Debug.Assert(_bp != null);
                        foreach (BoundBreakpoint bp in bindResult.BoundBreakpoints)
                        {
                            AddBoundBreakpoint(bp);
                        }
                    }
                }
            }
        }
コード例 #9
0
        // Binds this pending breakpoint to one or more code locations.
        int IDebugPendingBreakpoint2.Bind()
        {
            try
            {
                if (CanBind())
                {
                    // Make sure that HostMarshal calls happen on main thread instead of poll thread.
                    lock (_boundBreakpoints)
                    {
                        if (_bp != null)   // already bound
                        {
                            Debug.Fail("Breakpoint already bound");
                            return(Constants.S_FALSE);
                        }
                        if ((_bpRequestInfo.dwFields & enum_BPREQI_FIELDS.BPREQI_CONDITION) != 0 &&
                            _bpRequestInfo.bpCondition.styleCondition == enum_BP_COND_STYLE.BP_COND_WHEN_TRUE)
                        {
                            _condition = _bpRequestInfo.bpCondition.bstrCondition;
                        }
                        if ((_bpRequestInfo.dwFields & enum_BPREQI_FIELDS.BPREQI_BPLOCATION) != 0)
                        {
                            switch ((enum_BP_LOCATION_TYPE)_bpRequestInfo.bpLocation.bpLocationType)
                            {
                            case enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET:
                                try
                                {
                                    IDebugFunctionPosition2 functionPosition = HostMarshal.GetDebugFunctionPositionForIntPtr(_bpRequestInfo.bpLocation.unionmember2);
                                    EngineUtils.CheckOk(functionPosition.GetFunctionName(out _functionName));
                                }
                                finally
                                {
                                    HostMarshal.Release(_bpRequestInfo.bpLocation.unionmember2);
                                }
                                break;

                            case enum_BP_LOCATION_TYPE.BPLT_CODE_CONTEXT:
                                try
                                {
                                    IDebugCodeContext2 codePosition = HostMarshal.GetDebugCodeContextForIntPtr(_bpRequestInfo.bpLocation.unionmember1);
                                    if (!(codePosition is AD7MemoryAddress))
                                    {
                                        goto default;       // context is not from this engine
                                    }
                                    _codeAddress = ((AD7MemoryAddress)codePosition).Address;
                                }
                                finally
                                {
                                    HostMarshal.Release(_bpRequestInfo.bpLocation.unionmember1);
                                }
                                break;

                            case enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE:
                                try
                                {
                                    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));
                                }
                                finally
                                {
                                    HostMarshal.Release(_bpRequestInfo.bpLocation.unionmember2);
                                }

                                // Get the document checksum
                                if (_engine.DebuggedProcess.MICommandFactory.SupportsBreakpointChecksums())
                                {
                                    try
                                    {
                                        _checksums = GetSHA1Checksums();
                                    }
                                    catch (Exception)
                                    {
                                        // If we fail to get a checksum there's nothing else we can do
                                    }
                                }

                                break;

                            case enum_BP_LOCATION_TYPE.BPLT_DATA_STRING:
                                _address = HostMarshal.GetDataBreakpointStringForIntPtr(_bpRequestInfo.bpLocation.unionmember3);
                                _size    = (uint)_bpRequestInfo.bpLocation.unionmember4;
                                if (_condition != null)
                                {
                                    goto default;       // mi has no conditions on watchpoints
                                }
                                break;

                            default:
                                this.SetError(new AD7ErrorBreakpoint(this, ResourceStrings.UnsupportedBreakpoint), true);
                                return(Constants.S_FALSE);
                            }
                        }
                    }

                    Task bindTask = null;
                    _engine.DebuggedProcess.WorkerThread.RunOperation(() =>
                    {
                        bindTask = _engine.DebuggedProcess.AddInternalBreakAction(this.BindAsync);
                    });

                    bindTask.Wait(_engine.GetBPLongBindTimeout());
                    if (!bindTask.IsCompleted)
                    {
                        //send a low severity warning bp. This will allow the UI to respond quickly, and if the mi debugger doesn't end up binding, this warning will get
                        //replaced by the real mi debugger error text
                        this.SetError(new AD7ErrorBreakpoint(this, ResourceStrings.LongBind, enum_BP_ERROR_TYPE.BPET_SEV_LOW | enum_BP_ERROR_TYPE.BPET_TYPE_WARNING), true);
                        return(Constants.S_FALSE);
                    }
                    else
                    {
                        return(Constants.S_OK);
                    }
                }
                else
                {
                    // The breakpoint could not be bound. This may occur for many reasons such as an invalid location, an invalid expression, etc...
                    _engine.Callback.OnBreakpointError(_BPError);
                    return(Constants.S_FALSE);
                }
            }
            catch (MIException e)
            {
                return(e.HResult);
            }
            catch (AggregateException e)
            {
                if (e.GetBaseException() is InvalidCoreDumpOperationException)
                {
                    return(AD7_HRESULT.E_CRASHDUMP_UNSUPPORTED);
                }
                else
                {
                    return(EngineUtils.UnexpectedException(e));
                }
            }
            catch (InvalidCoreDumpOperationException)
            {
                return(AD7_HRESULT.E_CRASHDUMP_UNSUPPORTED);
            }
            catch (Exception e)
            {
                return(EngineUtils.UnexpectedException(e));
            }
        }
コード例 #10
0
 public EngineCallback(AD7Engine engine, IDebugEventCallback2 ad7Callback)
 {
     _engine        = engine;
     _eventCallback = HostMarshal.GetThreadSafeEventCallback(ad7Callback);
 }
コード例 #11
0
        // Binds this pending breakpoint to one or more code locations.
        int IDebugPendingBreakpoint2.Bind()
        {
            try
            {
                if (CanBind())
                {
                    // Make sure that HostMarshal calls happen on main thread instead of poll thread.
                    lock (_boundBreakpoints)
                    {
                        if (_bp != null)   // already bound
                        {
                            Debug.Fail("Breakpoint already bound");
                            return(Constants.S_FALSE);
                        }
                        if ((_bpRequestInfo.dwFields & enum_BPREQI_FIELDS.BPREQI_CONDITION) != 0 &&
                            _bpRequestInfo.bpCondition.styleCondition == enum_BP_COND_STYLE.BP_COND_WHEN_TRUE)
                        {
                            _condition = _bpRequestInfo.bpCondition.bstrCondition;
                        }
                        if ((_bpRequestInfo.dwFields & enum_BPREQI_FIELDS.BPREQI_BPLOCATION) != 0)
                        {
                            switch ((enum_BP_LOCATION_TYPE)_bpRequestInfo.bpLocation.bpLocationType)
                            {
                            case enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET:
                                try
                                {
                                    IDebugFunctionPosition2 functionPosition = HostMarshal.GetDebugFunctionPositionForIntPtr(_bpRequestInfo.bpLocation.unionmember2);
                                    EngineUtils.CheckOk(functionPosition.GetFunctionName(out _functionName));
                                }
                                finally
                                {
                                    HostMarshal.Release(_bpRequestInfo.bpLocation.unionmember2);
                                }
                                break;

                            case enum_BP_LOCATION_TYPE.BPLT_CODE_CONTEXT:
                                try
                                {
                                    IDebugCodeContext2 codePosition = HostMarshal.GetDebugCodeContextForIntPtr(_bpRequestInfo.bpLocation.unionmember1);
                                    if (!(codePosition is AD7MemoryAddress))
                                    {
                                        goto default;       // context is not from this engine
                                    }
                                    _codeAddress = ((AD7MemoryAddress)codePosition).Address;
                                }
                                finally
                                {
                                    HostMarshal.Release(_bpRequestInfo.bpLocation.unionmember1);
                                }
                                break;

                            case enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE:
                                try
                                {
                                    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));
                                }
                                finally
                                {
                                    HostMarshal.Release(_bpRequestInfo.bpLocation.unionmember2);
                                }

                                // Get the document checksum
                                if (_engine.DebuggedProcess.MICommandFactory.SupportsBreakpointChecksums())
                                {
                                    try
                                    {
                                        _checksums = GetSHA1Checksums();
                                    }
                                    catch (Exception)
                                    {
                                        // If we fail to get a checksum there's nothing else we can do
                                    }
                                }

                                break;

                            case enum_BP_LOCATION_TYPE.BPLT_DATA_STRING:
                                string address = HostMarshal.GetDataBreakpointStringForIntPtr(_bpRequestInfo.bpLocation.unionmember3);
                                if (address.Contains(","))
                                {
                                    this.AddressId = address;
                                    _address       = address.Split(',')[0];
                                }
                                else
                                {
                                    this.AddressId = null;
                                    _address       = address;
                                }
                                _size = (uint)_bpRequestInfo.bpLocation.unionmember4;
                                if (_condition != null)
                                {
                                    goto default;       // mi has no conditions on watchpoints
                                }
                                break;

                            default:
                                this.SetError(new AD7ErrorBreakpoint(this, ResourceStrings.UnsupportedBreakpoint), true);
                                return(Constants.S_FALSE);
                            }
                        }
                    }

                    if (!_enabled && IsHardwareBreakpoint)
                    {
                        return(Constants.S_OK);
                    }

                    return(BindWithTimeout());
                }
                else
                {
                    // The breakpoint could not be bound. This may occur for many reasons such as an invalid location, an invalid expression, etc...
                    _engine.Callback.OnBreakpointError(_BPError);
                    return(Constants.S_FALSE);
                }
            }
            catch (MIException e)
            {
                return(e.HResult);
            }
            catch (AggregateException e)
            {
                if (e.GetBaseException() is InvalidCoreDumpOperationException)
                {
                    return(AD7_HRESULT.E_CRASHDUMP_UNSUPPORTED);
                }
                else
                {
                    return(EngineUtils.UnexpectedException(e));
                }
            }
            catch (InvalidCoreDumpOperationException)
            {
                return(AD7_HRESULT.E_CRASHDUMP_UNSUPPORTED);
            }
            catch (Exception e)
            {
                return(EngineUtils.UnexpectedException(e));
            }
        }