public int GetCodeContext(ulong codeLocationId, out IDebugCodeContext2 codeContext)
        {
            // The codeContext is used, among other things, to link assembly instructions and
            // source code. The "Go To Source Code" functionality in disassembly view needs this
            // to be properly implemented.
            IDebugDocumentContext2 documentContext = null;

            if (_lineEntryCache.TryGetValue(codeLocationId, out LineEntryInfo lineEntry))
            {
                documentContext = _documentContextFactory.Create(lineEntry);
            }
            else
            {
                SbAddress address = _target.ResolveLoadAddress(codeLocationId);
                if (address != null)
                {
                    lineEntry       = address.GetLineEntry();
                    documentContext = _documentContextFactory.Create(lineEntry);
                }
            }

            string AddressToFuncName() =>
            _target.ResolveLoadAddress(codeLocationId)?.GetFunction()?.GetName() ??
            _codeContextName;

            codeContext = _codeContextFactory.Create(codeLocationId,
                                                     new Lazy <string>(AddressToFuncName),
                                                     documentContext, Guid.Empty);
            return(VSConstants.S_OK);
        }
示例#2
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);
        }
        // Compares this document context to a given array of document contexts.
        int IDebugDocumentContext2.Compare(enum_DOCCONTEXT_COMPARE Compare, IDebugDocumentContext2[] rgpDocContextSet, uint dwDocContextSetLen, out uint pdwDocContext)
        {
            dwDocContextSetLen = 0;
            pdwDocContext = 0;

            return Constants.E_NOTIMPL;
        }
示例#4
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 (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);
        }
示例#5
0
 // Creates a code context (ie PC)
 DebugCodeContext(DebugMemoryContext.Factory debugMemoryContextFactory, ulong address,
                  Lazy <string> name, IDebugDocumentContext2 documentContext,
                  Guid languageGuid) : base(debugMemoryContextFactory, address, name)
 {
     _documentContext = documentContext;
     _languageGuid    = languageGuid;
 }
示例#6
0
 public int GetDocumentContext(out IDebugDocumentContext2 documentContext)
 {
     documentContext = this.documentContext.Value;
     return(documentContext != null
         ? VSConstants.S_OK
         : VSConstants.E_FAIL);
 }
示例#7
0
 public int GetDocumentContext(out IDebugDocumentContext2 documentContext)
 {
     documentContext = _documentContext;
     return(documentContext != null
         ? VSConstants.S_OK
         : VSConstants.S_FALSE);
 }
        // Token: 0x060000E9 RID: 233 RVA: 0x00004A54 File Offset: 0x00002C54
        public int GetDocumentContext(out IDebugDocumentContext2 context)
        {
            context = null;
            if (this.Frame.IsExternalCode || !this.Frame.HasDebugInfo)
            {
                return(1);
            }
            if (this.Frame.SourceLocation == null)
            {
                return(1);
            }
            TEXT_POSITION begPos;
            TEXT_POSITION endPos;

            if (this.Frame.SourceLocation.EndLine == -1 || this.Frame.SourceLocation.EndColumn == -1)
            {
                begPos.dwLine   = (uint)(this.Frame.SourceLocation.Line - 1);
                begPos.dwColumn = 0U;
                endPos.dwLine   = (uint)this.Frame.SourceLocation.Line;
                endPos.dwColumn = 0U;
            }
            else
            {
                begPos.dwLine   = (uint)(this.Frame.SourceLocation.Line - 1);
                begPos.dwColumn = (uint)(this.Frame.SourceLocation.Column - 1);
                endPos.dwLine   = (uint)(this.Frame.SourceLocation.EndLine - 1);
                endPos.dwColumn = (uint)(this.Frame.SourceLocation.EndColumn - 1);
            }
            string fileName = this.Frame.SourceLocation.FileName;

            context = new AD7DocumentContext(fileName, begPos, endPos, this.GetCodeContext());
            return(0);
        }
 public void SetUp()
 {
     _mockDocumentContext      = Substitute.For <IDebugDocumentContext2>();
     _mockMemoryContextFactory = Substitute.For <DebugMemoryContext.Factory>();
     _codeContext = new DebugCodeContext.Factory(_mockMemoryContextFactory)
                    .Create(_testPc, _testName, _mockDocumentContext, Guid.Empty);
 }
