コード例 #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(this._bpRequestInfo.bpLocation.unionmember2));
                EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));
                EngineUtils.CheckOk(docPosition.GetFileName(out fileName));

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

                this._bpManager.AddPendingBreakpoint(this._breakpoint, this);
                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);
        }
コード例 #2
0
        // Creates a pending breakpoint in the engine. A pending breakpoint is contains all the information needed to bind a breakpoint to
        // a location in the debuggee.
        int IDebugEngine2.CreatePendingBreakpoint(IDebugBreakpointRequest2 pBPRequest,
                                                  out IDebugPendingBreakpoint2 ppPendingBP)
        {
            Log.Debug("Engine: CreatePendingBreakPoint");

            ppPendingBP = null;

            var info = new BP_REQUEST_INFO[1];

            info[0].bpLocation.bpLocationType = (uint)enum_BP_LOCATION_TYPE.BPLT_FILE_LINE;
            if (pBPRequest.GetRequestInfo(enum_BPREQI_FIELDS.BPREQI_BPLOCATION, info) == VSConstants.S_OK)
            {
                var    position = (IDebugDocumentPosition2)Marshal.GetObjectForIUnknown(info[0].bpLocation.unionmember2);
                var    start    = new TEXT_POSITION[1];
                var    end      = new TEXT_POSITION[1];
                string fileName;

                position.GetRange(start, end);
                position.GetFileName(out fileName);

                //VS has a 0 based line\column value. PowerShell starts at 1
                var breakpoint = new ScriptBreakpoint(_node, fileName, (int)start[0].dwLine + 1, (int)start[0].dwColumn, _events);
                ppPendingBP = breakpoint;

                bps.Add(breakpoint);
            }

            return(VSConstants.S_OK);
        }
コード例 #3
0
 public MonoDocumentContext(string fileName, TEXT_POSITION start, TEXT_POSITION end, MonoMemoryAddress address)
 {
     this.fileName = fileName;
     this.start    = start;
     this.end      = end;
     this.address  = address;
 }
コード例 #4
0
        // Binds this pending breakpoint to one or more code locations.
        int IDebugPendingBreakpoint2.Bind()
        {
            try {
                if (CanBind()) {
                    var docPosition = (IDebugDocumentPosition2)Marshal.GetObjectForIUnknown(m_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));

                    var id = m_engine.DebuggedProcess.SetBreakpoint(documentName, startPosition[0].dwLine, startPosition[0].dwColumn);
                    if (id == -1)
                        return Constants.S_FALSE;
                    lock (this)
                        m_boundBreakpoints.Add(new AD7BoundBreakpoint(m_engine, id, this));

                    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...
                    // 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 Constants.S_FALSE;
                }
            } catch (Exception e) {
                return EngineUtils.UnexpectedException(e);
            }
        }
コード例 #5
0
        // Create default mocks, and return values for the document position.
        void MockDocumentPosition(string filename, uint lineNumber, uint columnNumber)
        {
            var    mockDocumentPosition = Substitute.For <IDebugDocumentPosition2>();
            string value;

            mockDocumentPosition.GetFileName(out value).Returns(x =>
            {
                if (filename != null)
                {
                    x[0] = filename;
                    return(0);
                }
                return(1);
            });
            mockDocumentPosition.GetRange(Arg.Any <TEXT_POSITION[]>(), null).Returns(x =>
            {
                TEXT_POSITION[] startTextPositions = (TEXT_POSITION[])x[0];
                if (startTextPositions != null && startTextPositions.Length >= 1)
                {
                    TEXT_POSITION startTextPosition = new TEXT_POSITION();
                    startTextPosition.dwColumn      = columnNumber;
                    startTextPosition.dwLine        = lineNumber;
                    startTextPositions[0]           = startTextPosition;
                }
                return(0);
            });
            mockMarshal.GetDocumentPositionFromIntPtr(Arg.Any <IntPtr>()).Returns(
                mockDocumentPosition);
        }
コード例 #6
0
        public int Bind()
        {
            IDebugDocumentPosition2 docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(m_bpRequestInfo.bpLocation.unionmember2));

            string filename;

            docPosition.GetFileName(out filename);

            TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
            TEXT_POSITION[] endPosition   = new TEXT_POSITION[1];
            EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));

            Command bpCommand = new BreakpointCommand(Path.GetFileName(filename), (int)startPosition[0].dwLine + 1);

            m_engine.EnqueueCommand(bpCommand);

            AD7DocumentContext docContext = new AD7DocumentContext(filename, startPosition[0], endPosition[0]);

            AD7BreakpointResolution breakpointResolution = new AD7BreakpointResolution(this.m_engine, docContext);
            AD7BoundBreakpoint      boundBreakpoint      = new AD7BoundBreakpoint(this.m_engine, this, breakpointResolution);

            string fileandline = Path.GetFileName(filename) + ((int)startPosition[0].dwLine + 1).ToString();

            m_bpManager.StoreBoundBreakpoint(fileandline, boundBreakpoint);

            return(VSConstants.S_OK);
        }
