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); }
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 JRemoteDebugPort(this, hostName, portNum, secret, _useSsl); ppPort = port; return 0; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected int CreatePort(IDebugPortRequest2 portRequest, out IDebugPort2 port) { LoggingUtils.PrintFunction(); try { string requestPortName; LoggingUtils.RequireOk(portRequest.GetPortName(out requestPortName)); if (string.IsNullOrWhiteSpace(requestPortName)) { throw new InvalidOperationException("Invalid/empty port name"); } AndroidDevice device = AndroidAdb.GetConnectedDeviceById(requestPortName); if (device == null) { throw new InvalidOperationException("Failed to find a device with the name: " + requestPortName); } port = new DebuggeePort(this, device); return(Constants.S_OK); } catch (Exception e) { LoggingUtils.HandleException(e); port = null; return(Constants.E_FAIL); } }
/// <inheritdoc /> public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { string portName; var result = pRequest.GetPortName(out portName); ppPort = null; return(VSConstants.S_OK); }
public AD7Port(AD7PortSupplier supplier, IDebugPortRequest2 request) { this.supplier = supplier; this.request = request; request.GetPortName(out portName); AD7Process p = new AD7Process(this); processes.Add(p); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region IDebugPortSupplier2 Members //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { // // Attempt to find a port matching the requested name, refreshes and iterates updated ports via EnumPorts. // LoggingUtils.PrintFunction(); try { string requestPortName; LoggingUtils.RequireOk(CanAddPort()); LoggingUtils.RequireOk(pRequest.GetPortName(out requestPortName)); ppPort = null; foreach (KeyValuePair <Guid, IDebugPort2> keyPair in m_registeredPorts) { string portName; IDebugPort2 registeredPort = keyPair.Value; LoggingUtils.RequireOk(registeredPort.GetPortName(out portName)); if (portName.Equals(requestPortName)) { ppPort = registeredPort; break; } } if (ppPort == null) { Guid portId; ppPort = CreatePort(pRequest); LoggingUtils.RequireOk(ppPort.GetPortId(out portId)); m_registeredPorts.Add(portId, ppPort); } return(Constants.S_OK); } catch (Exception e) { LoggingUtils.HandleException(e); ppPort = null; return(Constants.E_FAIL); } }
/// <summary> /// Add a port. /// </summary> public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { DLog.Debug(DContext.VSDebuggerComCall, "DebugPortSupplier.AddPort"); string name; ErrorHandler.ThrowOnFailure(pRequest.GetPortName(out name)); var port = new DebugPort(this, pRequest); ports[name] = port; ppPort = port; return VSConstants.S_OK; }
// Qualifier for our transport has one of the following formats: // // tcp[s]://[secret@]hostname[:port] // ws[s]://[secret@]hostname[:port][/path] // [secret@]hostname[:port] // // 'tcp' and 'tcps' are for connecting directly to ptvsd; 'ws' and 'wss' are for connecting through WebSocketProxy. // The versions ending with '...s' use SSL to secure the connection. If no scheme is specified, 'tcp' is the default. // If port is not specified, it defaults to 5678 for 'tcp' and 'tcps', 80 for 'ws' and 443 for 'wss'. public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { ppPort = null; string name; pRequest.GetPortName(out name); // Support old-style 'hostname:port' format, as well. if (!name.Contains("://")) { name = "tcp://" + name; } var uri = new Uri(name, UriKind.Absolute); var transport = DebuggerTransportFactory.Get(uri); if (transport == null) { MessageBox.Show( Strings.RemoteUnrecognizedDebuggingTransport.FormatUI(uri.Scheme), Strings.ProductTitle, MessageBoxButtons.OK, MessageBoxIcon.Error ); return(VSConstants.E_FAIL); } var validationError = transport.Validate(uri); if (validationError != null) { return(validationError.HResult); } var port = new PythonRemoteDebugPort(this, pRequest, uri, DebugLog); if (PythonDebugOptionsServiceHelper.Options.UseLegacyDebugger) { // Validate connection early. Debugger automation (DTE) objects are not consistent in error checking from this // point on, so errors reported from EnumProcesses and further calls may be ignored and treated as successes // (with empty result). Reporting an error here works around that. int hr = port.EnumProcesses(out IEnumDebugProcesses2 processes); if (hr < 0) { return(hr); } } ppPort = port; _ports.Add(port); return(VSConstants.S_OK); }
public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { ppPort = null; string pName; pRequest.GetPortName(out pName); ppPort = new RemoteDebugPort(this, pRequest, pName); return(VSConstants.S_OK); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected DebuggeePort CreatePort(IDebugPortRequest2 portRequest) { AndroidAdb.Refresh(); string requestPortName; LoggingUtils.RequireOk(portRequest.GetPortName(out requestPortName)); AndroidDevice device = AndroidAdb.GetConnectedDeviceById(requestPortName); return(new DebuggeePort(this, device)); }
public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { string name; Marshal.ThrowExceptionForHR(pRequest.GetPortName(out name)); if (name != PortName) { ppPort = null; return VSConstants.E_INVALIDARG; } ppPort = new DebugPort(this, pRequest); return VSConstants.S_OK; }
/// <summary> /// Add a port. /// </summary> public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { DLog.Debug(DContext.VSDebuggerComCall, "DebugPortSupplier.AddPort"); string name; ErrorHandler.ThrowOnFailure(pRequest.GetPortName(out name)); var port = new DebugPort(this, pRequest); ports[name] = port; ppPort = port; return(VSConstants.S_OK); }
int IDebugPortSupplier2.AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { string portName; if (ErrorHandler.Succeeded(pRequest.GetPortName(out portName))) { ppPort = new RemoteDebugPort(this, pRequest, portName); return(VSConstants.S_OK); } ppPort = null; return(VSConstants.E_NOTIMPL); }
new public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { string name; pRequest.GetPortName(out name); ppPort = FindPort(name); if (ppPort != null) { return(COM_HResults.S_OK); } return(COM_HResults.E_FAIL); }
public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { string name; Marshal.ThrowExceptionForHR(pRequest.GetPortName(out name)); if (name != PortName) { ppPort = null; return(VSConstants.E_INVALIDARG); } ppPort = new DebugPort(this, pRequest); return(VSConstants.S_OK); }
public int AddPort(IDebugPortRequest2 request, out IDebugPort2 port) { string name; HR.Check(request.GetPortName(out name)); AD7Port newPort = new AD7Port(this, name, isInAddPort: true); if (newPort.IsConnected) { port = newPort; return HR.S_OK; } port = null; return HR.E_REMOTE_CONNECT_USER_CANCELED; }
// Qualifier for our transport is parsed either as a tcp://, ws:// or ws:// URI, // or as 'hostname:port', where ':port' is optional. public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { ppPort = null; string name; pRequest.GetPortName(out name); // Support old-style 'hostname:port' format, as well. if (!name.Contains("://")) { name = "tcp://" + name; } var uri = new Uri(name, UriKind.Absolute); switch (uri.Scheme) { case "tcp": // tcp:// URI should only specify host and optionally port, path has no meaning and is invalid. if (uri.PathAndQuery != "/") { return(new FormatException().HResult); } // Set default port if not specified. if (uri.Port < 0) { uri = new UriBuilder(uri) { Port = NodejsConstants.DefaultDebuggerPort }.Uri; } break; case "ws": case "wss": // WebSocket URIs are used as is break; default: // Anything else is not a valid debugger endpoint return(new FormatException().HResult); } ppPort = new NodeRemoteDebugPort(this, pRequest, uri); return(VSConstants.S_OK); }
public int AddPort(IDebugPortRequest2 request, out IDebugPort2 port) { string name; HR.Check(request.GetPortName(out name)); AD7Port newPort = new AD7Port(this, name, isInAddPort: true); if (newPort.IsConnected) { port = newPort; return(HR.S_OK); } port = null; return(HR.E_REMOTE_CONNECT_USER_CANCELED); }
// Qualifier for our transport has one of the following formats: // // tcp[s]://[secret@]hostname[:port] // ws[s]://[secret@]hostname[:port][/path] // [secret@]hostname[:port] // // 'tcp' and 'tcps' are for connecting directly to ptvsd; 'ws' and 'wss' are for connecting through WebSocketProxy. // The versions ending with '...s' use SSL to secure the connection. If no scheme is specified, 'tcp' is the default. // If port is not specified, it defaults to 5678 for 'tcp' and 'tcps', 80 for 'ws' and 443 for 'wss'. public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { ppPort = null; string name; pRequest.GetPortName(out name); // Support old-style 'hostname:port' format, as well. if (!name.Contains("://")) { name = "tcp://" + name; } var uri = new Uri(name, UriKind.Absolute); var transport = DebuggerTransportFactory.Get(uri); if (transport == null) { MessageBox.Show( Strings.RemoteUnrecognizedDebuggingTransport.FormatUI(uri.Scheme), Strings.ProductTitle, MessageBoxButtons.OK, MessageBoxIcon.Error ); return(VSConstants.E_FAIL); } var validationError = transport.Validate(uri); if (validationError != null) { return(validationError.HResult); } var port = new PythonRemoteDebugPort(this, pRequest, uri, DebugLog); ppPort = port; _ports.Add(port); return(VSConstants.S_OK); }
new public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { string name; pRequest.GetPortName(out name); ppPort = FindPort(name); if (ppPort == null) { DebugPort port = _ports[(int)PortFilter.TcpIp]; //hack, hack. Abusing the Attach to dialog box to force the NetworkDevice port to //look for a nanoCLR process if (port.TryAddProcess(name) != null) { ppPort = port; } } return(COM_HResults.BOOL_TO_HRESULT_FAIL(ppPort != null)); }
public override int AddPort(IDebugPortRequest2 request, out IDebugPort2 port) { string name; HR.Check(request.GetPortName(out name)); if (!string.IsNullOrWhiteSpace(name)) { AD7Port newPort = new DockerPort(this, name, isInAddPort: true); if (newPort.IsConnected) { port = newPort; return(HR.S_OK); } } port = null; return(HR.E_REMOTE_CONNECT_USER_CANCELED); }
// Qualifier for our transport is parsed either as a tcp://, ws:// or ws:// URI, // or as 'hostname:port', where ':port' is optional. public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { ppPort = null; string name; pRequest.GetPortName(out name); // Support old-style 'hostname:port' format, as well. if (!name.Contains("://")) { name = "tcp://" + name; } var uri = new Uri(name, UriKind.Absolute); switch (uri.Scheme) { case "tcp": // tcp:// URI should only specify host and optionally port, path has no meaning and is invalid. if (uri.PathAndQuery != "/") { return new FormatException().HResult; } // Set default port if not specified. if (uri.Port < 0) { uri = new UriBuilder(uri) { Port = NodejsConstants.DefaultDebuggerPort }.Uri; } break; case "ws": case "wss": // WebSocket URIs are used as is break; default: // Anything else is not a valid debugger endpoint return new FormatException().HResult; } ppPort = new NodeRemoteDebugPort(this, pRequest, uri); return VSConstants.S_OK; }
// Qualifier for our transport has one of the following formats: // // tcp[s]://[secret@]hostname[:port] // ws[s]://[secret@]hostname[:port][/path] // [secret@]hostname[:port] // // 'tcp' and 'tcps' are for connecting directly to ptvsd; 'ws' and 'wss' are for connecting through WebSocketProxy. // The versions ending with '...s' use SSL to secure the connection. If no scheme is specified, 'tcp' is the default. // If port is not specified, it defaults to 5678 for 'tcp' and 'tcps', 80 for 'ws' and 443 for 'wss'. public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { ppPort = null; string name; pRequest.GetPortName(out name); // Support old-style 'hostname:port' format, as well. if (!name.Contains("://")) { name = "tcp://" + name; } var uri = new Uri(name, UriKind.Absolute); var transport = DebuggerTransportFactory.Get(uri); if (transport == null) { MessageBox.Show(string.Format("Unrecognized remote debugging transport '{0}'.", uri.Scheme), null, MessageBoxButtons.OK, MessageBoxIcon.Error); return VSConstants.E_FAIL; } var validationError = transport.Validate(uri); if (validationError != null) { return validationError.HResult; } var port = new PythonRemoteDebugPort(this, pRequest, uri); // Validate connection early. Debugger automation (DTE) objects are not consistent in error checking from this // point on, so errors reported from EnumProcesses and further calls may be ignored and treated as successes // (with empty result). Reporting an error here works around that. IEnumDebugProcesses2 processes; int hr = port.EnumProcesses(out processes); if (hr < 0) { return hr; } ppPort = port; return VSConstants.S_OK; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region IDebugPortSupplier2 Members //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { // // Attempt to find a port matching the requested name, otherwise one is created. // LoggingUtils.PrintFunction(); try { string requestPortName; LoggingUtils.RequireOk(CanAddPort()); LoggingUtils.RequireOk(pRequest.GetPortName(out requestPortName)); if (string.IsNullOrWhiteSpace(requestPortName)) { throw new InvalidOperationException("Invalid/empty port name"); } ppPort = null; foreach (KeyValuePair <Guid, IDebugPort2> keyPair in m_registeredPorts) { string portName; IDebugPort2 registeredPort = keyPair.Value; LoggingUtils.RequireOk(registeredPort.GetPortName(out portName)); if (portName.Equals(requestPortName)) { ppPort = registeredPort; break; } } if (ppPort == null) { // // Create and track a new port for this request. // Guid portId; LoggingUtils.RequireOk(CreatePort(pRequest, out ppPort)); LoggingUtils.RequireOk(ppPort.GetPortId(out portId)); m_registeredPorts.Add(portId, ppPort); } return(Constants.S_OK); } catch (Exception e) { LoggingUtils.HandleException(e); ppPort = null; return(Constants.E_FAIL); } }
/// <summary> /// Adds a port. (http://msdn.microsoft.com/en-ca/library/bb161980.aspx) /// </summary> /// <param name="pRequest"> An IDebugPortRequest2 object that describes the port to be added. </param> /// <param name="ppPort"> Returns an IDebugPort2 object that represents the port. </param> /// <returns> VSConstants.S_OK. </returns> public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { bool sucess = true; AD7PortRequest port_request = null; AD7Port port = null; try { port_request = (AD7PortRequest)pRequest; } catch { sucess = false; string portRequestName; AD7Port defaultPort = null; pRequest.GetPortName(out portRequestName); string search = ""; if (portRequestName.ToLower().Contains("device")) { search = "device"; } else if (portRequestName.ToLower().Contains("simulator")) { search = "simulator"; } else { search = portRequestName.ToLower(); } foreach (var p in m_ports) { AD7Port tempPort = p.Value; if (defaultPort == null) { defaultPort = tempPort; } string tempPortName = ""; tempPort.GetPortName(out tempPortName); if (tempPortName.ToLower().Contains(search)) { port = tempPort; break; } else { string IP = search; do { int pos = IP.LastIndexOf('.'); if (pos != -1) { IP = IP.Remove(pos); if (tempPortName.Contains(IP)) { port = tempPort; break; } } else { IP = ""; } } while (IP != ""); if (IP != "") { break; } } } if (port == null) { if (defaultPort != null) { port = defaultPort; } else { port = new AD7Port(this, port_request, Guid.NewGuid(), "", "", true, ""); } } } if (sucess) { port = CreatePort(port_request); Guid portGuid; port.GetPortId(out portGuid); m_ports.Add(portGuid, port); } ppPort = port; return(VSConstants.S_OK); }
/// <summary> /// Adds a port. (http://msdn.microsoft.com/en-ca/library/bb161980.aspx) /// </summary> /// <param name="pRequest"> An IDebugPortRequest2 object that describes the port to be added. </param> /// <param name="ppPort"> Returns an IDebugPort2 object that represents the port. </param> /// <returns> VSConstants.S_OK. </returns> public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { bool sucess = true; AD7PortRequest port_request = null; AD7Port port = null; try { port_request = (AD7PortRequest)pRequest; } catch { sucess = false; string portRequestName; AD7Port defaultPort = null; pRequest.GetPortName(out portRequestName); string search = ""; if (portRequestName.ToLower().Contains("device")) search = "device"; else if (portRequestName.ToLower().Contains("simulator")) search = "simulator"; else { search = portRequestName.ToLower(); } foreach (var p in m_ports) { AD7Port tempPort = p.Value; if (defaultPort == null) defaultPort = tempPort; string tempPortName = ""; tempPort.GetPortName(out tempPortName); if (tempPortName.ToLower().Contains(search)) { port = tempPort; break; } else { string IP = search; do { int pos = IP.LastIndexOf('.'); if (pos != -1) { IP = IP.Remove(pos); if (tempPortName.Contains(IP)) { port = tempPort; break; } } else IP = ""; } while (IP != ""); if (IP != "") break; } } if (port == null) { if (defaultPort != null) { port = defaultPort; } else port = new AD7Port(this, port_request, Guid.NewGuid(), "", "", true, ""); } } if (sucess) { port = CreatePort(port_request); Guid portGuid; port.GetPortId(out portGuid); m_ports.Add(portGuid, port); } ppPort = port; return VSConstants.S_OK; }
public int GetPortName(out string pbstrName) { return(_request.GetPortName(out pbstrName)); }
public int GetPortName(out string pbstrName) { req.GetPortName(out pbstrName); return(Microsoft.VisualStudio.VSConstants.S_OK); }
new public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) { string name; pRequest.GetPortName(out name); ppPort = FindPort(name); if (ppPort == null) { DebugPort port = m_ports[(int)PortFilter.TcpIp]; //hack, hack. Abusing the Attach to dialog box to force the NetworkDevice port to //look for a TinyCLR process if (port.TryAddProcess(name) != null) { ppPort = port; } } return Utility.COM_HResults.BOOL_TO_HRESULT_FAIL( ppPort != null ); }
/// <summary> /// Gets the port name. /// </summary> public int GetPortName(out string pbstrName) { DLog.Debug(DContext.VSDebuggerComCall, "DebugPort.GetPortName"); return(request.GetPortName(out pbstrName)); }