示例#10
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 (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);
        }
 public virtual void OnActivateDocumentEvent( IDebugDocumentContext2 documentContext,
     IDebugDocument2 document = null)
 {
     Logger.Debug( string.Empty );
     var eventObject = new ActivateDocumentEvent( documentContext, document );
     OnDebugEvent( eventObject, InterfaceGuids.IActivateDocumentEvent2Guid );
 }
示例#12
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 (sqframe.Source != "NATIVE")
                {
                    // Assume all lines begin and end at the beginning of the line.
                    TEXT_POSITION begTp = new TEXT_POSITION();
                    begTp.dwColumn = 0;
                    begTp.dwLine   = (uint)sqframe.Line - 1;
                    TEXT_POSITION endTp = new TEXT_POSITION();
                    endTp.dwColumn = 0;
                    endTp.dwLine   = (uint)sqframe.Line - 1;

                    docContext = new AD7DocumentContext(sqframe.Source, begTp, endTp, null);
                    return(EngineConstants.S_OK);
                }
            }
            catch (ComponentException e)
            {
                return(e.HRESULT);
            }
            catch (Exception e)
            {
                return(EngineUtils.UnexpectedException(e));
            }

            return(EngineConstants.S_FALSE);
        }
示例#13
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);
        }
示例#14
0
        public virtual void OnActivateDocumentEvent(IDebugDocumentContext2 documentContext,
                                                    IDebugDocument2 document = null)
        {
            Logger.Debug(string.Empty);
            var eventObject = new ActivateDocumentEvent(documentContext, document);

            OnDebugEvent(eventObject, InterfaceGuids.IActivateDocumentEvent2Guid);
        }
        public DebugActivateDocumentEvent(enum_EVENTATTRIBUTES attributes, IDebugDocument2 document, IDebugDocumentContext2 documentContext)
            : base(attributes)
        {
            Contract.Requires<ArgumentNullException>(document != null, "document");
            Contract.Requires<ArgumentNullException>(documentContext != null, "documentContext");

            _document = document;
            _documentContext = documentContext;
        }
        public DebugActivateDocumentEvent(enum_EVENTATTRIBUTES attributes, IDebugDocument2 document, IDebugDocumentContext2 documentContext)
            : base(attributes)
        {
            Contract.Requires <ArgumentNullException>(document != null, "document");
            Contract.Requires <ArgumentNullException>(documentContext != null, "documentContext");

            _document        = document;
            _documentContext = documentContext;
        }
示例#17
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)
        {
            if (_codeCxt == null)
            {
                docContext = null;
                return(Constants.E_FAIL); // annotated frame
            }

            return(_codeCxt.GetDocumentContext(out docContext));
        }
        /// <summary>
        /// Gets the document context for this stack frame.
        /// </summary>
        /// <param name="ppCxt">Returns an IDebugDocumentContext2 object that represents the current position in a source document.</param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
        /// <remarks>
        /// This method is faster than calling the IDebugStackFrame2.GetCodeContext method and then calling
        /// the IDebugCodeContext2.GetDocumentContext method on the code context. However, it is not guaranteed
        /// that every debug engine (DE) will implement this method.
        /// </remarks>
        public int GetDocumentContext(out IDebugDocumentContext2 ppCxt)
        {
            if (_nativeMethod)
            {
                ppCxt = null;
                return(VSConstants.E_FAIL);
            }

            ppCxt = new JavaDebugDocumentContext(_stackFrame.GetLocation());
            return(VSConstants.S_OK);
        }
示例#19
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)
        {
            if (_documentCxt == null)
            {
                docContext = null;
                return(Constants.E_FAIL); // annotated frame
            }

            docContext = _documentCxt;
            return(Constants.S_OK);
        }