コード例 #7
0
 public XamarinDocumentContext(string fileName, TEXT_POSITION begPos, TEXT_POSITION endPos, XamarinMemoryAddress codeContext)
 {
     _fileName    = fileName;
     _begPos      = begPos;
     _endPos      = endPos;
     _codeContext = codeContext;
 }
コード例 #8
0
 public MonoDocumentContext(string fileName, TEXT_POSITION start, TEXT_POSITION end, MonoMemoryAddress address)
 {
     _fileName = fileName;
     _start    = start;
     _end      = end;
     _address  = address;
 }
コード例 #9
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;
        }
コード例 #10
0
 public AD7DocumentContext(string fileName, TEXT_POSITION begPos, TEXT_POSITION endPos, AD7MemoryAddress codeContext)
 {
     _fileName = fileName;
     _begPos = begPos;
     _endPos = endPos;
     _codeContext = codeContext;
 }
コード例 #11
0
ファイル: AD7StackFrame.cs プロジェクト: Mucosoft/Cosmos
        // Gets the document context for this stack frame. The debugger will call this when the current stack frame is changed
        // and will use it to open the correct source document for this stack frame.
        int IDebugStackFrame2.GetDocumentContext(out IDebugDocumentContext2 docContext)
        {
            docContext = null;
            try {
                if (mHasSource)
                {
                    // Assume all lines begin and end at the beginning of the line.
                    TEXT_POSITION begTp = new TEXT_POSITION();
                    begTp.dwColumn = 0;
                    begTp.dwLine   = mLineNum - 1;
                    TEXT_POSITION endTp = new TEXT_POSITION();
                    endTp.dwColumn = 0;
                    endTp.dwLine   = mLineNum - 1;

                    docContext = new AD7DocumentContext(mDocName, begTp, endTp, null);
                    return(VSConstants.S_OK);
                }
            }
            //catch (ComponentException e)
            //{
            //    return e.HResult;
            //}
            catch (Exception e) {
                return(EngineUtils.UnexpectedException(e));
            }

            return(VSConstants.S_FALSE);
        }
コード例 #12
0
ファイル: MonoStackFrame.cs プロジェクト: ronbak/vs-mono
        // Gets the document context for this stack frame. The debugger will call this when the current stack frame is changed
        // and will use it to open the correct source document for this stack frame.
        int IDebugStackFrame2.GetDocumentContext(out IDebugDocumentContext2 docContext)
        {
            docContext = null;
            try
            {
                if (hasSource)
                {
                    // Assume all lines begin and end at the beginning of the line.
                    // TODO: Accurate line endings
                    var           lineNumber = (uint)LineNumber;
                    TEXT_POSITION begTp      = new TEXT_POSITION();
                    begTp.dwColumn = 0;
                    begTp.dwLine   = lineNumber - 1;
                    TEXT_POSITION endTp = new TEXT_POSITION();
                    endTp.dwColumn = 0;
                    endTp.dwLine   = lineNumber - 1;

                    docContext = new MonoDocumentContext(engine.TranslateToLocalPath(documentName), begTp, endTp, null);
                    return(VSConstants.S_OK);
                }
            }
            catch (ComponentException e)
            {
                return(e.HResult);
            }
            catch (Exception e)
            {
                return(EngineUtils.UnexpectedException(e));
            }

            return(VSConstants.S_FALSE);
        }
コード例 #13
0
        // Gets the document context for this stack frame. The debugger will call this when the current stack frame is changed
        // and will use it to open the correct source document for this stack frame.
        int IDebugStackFrame2.GetDocumentContext(out IDebugDocumentContext2 docContext)
        {
            docContext = null;
            try
            {
                if (_stackFrame.HasDebugInfo)
                {
                    // Assume all lines begin and end at the beginning of the line.
                    TEXT_POSITION begTp = new TEXT_POSITION();
                    begTp.dwColumn = 0;
                    begTp.dwLine   = (uint)(_stackFrame.SourceLocation.Line > 0 ? _stackFrame.SourceLocation.Line - 1 : 0);
                    TEXT_POSITION endTp = new TEXT_POSITION();
                    endTp.dwColumn = 0;
                    endTp.dwLine   = (uint)(_stackFrame.SourceLocation.Line > 0 ? _stackFrame.SourceLocation.Line - 1 : 0);

                    docContext = new XamarinDocumentContext(_stackFrame.SourceLocation.FileName, begTp, endTp, null);
                    return(VisualStudioExtensionConstants.S_OK);
                }
            }
            catch (ComponentException e)
            {
                return(e.HResult);
            }
            catch (Exception e)
            {
                NLogService.Logger.Error(e);
                return(VisualStudioExtensionConstants.S_FALSE);
            }

            return(VisualStudioExtensionConstants.S_FALSE);
        }
