コード例 #1
0
        public void Setup()
        {
            mockMemoryMappedFileFactory = Substitute.For <MemoryMappedFileFactory>();
            mockMemoryMappedFile        = Substitute.For <IMemoryMappedFile>();

            // The first session should get a memory mapped file on the first try.
            mockMemoryMappedFileFactory.CreateNew(FILE_PREFIX + 0, Arg.Any <long>()).Returns(
                mockMemoryMappedFile);
            transportSessionFactory = new LldbTransportSession.Factory(mockMemoryMappedFileFactory);
            transportSession        = transportSessionFactory.Create();
        }
コード例 #2
0
        public void StartPreGameNoSession()
        {
            SshTarget sshTargetNull = null;

            mockMemoryMappedFileFactory.CreateNew(Arg.Any <string>(), Arg.Any <long>())
            .Returns((IMemoryMappedFile)null);
            Assert.Throws <YetiDebugTransportException>(
                () => yetiDebugTransport.StartPreGame(LaunchOption.AttachToCore, false, false,
                                                      sshTargetNull, out _, out _));
            // Early errors don't cause aborts.
            Assert.IsNull(abortError);
        }
コード例 #3
0
        public void MultipleSessions()
        {
            // The second session should throw an exception when creating the first file (because it
            // already exists), and get a memory mapped file on the second try.
            mockMemoryMappedFileFactory.CreateNew(FILE_PREFIX + 0, Arg.Any <long>()).Returns(x =>
            {
                throw new System.IO.IOException();
            });
            mockMemoryMappedFileFactory.CreateNew(FILE_PREFIX + 1, Arg.Any <long>()).Returns(
                mockMemoryMappedFile);
            var transportSession2 = transportSessionFactory.Create();

            Assert.AreNotEqual(LldbTransportSession.INVALID_SESSION_ID,
                               transportSession.GetSessionId());
            Assert.AreNotEqual(LldbTransportSession.INVALID_SESSION_ID,
                               transportSession2.GetSessionId());
            Assert.AreNotEqual(transportSession.GetSessionId(), transportSession2.GetSessionId());

            // Make sure the port numbers are different for the two sessions.
            Assert.AreNotEqual(transportSession.GetLocalDebuggerPort(),
                               transportSession2.GetLocalDebuggerPort());
            Assert.AreNotEqual(transportSession.GetReservedLocalAndRemotePort(),
                               transportSession2.GetReservedLocalAndRemotePort());
        }
コード例 #4
0
 int FindAvailableSessionId()
 {
     for (int i = 0; i < MAX_SESSIONS; i++)
     {
         try
         {
             // Create a memory mapped file in system memory, which will exist as long as
             // the debug engine is running.  They will either be cleaned up when we call
             // dispose on this object, or when the process stops.  These files let transport
             // sessions 'reserve' a system unique session ID.  If the file exists it will
             // throw a System.IO.IOException, and we can try the next one.
             memoryMappedFile = memoryMappedFileFactory.CreateNew(FILE_PREFIX + i,
                                                                  sizeof(byte));
             return(i);
         }
         catch (System.IO.IOException)
         {
         }
     }
     return(INVALID_SESSION_ID);
 }