示例#20
0
            public virtual IDebugCodeContext2 Create(ulong address, string name,
                                                     IDebugDocumentContext2 documentContext,
                                                     Guid languageGuid)
            {
                var lazyName = new Lazy <string>(() => string.IsNullOrWhiteSpace(name)
                                                    ? $"0x{address:x16}"
                                                    : name);

                return(new DebugCodeContext(_debugMemoryContextFactory, address, lazyName,
                                            documentContext, languageGuid));
            }
示例#21
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);
        }
示例#22
0
        // Gets the document context for this code-context. If no document context is available, return S_FALSE.
        public int GetDocumentContext(out IDebugDocumentContext2 ppSrcCxt)
        {
            int hr = Constants.S_OK;

            if (_documentContext == null)
            {
                hr = Constants.S_FALSE;
            }

            ppSrcCxt = _documentContext;
            return(hr);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int Seek(int nCount, out IDebugDocumentContext2 ppDocContext)
        {
            //
            // Moves the document context by a given number of statements or lines.
            //

            LoggingUtils.PrintFunction();

            ppDocContext = null;

            return(Constants.E_NOTIMPL);
        }
示例#24
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)
        {
            // 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);
        }
示例#25
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;
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int GetDocumentContext(out IDebugDocumentContext2 documentContext)
        {
            //
            // 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.
            //

            LoggingUtils.PrintFunction();

            documentContext = m_documentContext;

            return(Constants.S_OK);
        }
示例#27
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;

            var span  = _engine.Process.GetStatementSpan(StackFrame.FileName, _stackFrame.LineNo, 0);
            var begTp = new TEXT_POSITION {
                dwLine = (uint)(span.Start.Line - 1), dwColumn = (uint)(span.Start.Column - 1)
            };
            var endTp = new TEXT_POSITION {
                dwLine = (uint)(span.End.Line - 1), dwColumn = (uint)(span.End.Column - 1)
            };

            docContext = new AD7DocumentContext(_stackFrame.FileName, begTp, endTp, null, _stackFrame.Kind);
            return(VSConstants.S_OK);
        }
示例#28
0
        public int GetDocumentContext(out IDebugDocumentContext2 ppCxt)
        {
            if (_monoStackFrame.HasDebugInfo)
            {
                ppCxt = new MonoDocumentContext(new TextPositionInfo(
                                                    _monoStackFrame.SourceLocation.FileName,
                                                    _monoStackFrame.SourceLocation.Line - 1,
                                                    _monoStackFrame.SourceLocation.Column - 1), null);

                return(S_OK);
            }

            ppCxt = null;
            return(S_FALSE);
        }
示例#29
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;
            // 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.LineNo - 1;
            TEXT_POSITION endTp = new TEXT_POSITION();

            endTp.dwColumn = 0;
            endTp.dwLine   = (uint)_stackFrame.LineNo - 1;

            docContext = new AD7DocumentContext(_stackFrame.FileName, begTp, endTp, null);
            return(VSConstants.S_OK);
        }
示例#30
0
        public int GetDocumentContext(out IDebugDocumentContext2 ppCxt)
        {
            // Assume all lines begin and end at the beginning of the line.
            TEXT_POSITION begTp = new TEXT_POSITION();

            begTp.dwColumn = 0;
            begTp.dwLine   = m_line - 1;
            TEXT_POSITION endTp = new TEXT_POSITION();

            endTp.dwColumn = 0;
            endTp.dwLine   = m_line - 1;

            ppCxt = new AD7DocumentContext(m_thread.SourceFile, begTp, endTp);

            return(VSConstants.S_OK);
        }
示例#31
0
 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;
 }
示例#32
0
        public AD7MemoryAddress(AD7Engine engine, string filename, uint lineno, PythonStackFrame frame = null)
        {
            _engine   = engine;
            _lineNo   = (uint)lineno;
            _filename = filename;
            _frame    = frame;

            var span     = _engine.Process.GetStatementSpan(_filename, (int)_lineNo + 1, 0);
            var startPos = new TEXT_POSITION {
                dwLine = (uint)(span.Start.Line - 1), dwColumn = (uint)(span.Start.Column - 1)
            };
            var endPos = new TEXT_POSITION {
                dwLine = (uint)(span.End.Line - 1), dwColumn = (uint)(span.End.Column - 1)
            };

            _documentContext = new AD7DocumentContext(filename, startPos, endPos, this, frame != null ? frame.Kind : FrameKind.None);
        }