コード例 #14
0
        public MonoPendingBreakpoint(MonoEngine engine, IDebugBreakpointRequest2 pBPRequest)
        {
            var requestInfo = new BP_REQUEST_INFO[1];

            pBPRequest.GetRequestInfo(enum_BPREQI_FIELDS.BPREQI_BPLOCATION, requestInfo);
            _bpRequestInfo = requestInfo[0];
            _pBPRequest    = pBPRequest;
            _engine        = engine;

            IsEnabled = true;

            var docPosition =
                (IDebugDocumentPosition2)Marshal.GetObjectForIUnknown(_bpRequestInfo.bpLocation.unionmember2);

            string documentName;

            docPosition.GetFileName(out documentName);
            var startPosition = new TEXT_POSITION[1];
            var endPosition   = new TEXT_POSITION[1];

            docPosition.GetRange(startPosition, endPosition);

            DocumentName = documentName;
            StartLine    = (int)startPosition[0].dwLine;
            StartColumn  = (int)startPosition[0].dwColumn;

            EndLine   = (int)endPosition[0].dwLine;
            EndColumn = (int)endPosition[0].dwColumn;
        }
コード例 #15
0
ファイル: AD7DocumentContext.cs プロジェクト: fpcMotif/RTVS
 public AD7DocumentContext(string fileName, TEXT_POSITION start, TEXT_POSITION end, AD7MemoryAddress address)
 {
     FileName = fileName;
     Start    = start;
     End      = end;
     Address  = address;
 }
コード例 #16
0
        public int EnumCodeContexts(
            IDebugDocumentPosition2 docPos, out IEnumDebugCodeContexts2 contextsEnum)
        {
            contextsEnum = null;
            var startPositions = new TEXT_POSITION[1];
            var result         = docPos.GetRange(startPositions, null);

            if (result != VSConstants.S_OK)
            {
                Trace.WriteLine("Error: Unable to retrieve starting position.");
                return(result);
            }
            string fileName;

            docPos.GetFileName(out fileName);
            var codeContexts = new List <IDebugCodeContext2>();

            // TODO: Find a less hacky way of doing this
            var tempBreakpoint = _lldbTarget.BreakpointCreateByLocation(fileName,
                                                                        startPositions[0].dwLine + 1);

            if (tempBreakpoint == null)
            {
                Trace.WriteLine("Error: Failed to set temporary breakpoint used to map document " +
                                "position to code contexts.");
                return(VSConstants.E_FAIL);
            }
            try
            {
                var numLocations = tempBreakpoint.GetNumLocations();
                for (uint i = 0; i < numLocations; ++i)
                {
                    var location = tempBreakpoint.GetLocationAtIndex(i);
                    var address  = location.GetAddress();
                    if (address != null)
                    {
                        var codeContext = _codeContextFactory.Create(
                            address.GetLoadAddress(_lldbTarget),
                            address.GetFunction().GetName(),
                            _documentContextFactory.Create(address.GetLineEntry()),
                            Guid.Empty);
                        codeContexts.Add(codeContext);
                    }
                    else
                    {
                        Trace.WriteLine("Warning: Failed to obtain address for code context " +
                                        "from temporary breakpoint location. Code context skipped.");
                    }
                }
            }
            finally
            {
                _lldbTarget.BreakpointDelete(tempBreakpoint.GetId());
                tempBreakpoint = null;
            }

            contextsEnum = _codeContextEnumFactory.Create(codeContexts);
            return(VSConstants.S_OK);
        }
コード例 #17
0
ファイル: AD7DocumentContext.cs プロジェクト: PeezoSlug/PTVS
 public AD7DocumentContext(string fileName, TEXT_POSITION begPos, TEXT_POSITION endPos, AD7MemoryAddress codeContext, FrameKind frameKind)
 {
     _fileName    = fileName;
     _begPos      = begPos;
     _endPos      = endPos;
     _codeContext = codeContext;
     _frameKind   = frameKind;
 }
コード例 #18
0
ファイル: Breakpoint.cs プロジェクト: vsrad/radeon-asm-tools
        private TEXT_POSITION GetTextPosition()
        {
            var startPosition = new TEXT_POSITION[1];
            var endPosition   = new TEXT_POSITION[1];

            ErrorHandler.ThrowOnFailure(_documentInfo.GetRange(startPosition, endPosition));
            return(startPosition[0]);
        }
