示例#1
0
        void IDebugUnixShellCommandCallback.OnOutputLine(string line)
        {
            if (!_debuggerLaunched)
            {
                if (_launchOptions.DebuggerMIMode != MIMode.Clrdbg)
                {
                    _debuggerLaunched = true;
                }
                else
                {
                    if (line != null && line.StartsWith(ErrorPrefix, System.StringComparison.OrdinalIgnoreCase))
                    {
                        _callback.OnStdErrorLine(line.Substring(ErrorPrefix.Length).Trim());
                    }

                    if (line.Equals("Info: Launching clrdbg"))
                    {
                        _debuggerLaunched = true;
                        UnixShellPortLaunchOptions.SetSuccessfulLaunch(_launchOptions);
                    }
                }
            }

            if (!string.IsNullOrEmpty(line))
            {
                _callback.OnStdOutLine(line);
            }

            _logger?.WriteLine("->" + line);
            _logger?.Flush();
        }
        private void TransportLoop()
        {
            while (!_bQuit)
            {
                string line = GetLine();
                LiveLogger.WriteLine("->" + line);

                try
                {
                    if (!String.IsNullOrWhiteSpace(line))
                    {
                        _callback.OnStdOutLine(line);
                    }
                }
                catch (ObjectDisposedException)
                {
                    Debug.Assert(_bQuit);
                    break;
                }
            }
            if (!_bQuit)
            {
                OnReadStreamAborted();
            }
        }
示例#3
0
        private void TransportLoop()
        {
            _lineNumber = 0;

            // discard first line
            _reader.ReadLine();
            _lineNumber = 1;

            while (!_bQuit)
            {
                string line = _reader.ReadLine();
                if (line == null)
                {
                    break;
                }
                line = line.TrimEnd();
                _lineNumber++;
                Debug.WriteLine("#{0}:{1}", _lineNumber, line);

                if (line[0] == '-')
                {
                    _commandEvent.WaitOne();               // wait for a command
                    if (line != _nextCommand)
                    {
                        Debug.Assert(false, "Unexpected command sent " + line + " expecting " + _nextCommand);
                        break;
                    }
                    _nextCommand = null;
                }
                else if (!line.StartsWith("-", StringComparison.Ordinal))
                {
                    _callback.OnStdOutLine(line);
                }
            }
        }
示例#4
0
        private void TransportLoop()
        {
            string line;

            while (!_bQuit)
            {
                line = GetLine();
                if (line == null)
                {
                    break;
                }

                line = line.TrimEnd();

                Logger.WriteLine("->" + line);

                if (!String.IsNullOrWhiteSpace(line) && !line.StartsWith("-", StringComparison.Ordinal))
                {
                    try
                    {
                        _callback.OnStdOutLine(line);
                    }
                    catch (ObjectDisposedException)
                    {
                        Debug.Assert(_bQuit);
                        break;
                    }
                }
            }
            if (!_bQuit)
            {
                OnReadStreamAborted();
            }
        }
        void IDebugUnixShellCommandCallback.OnOutputLine(string line)
        {
            if (!_debuggerLaunched)
            {
                _debuggerLaunched = true;
            }

            if (!string.IsNullOrEmpty(line))
            {
                _callback.OnStdOutLine(line);
            }

            _logger?.WriteLine("->" + line);
            _logger?.Flush();
        }
示例#6
0
        private void TransportLoop()
        {
            string line;

            while (!_bQuit)
            {
                line = GetLine();
                if (line != null)
                {
                    if (line == _lastCommand)
                    {
                        // Commands get echoed back, so ignore them
                        continue;
                    }
                    _lastCommand = null;
                    line         = line.TrimEnd();
                    _callback.OnStdOutLine(line);
                }
            }
            _port.Close();
            _port = null;
        }
示例#7
0
        private void TransportLoop()
        {
            try
            {
                while (!_bQuit)
                {
                    string line = GetLine();
                    if (line == null)
                    {
                        break;
                    }

                    line = line.TrimEnd();
                    Logger?.WriteLine("->" + line);
                    Logger?.Flush();

                    try
                    {
                        if (_filterStdout)
                        {
                            line = FilterLine(line);
                        }
                        if (!String.IsNullOrWhiteSpace(line) && !line.StartsWith("-", StringComparison.Ordinal))
                        {
                            _callback.OnStdOutLine(line);
                        }
                    }
                    catch (ObjectDisposedException)
                    {
                        Debug.Assert(_bQuit);
                        break;
                    }
                }
                if (!_bQuit)
                {
                    OnReadStreamAborted();
                }
            }
            finally
            {
                lock (_locker)
                {
                    _bQuit = true;
                    _streamReadCancellationTokenSource.Dispose();

                    // If we are shutting down without notice from the debugger (e.g., the terminal
                    // where the debugger was hosted was closed), at this point it's possible that
                    // there is a thread blocked doing a read() syscall.
                    ForceDisposeStreamReader(_reader);

                    try
                    {
                        _writer.Dispose();
                    }
                    catch
                    {
                        // This can fail flush side effects if the debugger goes down. When this happens we don't want
                        // to crash OpenDebugAD7/VS. Stack:
                        //   System.IO.UnixFileStream.WriteNative(Byte[] array, Int32 offset, Int32 count)
                        //   System.IO.UnixFileStream.FlushWriteBuffer()
                        //   System.IO.UnixFileStream.Dispose(Boolean disposing)
                        //   System.IO.FileStream.Dispose(Boolean disposing)
                        //   System.IO.Stream.Close()
                        //   System.IO.StreamWriter.Dispose(Boolean disposing)
                        //   System.IO.TextWriter.Dispose()
                    }
                }
            }
        }