示例#33
0
        public void SetUp()
        {
            lineEntry                  = new LineEntryInfo();
            mockDocumentContext        = Substitute.For <IDebugDocumentContext2>();
            mockThread                 = Substitute.For <IDebugThread>();
            mockDocumentContextFactory = Substitute.For <DebugDocumentContext.Factory>();
            mockDocumentContextFactory.Create(lineEntry).Returns(mockDocumentContext);
            mockDebuggerStackFrame = Substitute.For <RemoteFrame>();
            mockDebuggerStackFrame.GetLineEntry().Returns(lineEntry);
            mockDebuggerStackFrame.GetPC().Returns(TEST_PC);
            mockDebuggerStackFrame.GetFunctionName().Returns(NAME);
            mockDebuggerStackFrame.GetFunctionNameWithSignature().Returns(NAME);

            mockCodeContextFactory = Substitute.For <DebugCodeContext.Factory>();
            mockExpressionFactory  = Substitute.For <DebugExpression.Factory>();
            mockModuleCache        = Substitute.For <IDebugModuleCache>();

            mockDebugEngineHandler = Substitute.For <IDebugEngineHandler>();
            mockProgram            = Substitute.For <IGgpDebugProgram>();

            taskExecutor = new TaskExecutor(new JoinableTaskContext().Factory);

            var childAdapterFactory     = new RemoteValueChildAdapter.Factory();
            var varInfoFactory          = new LLDBVariableInformationFactory(childAdapterFactory);
            var varInfoEnumFactory      = new VariableInformationEnum.Factory(taskExecutor);
            var childrenProviderFactory = new ChildrenProvider.Factory();
            var propertyFactory         =
                new DebugProperty.Factory(varInfoEnumFactory, childrenProviderFactory,
                                          Substitute.For <DebugCodeContext.Factory>(),
                                          new VsExpressionCreator(), taskExecutor);

            childrenProviderFactory.Initialize(propertyFactory.Create);
            var registerSetsBuilderFactory = new RegisterSetsBuilder.Factory(varInfoFactory);

            stackFrame = new DebugStackFrame.Factory(mockDocumentContextFactory,
                                                     childrenProviderFactory, mockCodeContextFactory, mockExpressionFactory.Create,
                                                     varInfoFactory, varInfoEnumFactory, registerSetsBuilderFactory, taskExecutor)
                         .Create(new AD7FrameInfoCreator(mockModuleCache), mockDebuggerStackFrame,
                                 mockThread, mockDebugEngineHandler, mockProgram);

            stackFrameAsync = new DebugStackFrameAsync.Factory(mockDocumentContextFactory,
                                                               childrenProviderFactory, mockCodeContextFactory, mockExpressionFactory.Create,
                                                               varInfoFactory, varInfoEnumFactory, registerSetsBuilderFactory, taskExecutor)
                              .Create(new AD7FrameInfoCreator(mockModuleCache), mockDebuggerStackFrame,
                                      mockThread, mockDebugEngineHandler, mockProgram);
        }
        public ActivateDocumentEvent( IDebugDocumentContext2 documentContext, IDebugDocument2 document = null )
        {
            if ( documentContext == null )
            {
                throw new ArgumentNullException( "documentContext" );
            }

            DocumentContext = documentContext;
            if ( document == null )
            {
                int result = documentContext.GetDocument( out document );
                if ( result != VSConstants.S_OK )
                {
                    throw new ArgumentException( "The document could not be resolved from the document context." );
                }
            }
            Document = document;
        }