コード例 #19
0
ファイル: AD7MemoryAddress.cs プロジェクト: wenh123/PTVS
        public AD7MemoryAddress(AD7Engine engine, string filename, uint lineno, PythonStackFrame frame = null) {
            _engine = engine;
            _lineNo = (uint)lineno;
            _filename = filename;

            var pos = new TEXT_POSITION { dwLine = lineno, dwColumn = 0 };
            _documentContext = new AD7DocumentContext(filename, pos, pos, this, frame != null ? frame.Kind : FrameKind.None);
        }
コード例 #20
0
ファイル: SourceFileContext.cs プロジェクト: texbois/vsbasm
        public SourceFileContext(string filePath, TEXT_POSITION begPos, TEXT_POSITION endPos)
        {
            _filePath      = filePath;
            _startPosition = begPos;
            _endPosition   = endPos;

            FileName = Path.GetFileName(filePath);
        }
コード例 #21
0
 public AD7DocumentContext(string fileName, int lineNumber, TEXT_POSITION beginPosition, TEXT_POSITION endPosition, RoutineScope rs)
 {
     Debug.WriteLine("AD7DocumentContext: ctor");
     _fileName      = fileName;
     _beginPosition = beginPosition;
     _endPosition   = endPosition;
     _lineNumber    = lineNumber;
     _rs            = rs;
 }
コード例 #22
0
 public MITextPosition(string filename, uint line)
 {
     this.FileName      = filename;
     this.BeginPosition = new Microsoft.VisualStudio.Debugger.Interop.TEXT_POSITION()
     {
         dwLine = line - 1
     };
     this.EndPosition = this.BeginPosition;
 }
コード例 #23
0
        public SourceFileContext GetAddressContext(uint address)
        {
            var location = new TEXT_POSITION()
            {
                dwLine = _addressToLine[address], dwColumn = 0
            };

            return(new SourceFileContext(FilePath, location, location));
        }
コード例 #24
0
 public AD7DocumentContext(string fileName, int lineNumber, TEXT_POSITION beginPosition, TEXT_POSITION endPosition, RoutineScope rs)
 {
   Debug.WriteLine("AD7DocumentContext: ctor");
   _fileName = fileName;
   _beginPosition = beginPosition;
   _endPosition = endPosition;
   _lineNumber = lineNumber;
   _rs = rs;
 }
コード例 #25
0
        public static MITextPosition TryParse(TupleValue miTuple)
        {
            string filename = miTuple.TryFindString("fullname");

            if (string.IsNullOrEmpty(filename))
            {
                filename = miTuple.TryFindString("file");
            }
            if (!string.IsNullOrEmpty(filename))
            {
                filename = DebuggedProcess.UnixPathToWindowsPath(filename);
            }

            if (string.IsNullOrWhiteSpace(filename))
            {
                return(null);
            }

            uint?line = miTuple.TryFindUint("line");

            if (!line.HasValue || line.Value == 0)
            {
                return(null);
            }

            uint lineValue = line.Value;

            var startPosition = new TEXT_POSITION()
            {
                dwLine   = lineValue - 1,
                dwColumn = 0
            };

            uint?startColumn = miTuple.TryFindUint("col");

            if (startColumn > 0)
            {
                startPosition.dwColumn = startColumn.Value - 1;
            }

            TEXT_POSITION endPosition = startPosition;
            uint?         endLine     = miTuple.TryFindUint("end-line");

            if (endLine > 0)
            {
                endPosition.dwLine = endLine.Value - 1;

                uint?endCol = miTuple.TryFindUint("end-col");
                if (endCol > 0)
                {
                    endPosition.dwColumn = endCol.Value - 1;
                }
            }

            return(new MITextPosition(filename, startPosition, endPosition));
        }
コード例 #26
0
        // Binds this pending breakpoint to one or more code locations.
        int IDebugPendingBreakpoint2.Bind()
        {
            try
            {
                if (CanBind())
                {
                    IDebugDocumentPosition2 docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(m_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));


                    // Ask the symbol engine to find all addresses in all modules with symbols that match this source and line number.
                    uint[] addresses = m_engine.DebuggedProcess.GetAddressesForSourceLocation(null,
                                                                                              documentName,
                                                                                              startPosition[0].dwLine + 1,
                                                                                              startPosition[0].dwColumn);
                    lock (m_boundBreakpoints)
                    {
                        foreach (uint addr in addresses)
                        {
                            AD7BreakpointResolution breakpointResolution = new AD7BreakpointResolution(m_engine, addr, GetDocumentContext(addr));
                            AD7BoundBreakpoint      boundBreakpoint      = new AD7BoundBreakpoint(m_engine, addr, this, breakpointResolution);
                            m_boundBreakpoints.Add(boundBreakpoint);
                            m_engine.DebuggedProcess.SetBreakpoint(addr, boundBreakpoint);
                            ((IDebugBoundBreakpoint2)boundBreakpoint).Enable(m_enabled ? 1 : 0);
                        }
                    }

                    return(EngineConstants.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(EngineConstants.S_FALSE);
                }
            }
            catch (ComponentException e)
            {
                return(e.HRESULT);
            }
            catch (Exception e)
            {
                return(EngineUtils.UnexpectedException(e));
            }
        }
