Example #1
0
        public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort)
        {
            ppPort = null;

            string name;

            pRequest.GetPortName(out name);

            Match m = _portNameRegex.Match(name);

            if (!m.Success)
            {
                return(Marshal.GetHRForException(new FormatException()));
            }

            string secret   = m.Groups["secret"].Value;
            string hostName = m.Groups["hostName"].Value;

            ushort portNum = _defaultPort;

            if (m.Groups["portNum"].Success)
            {
                if (!ushort.TryParse(m.Groups["portNum"].Value, out portNum))
                {
                    return(Marshal.GetHRForException(new FormatException()));
                }
            }

            var port = new LuaRemoteDebugPort(this, hostName, portNum, secret, _useSsl);

            ppPort = port;
            return(0);
        }
Example #2
0
 public LuaRemoteDebugProcess(LuaRemoteDebugPort port, int pid, string exe, string username, string version)
 {
     this._port     = port;
     this._pid      = (pid == 0) ? 1 : pid; // attach dialog won't show processes with pid==0
     this._username = username;
     this._exe      = string.IsNullOrEmpty(exe) ? "<lua>" : exe;
     this._version  = version;
 }
        private static LuaRemoteDebugProcess Connect(LuaRemoteDebugPort port)
        {
            LuaRemoteDebugProcess process = null;

/*
 *          // Connect to the remote debugging server and obtain process information. If any errors occur, display an error dialog, and keep
 *          // trying for as long as user clicks "Retry".
 *          while (true) {
 *              Socket socket;
 *              Stream stream;
 *              // Process information is not sensitive, so ignore any SSL certificate errors, rather than bugging the user with warning dialogs.
 *              var err = LuaRemoteProcess.TryConnect(port.HostName, port.PortNumber, port.Secret, port.UseSsl, SslErrorHandling.Ignore, out socket, out stream);
 *              using (stream) {
 *                  if (err == ConnErrorMessages.None) {
 *                      try {
 *                          stream.Write(LuaRemoteProcess.InfoCommandBytes);
 *                          int pid = stream.ReadInt32();
 *                          string exe = stream.ReadString();
 *                          string username = stream.ReadString();
 *                          string version = stream.ReadString();
 *                          process = new LuaRemoteDebugProcess(port, pid, exe, username, version);
 *                          break;
 *                      } catch (IOException) {
 *                          err = ConnErrorMessages.RemoteNetworkError;
 *                      }
 *                  }
 *
 *                  if (err != ConnErrorMessages.None) {
 *                      string errText;
 *                      switch (err) {
 *                          case ConnErrorMessages.RemoteUnsupportedServer:
 *                              errText = string.Format("Remote server at '{0}:{1}' is not a Lua Tools for Visual Studio remote debugging server, or its version is not supported.", port.HostName, port.PortNumber);
 *                              break;
 *                          case ConnErrorMessages.RemoteSecretMismatch:
 *                              errText = string.Format("Secret '{0}' did not match the server secret at '{1}:{2}'. Make sure that the secret is specified correctly in the Qualifier textbox, e.g. 'secret@localhost:5678'.", port.Secret, port.HostName, port.PortNumber);
 *                              break;
 *                          case ConnErrorMessages.RemoteSslError:
 *                              // User has already got a warning dialog and clicked "Cancel" on that, so no further prompts are needed.
 *                              return null;
 *                          default:
 *                              errText = string.Format("Could not connect to remote Lua process at '{0}:{1}'. Make sure that the process is running, and has called ptvsd.enable_attach()", port.HostName, port.PortNumber);
 *                              break;
 *                      }
 *
 *                      DialogResult dlgRes = MessageBox.Show(errText, null, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
 *                      if (dlgRes != DialogResult.Retry) {
 *                          break;
 *                      }
 *                  }
 *              }
 *          }
 *
 */
            return(process);
        }
 public LuaRemoteEnumDebugProcesses(LuaRemoteDebugPort port)
     : base(Connect(port))
 {
     this._port = port;
 }