示例#35
0
        public ActivateDocumentEvent(IDebugDocumentContext2 documentContext, IDebugDocument2 document = null)
        {
            if (documentContext == null)
            {
                throw new ArgumentNullException("documentContext");
            }

            DocumentContext = documentContext;
            if (document == null)
            {
                int result = documentContext.GetDocument(out document);
                if (result != VSConstants.S_OK)
                {
                    throw new ArgumentException("The document could not be resolved from the document context.");
                }
            }
            Document = document;
        }
示例#36
0
        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);
        }
示例#37
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);
        }
示例#38
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;
            // 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.LineNo - 1;
            TEXT_POSITION endTp = new TEXT_POSITION();
            endTp.dwColumn = 0;
            endTp.dwLine = (uint)_stackFrame.LineNo - 1;

            docContext = new AD7DocumentContext(_stackFrame.FileName, begTp, endTp, null, _stackFrame.Kind);
            return VSConstants.S_OK;
        }
 public int GetDocumentContext(out IDebugDocumentContext2 ppSrcCxt)
 {
     ppSrcCxt = new DebugDocumentPositionContext(_documentPosition);
     return VSConstants.S_OK;
 }
 public int Seek(int nCount, out IDebugDocumentContext2 ppDocContext)
 {
     ppDocContext = null;
     return VSConstants.E_FAIL;
 }
 public int GetDocumentContext(out IDebugDocumentContext2 ppSrcCxt)
 {
     ppSrcCxt = this;
     return VSConstants.S_OK;
 }
示例#42
0
 public int GetDocumentContext(out IDebugDocumentContext2 ppCxt)
 {
     DLog.Debug(DContext.VSDebuggerComCall, "DebugStackFrame.GetDocumentContext");
     ppCxt = GetDocumentContext();
     return VSConstants.S_OK;
 }
示例#43
0
 int IDebugCodeContext2.GetDocumentContext(out IDebugDocumentContext2 ppSrcCxt) {
     ppSrcCxt = DocumentContext;
     return VSConstants.S_OK;
 }
 /// <summary>
 /// Gets the document context that corresponds to this code context. The document context represents a position in the source file that corresponds to the source code that generated this instruction.
 /// </summary>
 /// <param name="ppSrcCxt">Returns the IDebugDocumentContext2 object that corresponds to the code context.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 /// <remarks>Generally, the document context can be thought of as a position in a source file while the code context is a position of a code instruction in an execution stream.</remarks>
 public virtual int GetDocumentContext( out IDebugDocumentContext2 ppSrcCxt )
 {
     Logger.Debug( string.Empty );
     ppSrcCxt = null;
     return VSConstants.E_NOTIMPL;
 }
 int IDebugDocumentContext2.Seek(int nCount, out IDebugDocumentContext2 ppDocContext) {
     ppDocContext = null;
     return VSConstants.E_NOTIMPL;
 }
示例#46
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 (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;
    }
示例#47
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 (m_hasSource) {
                    // Assume all lines begin and end at the beginning of the line.
                    var documentName = m_engine.DebuggedProcess.GetLocalFile(m_threadContext.script, fetchIfNotExists: true);
                    docContext = new AD7DocumentContext(documentName, m_lineNum, m_lineNum);
                    return Constants.S_OK;
                }
            } catch (Exception e) {
                return EngineUtils.UnexpectedException(e);
            }

            return Constants.S_FALSE;
        }