コード例 #27
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);
                        }
                    }
                }
            }
        }
コード例 #28
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="fileName"> Short path file name. </param>
        /// <param name="begPos"> Start position. </param>
        /// <param name="endPos"> End position. In VSNDK debug engine, both begPos and endPos have the same value. </param>
        /// <param name="codeContext"> An address in a program's execution stream. </param>
        public AD7DocumentContext(string fileName, TEXT_POSITION begPos, TEXT_POSITION endPos, AD7MemoryAddress codeContext)
        {
            // Need to lengthen the path used by Visual Studio.
            StringBuilder documentNameSB = new StringBuilder(1024);
            GetLongPathName(fileName, documentNameSB, documentNameSB.Capacity);
            m_fileName = documentNameSB.ToString();

            m_begPos = begPos;
            m_endPos = endPos;
            m_codeContext = codeContext;
        }
コード例 #29
0
        public int GetSourceRange(TEXT_POSITION[] pBegPosition, TEXT_POSITION[] pEndPosition)
        {
            Log.Debug("ScriptDocumentContext: GetSourceRange");

            pBegPosition[0].dwLine = (uint)_line;
            pBegPosition[0].dwColumn = (uint)_column;
            pEndPosition[0].dwLine = (uint)_line;
            pEndPosition[0].dwColumn = (uint)_column;

            return VSConstants.S_OK;
        }
コード例 #30
0
        public AD7MemoryAddress(AD7Engine engine, string filename, uint lineno, PythonStackFrame frame = null)
        {
            _engine   = engine;
            _lineNo   = (uint)lineno;
            _filename = filename;

            var pos = new TEXT_POSITION {
                dwLine = lineno, dwColumn = 0
            };

            _documentContext = new AD7DocumentContext(filename, pos, pos, this, frame != null ? frame.Kind : FrameKind.None);
        }
コード例 #31
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public DebuggeeDocumentContext(DebugEngine engine, string fileName, TEXT_POSITION beginPosition, TEXT_POSITION endPosition)
        {
            m_engine = engine;

            m_fileName = PathUtils.ConvertPathCygwinToWindows(fileName);

            m_beginPosition = beginPosition;

            m_endPosition = endPosition;

            m_codeContext = null;
        }
コード例 #32
0
        public string GetLocationInfo(IDebugDocumentPosition2 docPosition, out TEXT_POSITION[] startPosition, out TEXT_POSITION[] endPosition)
        {
            string documentName;

            EngineUtils.CheckOk(docPosition.GetFileName(out documentName));

            startPosition = new TEXT_POSITION[1];
            endPosition   = new TEXT_POSITION[1];
            EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));

            return(documentName);
        }
コード例 #33
0
        // Enumerates the code contexts for a given position in a source file.
        public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
        {
            string filename;

            pDocPos.GetFileName(out filename);
            TEXT_POSITION[] beginning = new TEXT_POSITION[1], end = new TEXT_POSITION[1];

            pDocPos.GetRange(beginning, end);

            ppEnum = new AD7CodeContextEnum(new[] { new AD7MemoryAddress(this, filename, (uint)beginning[0].dwLine) });
            return(VSConstants.S_OK);
        }
コード例 #34
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public DebuggeeDocumentContext (DebugEngine engine, string fileName, TEXT_POSITION beginPosition, TEXT_POSITION endPosition)
    {
      m_engine = engine;

      m_fileName = PathUtils.ConvertPathCygwinToWindows (fileName);

      m_beginPosition = beginPosition;

      m_endPosition = endPosition;

      m_codeContext = null;
    }
コード例 #35
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="fileName"> Short path file name. </param>
        /// <param name="begPos"> Start position. </param>
        /// <param name="endPos"> End position. In VSNDK debug engine, both begPos and endPos have the same value. </param>
        /// <param name="codeContext"> An address in a program's execution stream. </param>
        public AD7DocumentContext(string fileName, TEXT_POSITION begPos, TEXT_POSITION endPos, AD7MemoryAddress codeContext)
        {
            // Need to lengthen the path used by Visual Studio.
            StringBuilder documentNameSB = new StringBuilder(1024);

            GetLongPathName(fileName, documentNameSB, documentNameSB.Capacity);
            m_fileName = documentNameSB.ToString();

            m_begPos      = begPos;
            m_endPos      = endPos;
            m_codeContext = codeContext;
        }
