Ejemplo n.º 1
0
        public void GetName()
        {
            lineEntry.Directory = "dir";
            lineEntry.FileName  = "file";
            string fileName;

            documentContext.GetName(enum_GETNAME_TYPE.GN_FILENAME, out fileName);
            Assert.AreEqual("dir\\file", fileName);
        }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
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);
        }
        public void SetUp()
        {
            string name = "";

            mockBreakpoint         = Substitute.For <RemoteBreakpoint>();
            lineEntry              = new LineEntryInfo();
            mockPendingBreakpoint  = Substitute.For <IDebugPendingBreakpoint2>();
            mockBreakpointLocation = Substitute.For <SbBreakpointLocation>();
            mockAddress            = Substitute.For <SbAddress>();
            mockAddress.GetLineEntry().Returns(lineEntry);
            mockBreakpointLocation.GetHitCount().Returns(HIT_COUNT);
            mockBreakpointLocation.GetLoadAddress().Returns(ADDRESS);
            mockBreakpointLocation.GetBreakpoint().Returns(mockBreakpoint);
            mockBreakpointLocation.GetId().Returns(ID);
            mockBreakpointLocation.GetAddress().Returns(mockAddress);
            mockprogram         = Substitute.For <IDebugProgram2>();
            mockDocumentContext = Substitute.For <IDebugDocumentContext2>();
            mockDocumentContext.GetName(enum_GETNAME_TYPE.GN_NAME, out name).Returns(
                x =>
            {
                x[1] = NAME;
                return(VSConstants.S_OK);
            });
            mockBreakpointResolution   = Substitute.For <IDebugBreakpointResolution2>();
            mockDocumentContextFactory = Substitute.For <DebugDocumentContext.Factory>();
            mockDocumentContextFactory.Create(lineEntry).Returns(mockDocumentContext);
            mockCodeContext        = Substitute.For <IDebugCodeContext2>();
            mockCodeContextFactory = Substitute.For <DebugCodeContext.Factory>();
            mockCodeContextFactory.Create(ADDRESS, NAME,
                                          mockDocumentContext, Guid.Empty).Returns(mockCodeContext);
            mockBreakpointResolutionFactory =
                Substitute.For <DebugBreakpointResolution.Factory>();
            mockBreakpointResolutionFactory.Create(mockCodeContext, mockprogram).Returns(
                mockBreakpointResolution);
            boundBreakpointFactory = new DebugBoundBreakpoint.Factory(mockDocumentContextFactory,
                                                                      mockCodeContextFactory, mockBreakpointResolutionFactory);
            boundBreakpoint = boundBreakpointFactory.Create(
                mockPendingBreakpoint, mockBreakpointLocation, mockprogram, Guid.Empty);
        }
Ejemplo n.º 5
0
        // Constructor with factories for tests.
        DebugBoundBreakpoint(DebugDocumentContext.Factory documentContextFactory,
                             DebugCodeContext.Factory codeContextFactory,
                             DebugBreakpointResolution.Factory breakpointResolutionFactory,
                             IDebugPendingBreakpoint2 pendingBreakpoint,
                             SbBreakpointLocation breakpointLocation, IDebugProgram2 program,
                             Guid languageGuid)
        {
            _pendingBreakpoint  = pendingBreakpoint;
            _breakpointLocation = breakpointLocation;

            _enabled             = true;
            _deleted             = false;
            _disabledByPassCount = false;

            SbAddress address = breakpointLocation.GetAddress();

            if (address != null)
            {
                LineEntryInfo          lineEntry       = address.GetLineEntry();
                IDebugDocumentContext2 documentContext = null;
                string name = "";

                // |lineEntry| is null if the breakpoint is set on an external function.
                if (lineEntry != null)
                {
                    documentContext = documentContextFactory.Create(lineEntry);
                    documentContext.GetName(enum_GETNAME_TYPE.GN_NAME, out name);
                }
                IDebugCodeContext2 codeContext = codeContextFactory.Create(
                    breakpointLocation.GetLoadAddress(), name, documentContext, languageGuid);
                _breakpointResolution = breakpointResolutionFactory.Create(codeContext, program);
            }
            else
            {
                Trace.WriteLine("Warning: Unable to obtain address from breakpoint location." +
                                " No breakpoint resolution created.");
            }
        }