Example #1
0
 public RemoteDebugPort(RemoteDebugPortSupplier supplier, IDebugPortRequest2 request, string portName)
 {
     this.guidId   = Guid.NewGuid();
     this.supplier = supplier;
     this.request  = request;
     this.portName = portName;
 }         // ctor
Example #2
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;
        }
 //string pname;
 public SquirrelPort(SquirrelPortSupplier supplier, IDebugPortRequest2 req)
 {
     // string pname;
     //req.GetPortName(out pname);
     this.req      = req;
     this.supplier = supplier;
 }
Example #4
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);
        }
            public DebugPort(RDebugPortSupplier supplier, IDebugPortRequest2 request) {
                _supplier = supplier;
                _request = request;

                var compModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel));
                compModel.DefaultCompositionService.SatisfyImportsOnce(this);
            }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        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);
            }
        }
Example #7
0
 public PythonRemoteDebugPort(PythonRemoteDebugPortSupplier supplier, IDebugPortRequest2 request, Uri uri, TextWriter debugLog)
 {
     _supplier = supplier;
     _request  = request;
     _uri      = uri;
     _debugLog = debugLog ?? new DebugTextWriter();
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        #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
            {
                LoggingUtils.RequireOk(CanAddPort());

                LoggingUtils.RequireOk(pRequest.GetPortName(out string requestPortName));

                if (string.IsNullOrWhiteSpace(requestPortName))
                {
                    throw new InvalidOperationException("Invalid/empty port name");
                }

                ppPort = null;

                foreach (KeyValuePair <Guid, IDebugPort2> keyPair in m_registeredPorts)
                {
                    IDebugPort2 registeredPort = keyPair.Value;

                    LoggingUtils.RequireOk(registeredPort.GetPortName(out string portName));

                    if (portName.Equals(requestPortName))
                    {
                        ppPort = registeredPort;

                        break;
                    }
                }

                if (ppPort == null)
                {
                    //
                    // Create and track a new port for this request.
                    //

                    LoggingUtils.RequireOk(CreatePort(pRequest, out ppPort));

                    LoggingUtils.RequireOk(ppPort.GetPortId(out Guid portId));

                    m_registeredPorts.Add(portId, ppPort);
                }

                return(Constants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                ppPort = null;

                return(Constants.E_FAIL);
            }
        }
Example #9
0
        /// <inheritdoc />
        public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort)
        {
            string portName;
            var    result = pRequest.GetPortName(out portName);

            ppPort = null;
            return(VSConstants.S_OK);
        }
Example #10
0
            public DebugPort(RDebugPortSupplier supplier, IDebugPortRequest2 request)
            {
                _supplier = supplier;
                _request  = request;

                var compModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel));

                compModel.DefaultCompositionService.SatisfyImportsOnce(this);
            }
Example #11
0
        /// <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)
        {
            AD7PortRequest port_request = (AD7PortRequest)pRequest;
            var            port         = CreatePort(port_request);

            m_ports.Add(port.m_guid, port);
            ppPort = port;
            return(VSConstants.S_OK);
        }
Example #12
0
        public AD7Port(AD7PortSupplier supplier, IDebugPortRequest2 request)
        {
            this.supplier = supplier;
            this.request  = request;
            request.GetPortName(out portName);
            AD7Process p = new AD7Process(this);

            processes.Add(p);
        }
Example #13
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        #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);
            }
        }
Example #14
0
 /// <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;
 }
Example #15
0
        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);
        }
        // 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);
        }
Example #17
0
        /// <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);
        }
Example #18
0
        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 GetPortRequest(out IDebugPortRequest2 ppRequest)
        {
            //
            // Gets the description of a port that was previously used to create the port (if available).
            //

            LoggingUtils.PrintFunction();

            ppRequest = null;

            return(Constants.E_PORT_NO_REQUEST);
        }
Example #20
0
        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);
        }
Example #21
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        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));
        }
Example #22
0
            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);
            }
Example #23
0
        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);
        }
Example #24
0
        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;
        }
Example #25
0
        // 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);
        }
Example #26
0
        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);
        }
Example #27
0
        // 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);
        }
Example #28
0
        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);
        }
            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));
            }