コード例 #36
0
ファイル: AD7StackFrame.cs プロジェクト: xbdtb/node-tools
        // Gets the document context for this stack frame. The debugger will call this when the current stack frame is changed
        // and will use it to open the correct source document for this stack frame.
        int IDebugStackFrame2.GetDocumentContext(out IDebugDocumentContext2 docContext)
        {
            // Assume all lines begin and end at the beginning of the line.
            var begTp = new TEXT_POSITION {
                dwColumn = 0, dwLine = (uint)_stackFrame.Line - 1
            };
            var endTp = new TEXT_POSITION {
                dwColumn = 0, dwLine = (uint)_stackFrame.Line - 1
            };

            docContext = new AD7DocumentContext(_stackFrame.FileName, begTp, endTp, null);
            return(VSConstants.S_OK);
        }
コード例 #37
0
        private int CharPosFromTextPos(TEXT_POSITION textPosition)
        {
            // Lazily calculate ScriptLines
            if (textPosition.dwLine == 0)
            {
                return((int)textPosition.dwColumn);
            }

            var scriptLines = ScriptLines;
            var line        = textPosition.dwLine < scriptLines.Length ? (int)textPosition.dwLine : scriptLines.Length - 1;

            return(scriptLines[line] + (int)textPosition.dwColumn);
        }
コード例 #38
0
        public void GetLocation(out string fileName, out int lineNumber, out TEXT_POSITION start, out TEXT_POSITION end) {
            var docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(_requestInfo.bpLocation.unionmember2));

            Marshal.ThrowExceptionForHR(docPosition.GetFileName(out fileName));

            var pStart = new TEXT_POSITION[1];
            var pEnd = new TEXT_POSITION[1];
            Marshal.ThrowExceptionForHR(docPosition.GetRange(pStart, pEnd));
            start = pStart[0];
            end = pEnd[0];

            lineNumber = (int)start.dwLine + 1;
        }
コード例 #39
0
 public static TextSpan GetRange(this IDebugDocumentPosition2 documentPosition)
 {
     Contract.Requires<ArgumentNullException>(documentPosition != null, "documentPosition");
     TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
     TEXT_POSITION[] endPosition = new TEXT_POSITION[1];
     ErrorHandler.ThrowOnFailure(documentPosition.GetRange(startPosition, endPosition));
     return new TextSpan()
     {
         iStartLine = (int)startPosition[0].dwLine,
         iStartIndex = (int)startPosition[0].dwColumn,
         iEndLine = (int)endPosition[0].dwLine,
         iEndIndex = (int)endPosition[0].dwColumn
     };
 }
コード例 #40
0
        public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
        {
            TEXT_POSITION[] startPosition;
            TEXT_POSITION[] endPosition;
            var             documentName = breakpointManager.Engine.GetLocationInfo(pDocPos, out startPosition, out endPosition);

            var textPosition = new TEXT_POSITION {
                dwLine = startPosition[0].dwLine + 1
            };
            var documentContext = new MonoDocumentContext(documentName, textPosition, textPosition, null);

            ppEnum = new MonoCodeContextEnum(new[] { new MonoMemoryAddress(this, 0, documentContext) });
            return(VSConstants.S_OK);
        }
コード例 #41
0
        int IDebugStackFrame2.GetDocumentContext(out IDebugDocumentContext2 ppCxt) {
            var pos = new TEXT_POSITION { dwColumn = 0, dwLine = (uint)((StackFrame.LineNumber - 1) ?? 0) };

            string fileName = StackFrame.FileName;
            if (fileName != null) {
                try {
                    fileName = Path.GetFullPath(fileName);
                } catch (Exception) {
                }
            }

            ppCxt = new AD7DocumentContext(fileName, pos, pos, null);
            return VSConstants.S_OK;
        }
