public void Init(ITransportCallback transportCallback, LaunchOptions options) { SerialLaunchOptions serialOptions = (SerialLaunchOptions)options; string line; bool bLoggedIn = false; _bQuit = false; _callback = transportCallback; _thread = new Thread(TransportLoop); _port.Open(); Echo(""); for (;;) { line = GetLine(); if (line != null) { if (line.EndsWith("login: "******"root"); Debug.WriteLine("DBG:Logged into device"); bLoggedIn = true; } else if (line.EndsWith("$ ", StringComparison.Ordinal)) { Debug.WriteLine("DBG:Command prompt detected"); break; } } } Debug.WriteLine("DBG:GDB is starting"); _thread.Start(); }
public void Init(ITransportCallback transportCallback, LaunchOptions options, Logger logger, HostWaitLoop waitLoop = null) { _launchOptions = (UnixShellPortLaunchOptions)options; _callback = transportCallback; _logger = logger; _startRemoteDebuggerCommand = _launchOptions.StartRemoteDebuggerCommand; if (_launchOptions.DebuggerMIMode == MIMode.Clrdbg) { if (!UnixShellPortLaunchOptions.HasSuccessfulPreviousLaunch(_launchOptions)) { waitLoop?.SetText(MICoreResources.Info_InstallingDebuggerOnRemote); try { Task.Run(() => DownloadAndCopyFileToRemote(_launchOptions.DebuggerInstallationDirectory, _launchOptions.GetClrDbgUrl)).Wait(); } catch (Exception e) { // Even if downloading & copying to remote fails, we will still try to invoke the script as it might already exist. string message = String.Format(CultureInfo.CurrentUICulture, MICoreResources.Warning_DownloadingClrDbgToRemote, e.Message); _callback.AppendToInitializationLog(message); } } } _callback.AppendToInitializationLog(string.Format(CultureInfo.CurrentUICulture, MICoreResources.Info_StartingUnixCommand, _startRemoteDebuggerCommand)); _launchOptions.UnixPort.BeginExecuteAsyncCommand(_startRemoteDebuggerCommand, this, out _asyncCommand); }
public virtual void Init(ITransportCallback transportCallback, LaunchOptions options, Logger logger) { Logger = logger; _callback = transportCallback; InitStreams(options, out _reader, out _writer); StartThread(GetThreadName()); }
public void Init(ITransportCallback transportCallback, LaunchOptions options, Logger logger, HostWaitLoop waitLoop = null) { _launchOptions = (UnixShellPortLaunchOptions)options; _callback = transportCallback; _logger = logger; _startRemoteDebuggerCommand = _launchOptions.StartRemoteDebuggerCommand; if (_launchOptions.DebuggerMIMode == MIMode.Clrdbg) { if (!UnixShellPortLaunchOptions.HasSuccessfulPreviousLaunch(_launchOptions)) { waitLoop?.SetText(MICoreResources.Info_InstallingDebuggerOnRemote); try { Task.Run(() => DownloadAndCopyFileToRemote(_launchOptions.DebuggerInstallationDirectory, _launchOptions.GetClrDbgUrl)).Wait(); } catch (Exception e) { // Even if downloading & copying to remote fails, we will still try to invoke the script as it might already exist. string message = String.Format(CultureInfo.CurrentUICulture, MICoreResources.Warning_DownloadingClrDbgToRemote, e.Message); _callback.AppendToInitializationLog(message); } } } _callback.AppendToInitializationLog(string.Format(CultureInfo.CurrentUICulture, MICoreResources.Info_StartingUnixCommand, _startRemoteDebuggerCommand)); _launchOptions.UnixPort.BeginExecuteAsyncCommand(_startRemoteDebuggerCommand, true, this, out _asyncCommand); }
public virtual void Init(ITransportCallback transportCallback, LaunchOptions options, Logger logger, HostWaitLoop waitLoop = null) { Logger = logger; _callback = transportCallback; InitStreams(options, out _reader, out _writer); StartThread(GetThreadName()); }
public void Init(IPEndPoint endPoint, ITransportCallback transportCallback) { _endPoint = endPoint; _callback = transportCallback; InitStreams(); StartThread("MI.TcpTransport"); }
public void Init(ITransportCallback transportCallback, LaunchOptions options, Logger logger, HostWaitLoop waitLoop = null) { _launchOptions = (UnixShellPortLaunchOptions)options; _callback = transportCallback; _logger = logger; _startRemoteDebuggerCommand = _launchOptions.StartRemoteDebuggerCommand; _callback.AppendToInitializationLog(string.Format(CultureInfo.CurrentCulture, MICoreResources.Info_StartingUnixCommand, _startRemoteDebuggerCommand)); _launchOptions.UnixPort.BeginExecuteAsyncCommand(_startRemoteDebuggerCommand, runInShell: true, this, out _asyncCommand); }
public void Init(ITransportCallback transportCallback, LaunchOptions options) { _bQuit = false; _callback = transportCallback; _commandEvent = new AutoResetEvent(false); _reader = new StreamReader(File.OpenRead(_filename)); _thread = new Thread(TransportLoop); _nextCommand = null; _thread.Start(); }
public void Init(ITransportCallback transportCallback, LaunchOptions options) { _launchTimeout = ((LocalLaunchOptions)options).ServerLaunchTimeout; _serverTransport.Init(transportCallback, options); WaitForStart(); if (!_clientTransport.IsClosed) { _clientTransport.Init(transportCallback, options); } }
public void Register <TMsg>(ITransportCallback <TMsg> callback, MyTransportMessageEnum messageType) where TMsg : struct { var msgId = GetId <TMsg>(messageType); m_callbacks.Add(msgId.Item1, new CallbackInfo() { Callback = callback, MessageId = msgId.Item1, SendType = msgId.Item2, MessageType = typeof(TMsg), TransportEnum = messageType }); }
public void Init(ITransportCallback transportCallback, LaunchOptions options, Logger logger, HostWaitLoop waitLoop = null) { _launchTimeout = ((LocalLaunchOptions)options).ServerLaunchTimeout; _serverTransport.Init(transportCallback, options, logger, waitLoop); WaitForStart(); if (!_clientTransport.IsClosed) { _clientTransport.Init(transportCallback, options, logger, waitLoop); } }
public void Init(ITransportCallback transportCallback, LaunchOptions options) { _launchTimeout = ((LocalLaunchOptions)options).ServerLaunchTimeout; _serverTransport.Init(transportCallback, options); WaitForStart(); if (!_clientTransport.IsClosed) { _clientTransport.Init(transportCallback, options); } }
public void Init(ITransportCallback transportCallback, LaunchOptions options, Logger logger, HostWaitLoop waitLoop = null) { _launchTimeout = ((LocalLaunchOptions)options).ServerLaunchTimeout; _serverTransport.Init(transportCallback, options, logger, waitLoop); WaitForStart(); if (!_clientTransport.IsClosed) { _clientTransport.Init(transportCallback, options, logger, waitLoop); } }
public void Init(ITransportCallback transportCallback, LaunchOptions options, Logger logger) { _bQuit = false; _callback = transportCallback; _commandEvent = new AutoResetEvent(false); _reader = new StreamReader(File.OpenRead(_filename)); _thread = new Thread(TransportLoop); _nextCommand = null; _thread.Start(); }
public void Init(ITransportCallback transportCallback, LaunchOptions options, Logger logger, HostWaitLoop waitLoop = null) { _launchOptions = (UnixShellPortLaunchOptions)options; _callback = transportCallback; _logger = logger; _startRemoteDebuggerCommand = _launchOptions.StartRemoteDebuggerCommand; waitLoop?.SetText(MICoreResources.Info_InstallingDebuggerOnRemote); _callback.AppendToInitializationLog("Starting unix command: " + _startRemoteDebuggerCommand); _launchOptions.UnixPort.BeginExecuteAsyncCommand(_startRemoteDebuggerCommand, this, out _asyncCommand); }
public void SendMessage <TMessage>(ref TMessage msg, List <ulong> recipients, MyTransportMessageEnum messageType, bool includeSelf) where TMessage : struct { if (recipients.Count == 0 && !includeSelf) { return; } var msgId = GetId <TMessage>(messageType); ITransportCallback <TMessage> c = (ITransportCallback <TMessage>)m_callbacks[msgId.Item1].Callback; P2PMessageEnum sendType = msgId.Item2; m_sendStream.Position = 0; m_sendStream.WriteByte((byte)MyMessageId.OLD_GAME_EVENT); m_sendStream.WriteUShort(msgId.Item1); c.Write(m_sendStream, ref msg); const int mtu = 1200; if ((sendType == P2PMessageEnum.Unreliable || sendType == P2PMessageEnum.UnreliableNoDelay) && m_sendStream.Position > mtu) { Debug.Fail("Sending unreliable message as reliable, because it's bigger than MTU, message type: " + FindDebugName(msgId.Item1)); sendType = P2PMessageEnum.ReliableWithBuffering; } if (sendType == P2PMessageEnum.Reliable) // Always with buffering { sendType = P2PMessageEnum.ReliableWithBuffering; } Stats.Network.WriteFormat(StatName <TMessage> .Name, (int)m_sendStream.Position, VRage.Stats.MyStatTypeEnum.CounterSum, 1000, 0); if (!MySandboxGame.IsDedicated) { LogStats(SendStats, TypeNameHelper <TMessage> .Name, (int)m_sendStream.Position, recipients.Count, msgId.Item2); } if (includeSelf) { MyTrace.Send(TraceWindow.Multiplayer, "Loopback: " + typeof(TMessage).Name); m_loopback(m_sendStream.Data, (int)m_sendStream.Position, Sync.MyId); } foreach (var sendTo in recipients) { Debug.Assert(Sync.MultiplayerActive); TraceMessage("Sending: ", msg.ToString(), sendTo, m_sendStream.Position, sendType); SendMessage(m_sendStream, sendType, sendTo, m_channel); } }
public void Init(ITransportCallback transportCallback, LaunchOptions options) { SerialLaunchOptions serialOptions = (SerialLaunchOptions)options; string line; bool bLoggedIn = false; _bQuit = false; _callback = transportCallback; _thread = new Thread(TransportLoop); _port.Open(); Echo(""); for (;;) { line = GetLine(); if (line != null) { if (line.EndsWith("login: "******"root"); Debug.WriteLine("DBG:Logged into device"); bLoggedIn = true; } else if (line.EndsWith("$ ", StringComparison.Ordinal)) { Debug.WriteLine("DBG:Command prompt detected"); break; } } } Debug.WriteLine("DBG:GDB is starting"); _thread.Start(); }
public override async void Init(ITransportCallback transportCallback, LaunchOptions options, Logger logger, HostWaitLoop waitLoop = null) { LocalLaunchOptions localOptions = options as LocalLaunchOptions; Encoding encNoBom = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false); string commandPipeName; string outputPipeName; string pidPipeName; List <string> cmdArgs = new List <string>(); string windowtitle = FormattableString.Invariant($"cppdbg: {Path.GetFileName(options.ExePath)}"); if (PlatformUtilities.IsWindows()) { // Create Windows Named pipes commandPipeName = Utilities.GetMIEngineTemporaryFilename("In"); outputPipeName = Utilities.GetMIEngineTemporaryFilename("Out"); pidPipeName = Utilities.GetMIEngineTemporaryFilename("Pid"); string errorPipeName = Utilities.GetMIEngineTemporaryFilename("Error"); NamedPipeServerStream inputToDebugger = new NamedPipeServerStream(commandPipeName, PipeDirection.Out, 1, PipeTransmissionMode.Byte); NamedPipeServerStream outputFromDebugger = new NamedPipeServerStream(outputPipeName, PipeDirection.In, 1, PipeTransmissionMode.Byte); NamedPipeServerStream errorFromDebugger = new NamedPipeServerStream(errorPipeName, PipeDirection.In, 1, PipeTransmissionMode.Byte); NamedPipeServerStream pidPipe = new NamedPipeServerStream(pidPipeName, PipeDirection.In, 1, PipeTransmissionMode.Byte); _pidReader = new StreamReader(pidPipe, encNoBom, false, UnixUtilities.StreamBufferSize); string thisModulePath = typeof(RunInTerminalTransport).GetTypeInfo().Assembly.ManifestModule.FullyQualifiedName; string launchCommand = Path.Combine(Path.GetDirectoryName(thisModulePath), "WindowsDebugLauncher.exe"); if (!File.Exists(launchCommand)) { string errorMessage = string.Format(CultureInfo.CurrentCulture, MICoreResources.Error_InternalFileMissing, launchCommand); transportCallback.OnStdErrorLine(errorMessage); transportCallback.OnDebuggerProcessExit(null); return; } cmdArgs.Add(launchCommand); cmdArgs.Add("--stdin=" + commandPipeName); cmdArgs.Add("--stdout=" + outputPipeName); cmdArgs.Add("--stderr=" + errorPipeName); cmdArgs.Add("--pid=" + pidPipeName); cmdArgs.Add("--dbgExe=" + localOptions.MIDebuggerPath); cmdArgs.Add(localOptions.GetMiDebuggerArgs()); _waitForConnection = Task.WhenAll( inputToDebugger.WaitForConnectionAsync(), outputFromDebugger.WaitForConnectionAsync(), errorFromDebugger.WaitForConnectionAsync(), pidPipe.WaitForConnectionAsync()); _commandStream = new StreamWriter(inputToDebugger, encNoBom); _outputStream = new StreamReader(outputFromDebugger, encNoBom, false, UnixUtilities.StreamBufferSize); _errorStream = new StreamReader(errorFromDebugger, encNoBom, false, UnixUtilities.StreamBufferSize); } else { // Do Linux style pipes commandPipeName = UnixUtilities.MakeFifo(identifier: "In", logger: logger); outputPipeName = UnixUtilities.MakeFifo(identifier: "Out", logger: logger); pidPipeName = UnixUtilities.MakeFifo(identifier: "Pid", logger: logger); // Create filestreams FileStream stdInStream = new FileStream(commandPipeName, FileMode.Open); FileStream stdOutStream = new FileStream(outputPipeName, FileMode.Open); _pidReader = new StreamReader(new FileStream(pidPipeName, FileMode.Open), encNoBom, false, UnixUtilities.StreamBufferSize); string debuggerCmd = UnixUtilities.GetDebuggerCommand(localOptions); // Default working directory is next to the app string debuggeeDir; if (Path.IsPathRooted(options.ExePath) && File.Exists(options.ExePath)) { debuggeeDir = Path.GetDirectoryName(options.ExePath); } else { // If we don't know where the app is, default to HOME, and if we somehow can't get that, go with the root directory. debuggeeDir = Environment.GetEnvironmentVariable("HOME"); if (string.IsNullOrEmpty(debuggeeDir)) { debuggeeDir = "/"; } } string dbgCmdScript = Path.Combine(Path.GetTempPath(), Utilities.GetMIEngineTemporaryFilename(identifier: "Cmd")); string launchDebuggerCommand = UnixUtilities.LaunchLocalDebuggerCommand( debuggeeDir, commandPipeName, outputPipeName, pidPipeName, dbgCmdScript, debuggerCmd, localOptions.GetMiDebuggerArgs()); logger?.WriteTextBlock("DbgCmd:", launchDebuggerCommand); using (FileStream dbgCmdStream = new FileStream(dbgCmdScript, FileMode.CreateNew)) using (StreamWriter dbgCmdWriter = new StreamWriter(dbgCmdStream, encNoBom) { AutoFlush = true }) { dbgCmdWriter.WriteLine("#!/bin/sh"); dbgCmdWriter.Write(launchDebuggerCommand); dbgCmdWriter.Flush(); } if (PlatformUtilities.IsOSX()) { string osxLaunchScript = GetOSXLaunchScript(); // Call osascript with a path to the AppleScript. The apple script takes 2 parameters: a title for the terminal and the launch script. cmdArgs.Add("/usr/bin/osascript"); cmdArgs.Add(osxLaunchScript); cmdArgs.Add(FormattableString.Invariant($"\"{windowtitle}\"")); cmdArgs.Add(FormattableString.Invariant($"sh {dbgCmdScript} ;")); // needs a semicolon because this command is running through the launchscript. } else { cmdArgs.Add("sh"); cmdArgs.Add(dbgCmdScript); } _outputStream = new StreamReader(stdOutStream, encNoBom, false, UnixUtilities.StreamBufferSize); _commandStream = new StreamWriter(stdInStream, encNoBom); } RunInTerminalLauncher launcher = new RunInTerminalLauncher(windowtitle, localOptions.Environment); launcher.Launch( cmdArgs, localOptions.UseExternalConsole, LaunchSuccess, (error) => { transportCallback.OnStdErrorLine(error); throw new InvalidOperationException(error); }, logger); logger?.WriteLine("Wait for connection completion."); if (_waitForConnection != null) { // Add a timeout for waiting for connection - 20 seconds Task waitOrTimeout = Task.WhenAny(_waitForConnection, Task.Delay(20000)); await waitOrTimeout; if (waitOrTimeout.Status != TaskStatus.RanToCompletion) { string errorMessage = String.Format(CultureInfo.CurrentCulture, MICoreResources.Error_DebuggerInitializeFailed_NoStdErr, "WindowsDebugLauncher.exe"); transportCallback.OnStdErrorLine(errorMessage); transportCallback.OnDebuggerProcessExit(null); return; } } base.Init(transportCallback, options, logger, waitLoop); }
public void Init(ITransportCallback transportCallback, LaunchOptions options) { _callback = transportCallback; InitStreams(options, out _reader, out _writer); StartThread(GetThreadName()); }
public void Init(ITransportCallback transportCallback, LaunchOptions options) { _callback = transportCallback; InitStreams(options, out _reader, out _writer); StartThread(GetThreadName()); }