Ejemplo n.º 1
0
        /// <summary>
        /// Stops the debugging process that is currently underway.
        /// </summary>
        public void Stop()
        {
            if (this.m_ActiveDesigner != null && !Central.Manager.IDE.IsDisposed)
            {
                // Inform them we have stopped debugging.
                (this.m_ActiveDesigner as IDesigner).Invoke(new Action(() =>
                    {
                        this.m_ActiveDesigner.EndDebug();
                        this.m_ActiveDesigner = null;
                    }));
            }

            if (this.m_Process == null)
                return;
            if (!this.m_Process.HasExited)
                this.m_Process.Kill();
            this.m_Process = null;
            if (this.m_Communicator != null)
                this.m_Communicator.Close();
            this.m_Communicator = null;
            this.p_Paused = false;

            // Fire the event to say that debugging has stopped.
            if (this.DebugStop != null)
                this.DebugStop(this, new EventArgs());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Runs the specified project with debugging.
        /// </summary>
        /// <param name="project">The project to run under the debugger.</param>
        public bool Start(Moai.Platform.Management.Project project)
        {
            // Check to see whether we are paused or not.
            if (this.p_Paused)
            {
                // Unpause, optionally sending an EndDebug call to
                // the appropriate place.
                if (this.m_ActiveDesigner != null)
                {
                    // Inform them we have stopped debugging.
                    this.m_ActiveDesigner.EndDebug();
                    this.m_ActiveDesigner = null;
                }

                // Now send the continue message.
                this.m_Communicator.Send(new ContinueMessage());
                this.p_Paused = false;
                if (this.DebugContinue != null)
                    this.DebugContinue(this, new EventArgs());
            }

            // Otherwise make sure we have no process running.
            if (this.m_Process != null)
            {
                // Can't run.
                return false;
            }

            // Check to see if the launch path exists.
            if (!File.Exists(Manager.m_LaunchPath))
            {
                Central.Platform.UI.ShowMessage(@"Moai IDE was unable to start debugging because it could not
            locate the engine executable.  Ensure that you have installed
            the engine executable in the required path and try again.", "Debugging Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            // Fire the event to say that debugging has started.
            if (this.DebugStart != null)
                this.DebugStart(this, new EventArgs());

            // Clear the existing output log.
            this.m_OutputTool = Central.Manager.ToolsManager.Get(typeof(IOutputTool)) as IOutputTool;
            if (this.m_OutputTool != null)
                this.m_OutputTool.ClearLog();

            // Start the debug listening service.
            try
            {
                this.m_Communicator = new Communicator(7018);
            }
            catch (ConnectionFailureException)
            {
                // It seems we can't start the debugging communicator.  Stop debugging
                // (forcibly terminate the process) and alert the user.
                if (this.DebugStop != null)
                    this.DebugStop(this, new EventArgs());
                Central.Platform.UI.ShowMessage(@"Moai IDE was unable to start debugging because it could not
            listen or connect to the debugging socket.  Ensure there
            are no other instances of the Moai engine running in debug
            mode and try again.", "Debugging Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            this.m_Communicator.MessageArrived += new EventHandler<MessageEventArgs>(m_Communicator_MessageArrived);

            this.m_Process = new Process();
            this.m_Process.StartInfo.FileName = Manager.m_LaunchPath;
            this.m_Process.StartInfo.WorkingDirectory = project.ProjectInfo.Directory.FullName;
            this.m_Process.StartInfo.UseShellExecute = false;
            this.m_Process.StartInfo.Arguments = "Main.lua";
            this.m_Process.EnableRaisingEvents = true;
            this.m_Process.Exited += new EventHandler(m_Process_Exited);

            // FIXME: Find some way to make this work.  We need the Moai output to be completely unbuffered,
            //        and changing things around in .NET and on the engine side seems to make absolutely no
            //        difference what-so-ever.  My suggestion is to make the engine-side of the debugger replace
            //        the Lua print() function and send it over the network directly back to the IDE (this
            //        means that print would work even during remote debugging!)
            //
            // this.m_Process.StartInfo.RedirectStandardOutput = true;
            // this.m_Process.OutputDataReceived += new DataReceivedEventHandler(m_Process_OutputDataReceived);

            this.m_Process.Start();
            //this.m_Process.BeginOutputReadLine();

            this.p_Paused = false;
            return true;
        }