コード例 #42
0
ファイル: AD7PendingBreakpoint.cs プロジェクト: iSalva/Cosmos
    // Get the document context for this pending breakpoint. A document context is a abstract representation of a source file 
    // location.
    public AD7DocumentContext GetDocumentContext(uint address) {
      IDebugDocumentPosition2 docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(mBpRequestInfo.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(mEngine, address);

      return new AD7DocumentContext(documentName, startPosition[0], startPosition[0], codeContext);
    }
コード例 #43
0
ファイル: DebugDocumentContext.cs プロジェクト: rfcclub/dot42
 /// <summary>
 /// Gets the file statement range of the document context.
 /// A statement range is the range of the lines that contributed the code to which this document context refers.
 /// </summary>
 public int GetStatementRange(TEXT_POSITION[] pBegPosition, TEXT_POSITION[] pEndPosition)
 {
     DLog.Debug(DContext.VSDebuggerComCall, "DebugDocumentContext.GetStatementRange");
     var position = DocumentLocation.Position;
     if (position == null)
         return VSConstants.E_FAIL;
     // TEXT_POSITION starts counting at 0
     pBegPosition[0].dwLine = (uint) (position.Start.Line - 1);
     pBegPosition[0].dwColumn = (uint) (position.Start.Column - 1);
     pEndPosition[0].dwLine = (uint) (position.End.Line - 1);
     pEndPosition[0].dwColumn = (uint) (position.End.Column - 1);
     DLog.Debug(DContext.VSDebuggerComCall, "Range: {0}-{1}", position.Start, position.End);
     return VSConstants.S_OK;
 }
コード例 #44
0
ファイル: HandleException.cs プロジェクト: chrisparnin/ganji
 public static string GetTextLine(IDebugDocumentContext2 context, TEXT_POSITION start, TEXT_POSITION end)
 {
     //IVsTextManager2 tm2 = (IVsTextManager2)serviceProvider.GetService(typeof(SVsTextManager));
     //IVsTextView activeView;
     //int hResult = tm2.GetActiveView2(1, null, (uint)_VIEWFRAMETYPE.vftCodeWindow, out activeView);
     string name;
     context.GetName(enum_GETNAME_TYPE.GN_MONIKERNAME, out name);
     IVsTextView txtView;
     Debugger.ShowSource(context, 0, 0, 0, 0, out txtView);
     if (txtView != null)
     {
         string line;
         txtView.GetTextStream((int)start.dwLine, (int)start.dwColumn, (int)end.dwLine, (int)end.dwColumn, out line);
         return line;
     }
     return null;
 }
コード例 #45
0
ファイル: HandleException.cs プロジェクト: chrisparnin/ganji
 public static string GetDocumentText(IDebugDocumentText2 pText, TEXT_POSITION pos)
 {
     string documentText = string.Empty;
     if (pText != null)
     {
         uint numLines = 0;
         uint numChars = 0;
         int hr;
         hr = pText.GetSize(ref numLines, ref numChars);
         if (ErrorHandler.Succeeded(hr))
         {
             IntPtr buffer = Marshal.AllocCoTaskMem((int)numChars * sizeof(char));
             uint actualChars = 0;
             hr = pText.GetText(pos, numChars, buffer, out actualChars);
             if (ErrorHandler.Succeeded(hr))
             {
                 documentText = Marshal.PtrToStringUni(buffer, (int)actualChars);
             }
             Marshal.FreeCoTaskMem(buffer);
         }
     }
     return documentText;
 }
コード例 #46
0
ファイル: AD7PendingBreakpoint.cs プロジェクト: Strongc/VSLua
        public int Bind()
        {
            IDebugDocumentPosition2 docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(m_bpRequestInfo.bpLocation.unionmember2));

            string filename;
            docPosition.GetFileName(out filename);

            TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
            TEXT_POSITION[] endPosition = new TEXT_POSITION[1];
            EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));

            Command bpCommand = new BreakpointCommand(Path.GetFileName(filename), (int)startPosition[0].dwLine + 1);
            m_engine.EnqueueCommand(bpCommand);

            AD7DocumentContext docContext = new AD7DocumentContext(filename, startPosition[0], endPosition[0]);

            AD7BreakpointResolution breakpointResolution = new AD7BreakpointResolution(this.m_engine, docContext);
            AD7BoundBreakpoint boundBreakpoint = new AD7BoundBreakpoint(this.m_engine, this, breakpointResolution);

            string fileandline = Path.GetFileName(filename) + ((int)startPosition[0].dwLine + 1).ToString();
            m_bpManager.StoreBoundBreakpoint(fileandline, boundBreakpoint);

            return VSConstants.S_OK;
        }
コード例 #47
0
ファイル: AD7Engine.cs プロジェクト: wesrupert/MIEngine
        // Enumerates the code contexts for a given position in a source file.
        public int EnumCodeContexts(IDebugDocumentPosition2 docPosition, out IEnumDebugCodeContexts2 ppEnum)
        {
            string documentName;
            EngineUtils.CheckOk(docPosition.GetFileName(out documentName));

            // Get the location in the document
            TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
            TEXT_POSITION[] endPosition = new TEXT_POSITION[1];
            EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));
            List<IDebugCodeContext2> codeContexts = new List<IDebugCodeContext2>();

            List<ulong> addresses = null;
            uint line = startPosition[0].dwLine + 1;
            _debuggedProcess.WorkerThread.RunOperation(async () =>
            {
                addresses = await DebuggedProcess.StartAddressesForLine(documentName, line);
            });

            if (addresses != null && addresses.Count > 0)
            {
                foreach (var a in addresses)
                {
                    var codeCxt = new AD7MemoryAddress(this, a, null);
                    TEXT_POSITION pos;
                    pos.dwLine = line;
                    pos.dwColumn = 0;
                    MITextPosition textPosition = new MITextPosition(documentName, pos, pos);
                    codeCxt.SetDocumentContext(new AD7DocumentContext(textPosition, codeCxt, this.DebuggedProcess));
                    codeContexts.Add(codeCxt);
                }
                if (codeContexts.Count > 0)
                {
                    ppEnum = new AD7CodeContextEnum(codeContexts.ToArray());
                    return Constants.S_OK;
                }
            }
            ppEnum = null;
            return Constants.E_FAIL;
        }