示例#48
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)
        {
            this.m_engine.cleanEvaluatedThreads();
            docContext = null;

            try
            {
                if (m_hasSource)
                {
                    // Assume all lines begin and end at the beginning of the line.
                    TEXT_POSITION begTp = new TEXT_POSITION();
                    begTp.dwColumn = 0;
                    begTp.dwLine = m_lineNum - 1;
                    TEXT_POSITION endTp = new TEXT_POSITION();
                    endTp.dwColumn = 0;
                    endTp.dwLine = m_lineNum - 1;

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

            return VSConstants.S_FALSE;
        }
示例#49
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)
        {
            if (_codeCxt == null)
            {
                docContext = null;
                return Constants.E_FAIL; // annotated frame
            }

            return _codeCxt.GetDocumentContext(out docContext);
        }
示例#50
0
 public int GetDocumentContext(out IDebugDocumentContext2 ppSrcCxt)
 {
     ppSrcCxt = new JavaDebugDocumentContext(_location);
     return VSConstants.S_OK;
 }
示例#51
0
 // Gets the document context for this code-context
 public int GetDocumentContext(out IDebugDocumentContext2 ppSrcCxt)
 {
     ppSrcCxt = _documentContext;
     return Constants.S_OK;
 }
 /// <summary>
 /// Moves the document context by a given number of statements or lines.
 /// </summary>
 /// <param name="nCount">The number of statements or lines to move ahead, depending on the document context.</param>
 /// <param name="ppDocContext">Returns a new IDebugDocumentContext2 object with the new position.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 public virtual int Seek( int nCount, out IDebugDocumentContext2 ppDocContext )
 {
     Logger.Debug( string.Empty );
     ppDocContext = null;
     return VSConstants.E_NOTIMPL;
 }
示例#53
0
 public void SetDocumentContext(IDebugDocumentContext2 docContext)
 {
     _documentContext = docContext;
 }
 /// <summary>
 /// Compares this document context to a given array of document contexts.
 /// </summary>
 /// <param name="Compare">A value from the DOCCONTEXT_COMPARE enumeration that specifies the type of comparison.</param>
 /// <param name="rgpDocContextSet">An array of IDebugDocumentContext2 objects that represent the document contexts being compared to.</param>
 /// <param name="dwDocContextSetLen">The length of the array of document contexts to compare.</param>
 /// <param name="pdwDocContext">Returns the index into the rgpDocContextSet array of the first document context that satisfies the comparison.</param>
 /// <returns>Returns S_OK if a match was found. Returns S_FALSE if no match was found. Otherwise, returns an error code.</returns>
 /// <remarks>
 /// The IDebugDocumentContext2 objects that are passed in the array must be implemented by the same debug engine that implements the IDebugDocumentContext2 object being called on; otherwise, the comparison is not valid.
 /// </remarks>
 public virtual int Compare( enum_DOCCONTEXT_COMPARE Compare,
     IDebugDocumentContext2[] rgpDocContextSet,
     uint dwDocContextSetLen,
     out uint pdwDocContext)
 {
     Logger.Debug( string.Empty );
     pdwDocContext = 0;
     return VSConstants.E_NOTIMPL;
 }
示例#55
0
        /// <summary>
        /// Gets the document context for this stack frame.
        /// </summary>
        /// <param name="ppCxt">Returns an IDebugDocumentContext2 object that represents the current position in a source document.</param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
        /// <remarks>
        /// This method is faster than calling the IDebugStackFrame2.GetCodeContext method and then calling
        /// the IDebugCodeContext2.GetDocumentContext method on the code context. However, it is not guaranteed
        /// that every debug engine (DE) will implement this method.
        /// </remarks>
        public int GetDocumentContext(out IDebugDocumentContext2 ppCxt)
        {
            if (_nativeMethod)
            {
                ppCxt = null;
                return VSConstants.E_FAIL;
            }

            ppCxt = new JavaDebugDocumentContext(_stackFrame.GetLocation());
            return VSConstants.S_OK;
        }
 public int Compare(enum_DOCCONTEXT_COMPARE Compare, IDebugDocumentContext2[] rgpDocContextSet, uint dwDocContextSetLen, out uint pdwDocContext)
 {
     throw new NotImplementedException();
 }
示例#57
0
 public int GetDocumentContext(out IDebugDocumentContext2 ppCxt)
 {
     ppCxt = docContext;
     return VSConstants.S_OK;
 }
示例#58
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)
        {
            if (_documentCxt == null)
            {
                docContext = null;
                return Constants.E_FAIL; // annotated frame
            }

            docContext = _documentCxt;
            return Constants.S_OK;
        }
示例#59
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)
        {
            // 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;
        }
示例#60
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 = DocumentContext;
     return VSConstants.S_OK;
 }