Exemplo n.º 1
0
        void PushCommands()
        {
            try
            {
                string name = "npp.css.dbg.commands." + remoteProcessId;
                using (var pipeServer = new NamedPipeServerStream(name, PipeDirection.Out))
                    using (var streamWriter = new StreamWriter(pipeServer))
                    {
                        pipeServer.WaitForConnection();
                        Notify("Out.Client connected.");
                        streamWriter.AutoFlush = true;

                        while (true)
                        {
                            string command = MessageQueue.WaitForCommand();

                            streamWriter.WriteLine(command);
                            if (command == NppCommand.Exit)
                            {
                                MessageQueue.AddNotification(NppCommand.Exit); //signal to stop the PullNotifications channel
                                break;
                            }
                            pipeServer.WaitForPipeDrain();
                        }
                    }
            }
            catch
            {
                //Notify("ERROR: " + e.Message);
            }

            Notify("Out.Client disconnected.");
        }
Exemplo n.º 2
0
        public void PullNotifications()
        {
            try
            {
                string name = "npp.css.dbg.notifications." + remoteProcessId;
                using (var pipeServer = new NamedPipeServerStream(name, PipeDirection.In))
                    using (var streamReader = new StreamReader(pipeServer))
                    {
                        pipeServer.WaitForConnection();
                        Notify("In.Client connected.");

                        while (true)
                        {
                            string message = streamReader.ReadLine();

                            if (message == NppCommand.Exit || message == null)
                            {
                                break;
                            }

                            Debug.WriteLine(message);
                            MessageQueue.AddNotification(message);
                        }
                    }
            }
            catch (IOException e)
            {
                Notify("ERROR: " + e.Message);
            }

            Notify("In.Client disconnected");
        }
Exemplo n.º 3
0
        static public bool Start(Debugger.CpuType cpu = Debugger.CpuType.Any)
        {
            if (!initialized)
            {
                Init();
            }

            if (debuggerProcessId != 0)
            {
                return(false);
            }

            MessageQueue.Clear();

            string debuggerApp = PluginEnv.Locate("mdbg.exe", "MDbg");

            if (cpu == Debugger.CpuType.x86)
            {
                debuggerApp = PluginEnv.Locate("mdbghost_32.exe", "MDbg");
            }
            else if (cpu == Debugger.CpuType.x64)
            {
                debuggerApp = PluginEnv.Locate("mdbghost_64.exe", "MDbg");
            }

            var debugger = Process.Start(new ProcessStartInfo
            {
                FileName  = debuggerApp,
                Arguments = "!load npp.dll",
                // #if !DEBUG
                CreateNoWindow  = true,
                UseShellExecute = false
                                  // #endif
            });

            MessageQueue.AddNotification(NppCategory.Diagnostics + debugger.Id + ":STARTED");
            debuggerProcessId = debugger.Id;

            if (CSScriptHelper.IsUsingCSScriptCore)
            {
                OnDebuggeeProcessNotification?.Invoke("======= Debugging .NET 5/Core is not supported =======");
            }

            Task.Factory.StartNew(() => WaitForExit(debugger));

            channel        = new RemoteChannelServer(debuggerProcessId);
            channel.Notify = message => Console.WriteLine(message);
            channel.Start();

            return(true);
        }
Exemplo n.º 4
0
        private static void WaitForExit(Process debugger)
        {
            debugger.WaitForExit();

            debuggeeProcessId     =
                debuggerProcessId = 0;

            MessageQueue.AddCommand(NppCommand.Exit);

            if (OnDebuggerStateChanged != null)
            {
                OnDebuggerStateChanged();
            }

            MessageQueue.AddNotification(NppCategory.Diagnostics + debugger.Id + ":STOPPED");
        }