コード例 #48
0
 public int GetSourceRange(TEXT_POSITION[] pBegPosition, TEXT_POSITION[] pEndPosition)
 {
     return _documentPosition.GetRange(pBegPosition, pEndPosition);
 }
コード例 #49
0
        // Gets the file statement range of the document context.
        // A statement range is the range of the lines that contributed the code to which this document context refers.
        int IDebugDocumentContext2.GetStatementRange(TEXT_POSITION[] pBegPosition, TEXT_POSITION[] pEndPosition)
        {
            pBegPosition[0].dwColumn = _begPos.dwColumn;
            pBegPosition[0].dwLine = _begPos.dwLine;

            pEndPosition[0].dwColumn = _endPos.dwColumn;
            pEndPosition[0].dwLine = _endPos.dwLine;

            return VSConstants.S_OK;
        }
コード例 #50
0
 public int GetStatementRange(TEXT_POSITION[] pBegPosition, TEXT_POSITION[] pEndPosition)
 {
     return VSConstants.E_FAIL;
 }
コード例 #51
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;
        }
コード例 #52
0
 public MITextPosition(string filename, TEXT_POSITION beginPosition, TEXT_POSITION endPosition)
 {
     this.FileName = filename;
     this.BeginPosition = beginPosition;
     this.EndPosition = endPosition;
 }
コード例 #53
0
        // Enumerates the code contexts for a given position in a source file.
        public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
        {
            if (_mixedMode) {
                ppEnum = null;
                return VSConstants.E_NOTIMPL;
            }

            string filename;
            pDocPos.GetFileName(out filename);
            TEXT_POSITION[] beginning = new TEXT_POSITION[1], end = new TEXT_POSITION[1];

            pDocPos.GetRange(beginning, end);

            ppEnum = new AD7CodeContextEnum(new[] { new AD7MemoryAddress(this, filename, (uint)beginning[0].dwLine) });
            return VSConstants.S_OK;
        }
コード例 #54
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;
            }
        }
コード例 #55
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);
                        }
                    }
                }
            }
        }
コード例 #56
0
 int IDebugDocumentContext2.GetStatementRange(TEXT_POSITION[] pBegPosition, TEXT_POSITION[] pEndPosition) {
     pBegPosition[0] = Start;
     pEndPosition[0] = End;
     return VSConstants.S_OK;
 }
コード例 #57
0
 public AD7DocumentContext(string fileName, TEXT_POSITION start, TEXT_POSITION end, AD7MemoryAddress address) {
     FileName = fileName;
     Start = start;
     End = end;
     Address = address;
 }
コード例 #58
0
    private int FindBreakpointLine()
    {
      IDebugDocumentPosition2 docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(_bpRequestInfo.bpLocation.unionmember2));

      TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
      TEXT_POSITION[] endPosition = new TEXT_POSITION[1];
      docPosition.GetRange(startPosition, endPosition);
      _lineNumber = startPosition[0].dwLine + 1;
      _beginPosition = startPosition[0];
      _endPosition = endPosition[0];
      string fileName;
      docPosition.GetFileName(out fileName);
      if (fileName != _node.FileName)
        return VSConstants.E_FAIL;
      else
        return VSConstants.S_OK;
    }
コード例 #59
0
        // Gets the file statement range of the document context.
        // A statement range is the range of the lines that contributed the code to which this document context refers.
        int IDebugDocumentContext2.GetStatementRange(TEXT_POSITION[] pBegPosition, TEXT_POSITION[] pEndPosition)
        {
            try
            {
                pBegPosition[0].dwColumn = _textPosition.BeginPosition.dwColumn;
                pBegPosition[0].dwLine = _textPosition.BeginPosition.dwLine;

                pEndPosition[0].dwColumn = _textPosition.EndPosition.dwColumn;
                pEndPosition[0].dwLine = _textPosition.EndPosition.dwLine;
            }
            catch (MIException e)
            {
                return e.HResult;
            }
            catch (Exception e)
            {
                return EngineUtils.UnexpectedException(e);
            }

            return Constants.S_OK;
        }
コード例 #60
0
 // Gets the source code range of this document context.
 // A source range is the entire range of source code, from the current statement back to just after the previous s
 // statement that contributed code. The source range is typically used for mixing source statements, including 
 // comments, with code in the disassembly window.
 // Sincethis engine does not support the disassembly window, this is not implemented.
 int IDebugDocumentContext2.GetSourceRange(TEXT_POSITION[] pBegPosition, TEXT_POSITION[] pEndPosition)
 {
     throw new NotImplementedException("This method is not implemented");
 }