Example #30
0
        public int AddPort(IDebugPortRequest2 request, out IDebugPort2 port)
        {
            var debugSessionMetrics = new DebugSessionMetrics(_metrics);

            debugSessionMetrics.UseNewDebugSessionId();
            var actionRecorder = new ActionRecorder(debugSessionMetrics);

            port = null;

            if (request.GetPortName(out string gameletIdOrName) != VSConstants.S_OK)
            {
                return(VSConstants.E_FAIL);
            }

            var action        = actionRecorder.CreateToolAction(ActionType.GameletGet);
            var gameletClient = _gameletClientFactory.Create(_cloudRunner.Intercept(action));
            var gameletTask   = _cancelableTaskFactory.Create(
                "Querying instance...",
                async() => await gameletClient.LoadByNameOrIdAsync(gameletIdOrName));

            try
            {
                gameletTask.RunAndRecord(action);
            }
            catch (CloudException e)
            {
                Trace.WriteLine(e.ToString());
                _dialogUtil.ShowError(e.Message);
                return(VSConstants.S_OK);
            }

            var debugPort = _debugPortFactory.Create(gameletTask.Result, this,
                                                     debugSessionMetrics.DebugSessionId);

            _ports.Add(debugPort);
            port = debugPort;
            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;
        }
        // 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;
        }
Example #33
0
 int Microsoft.VisualStudio.Debugger.Interop.IDebugPort2.GetPortRequest(out IDebugPortRequest2 ppRequest)
 {
     ppRequest = null;
     return Utility.COM_HResults.E_NOTIMPL;
 }
Example #34
0
        /// <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;
        }
Example #35
0
 public int GetPortRequest(out IDebugPortRequest2 ppRequest)
 {
     ppRequest = _request;
     return(VSConstants.S_OK);
 }
 public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort) {
     ppPort = new DebugPort(this, pRequest);
     return VSConstants.S_OK;
 }
Example #37
0
 int IDebugPortSupplier2.AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort)
 {
     throw new NotImplementedException();
 }
 public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort)
 {
     throw new NotImplementedException();
 }
 public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort)
 {
     thePort = new SquirrelPort(this, pRequest);
     ppPort  = (IDebugPort2)thePort;
     return(Microsoft.VisualStudio.VSConstants.S_OK);
 }
Example #40
0
 /// <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)
 {
     AD7PortRequest port_request = (AD7PortRequest)pRequest;
     var port = CreatePort(port_request);
     m_ports.Add(port.m_guid, port);
     ppPort = port;
     return VSConstants.S_OK;
 }
 public int GetPortRequest(out IDebugPortRequest2 ppRequest) {
     ppRequest = _request;
     return VSConstants.S_OK;
 }
 /// <summary>
 /// Adds a port.
 /// </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>If successful, returns S_OK; otherwise, returns an error code.</returns>
 /// <remarks>
 /// This method actually creates the requested port as well as adding it to the port supplier's internal list of active ports. The IDebugPortSupplier2::CanAddPort method can be called first to avoid possible time-consuming delays.
 /// </remarks>
 public virtual int AddPort( IDebugPortRequest2 pRequest, out IDebugPort2 ppPort )
 {
     Logger.Debug( string.Empty );
     ppPort = null;
     return VSConstants.E_NOTIMPL;
 }
Example #43
0
 /// <summary>
 /// Gets the description of a port that was previously used to create the port (if available).
 /// </summary>
 public int GetPortRequest(out IDebugPortRequest2 ppRequest)
 {
     DLog.Debug(DContext.VSDebuggerComCall, "DebugPort.GetPortRequest");
     ppRequest = request;
     return VSConstants.S_OK;
 }
Example #44
0
 /// <summary>
 /// Gets the description of a port that was previously used to create the port (if available).
 /// </summary>
 /// <param name="ppRequest">Returns an IDebugPortRequest2 object representing the request that was used to create the port.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code. Returns E_PORT_NO_REQUEST if a port was not created using an IDebugPortRequest2 port request.</returns>
 public virtual int GetPortRequest( out IDebugPortRequest2 ppRequest )
 {
     Logger.Debug( string.Empty );
     ppRequest = null;
     return VSConstants.E_NOTIMPL;
 }
Example #45
0
 public PythonRemoteDebugPort(PythonRemoteDebugPortSupplier supplier, IDebugPortRequest2 request, Uri uri) {
     _supplier = supplier;
     _request = request;
     _uri = uri;
 }
            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 );                
            }
Example #47
0
 /// <summary>
 /// Default ctor
 /// </summary>
 internal DebugPort(DebugPortSupplier supplier, IDebugPortRequest2 request)
 {
     this.supplier = supplier;
     this.request = request;
     guid = Guid.NewGuid();
 }
Example #48
0
 public int GetPortRequest(out IDebugPortRequest2 ppRequest)
 {
     throw new NotImplementedException();
 }
 public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort)
 {
     return s_portSupplier.AddPort(pRequest, out ppPort);
 }
Example #50
0
 int IDebugPortSupplier2.AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort)
 {
     throw new NotImplementedException();
 }
Example #51
0
 public int GetPortRequest(out IDebugPortRequest2 ppRequest)
 {
     throw new NotImplementedException();
 }