Ejemplo n.º 1
0
        private void OnXdebuggerConnected(XDebugEventArgs e)
        {
            _statusFrm.WriteStatusLine("(-) Debugger connected.");

            try {
                if (_client.Initialize())
                {
                    _statusFrm.WriteStatusLine("(-) XDebugClient initialized.");

                    if (!xdc.Properties.Settings.Default.break_on_script_start)
                    {
                        this.SendContinuationCommand("run");
                    }
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                _statusFrm.WriteStatusLine("(-) Cannot initialize XDebugClient: " + ex.Message);

                MessageBox.Show(
                    "XDebugClient was unable to initialize. Debugging session terminated.\r\n\r\n" + ex.Message,
                    "System error",
                    MessageBoxButtons.OK
                    );

                this.StopDebuggingSession();
            }
        }
Ejemplo n.º 2
0
        private void OnXdebugScriptFinished(XDebugEventArgs e)
        {
            _statusFrm.WriteStatusLine("(!) Script finished.");

            this.StopDebuggingSession();

            if (xdc.Properties.Settings.Default.auto_restart)
            {
                _statusFrm.WriteStatusLine("(-) Automatically restarting debugging.");

                try
                {
                    _client.listenForConnection();

                    startListeningToolStripMenuItem.Enabled = false;
                    stopDebuggingToolStripMenuItem.Enabled  = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(
                        "Unable to re-create listening socket: " + ex.Message,
                        "Cannot open socket",
                        MessageBoxButtons.OK
                        );
                }
            }
        }
Ejemplo n.º 3
0
        private void OnXdebugBreakpointHit(XDebugEventArgs e)
        {
            this.PrepareFileForAccess(e.CurrentLocation.filename);
            this.SetActiveFileAndLine(e.CurrentLocation);

            List <StackEntry> callstack = _client.GetCallStack(-1);

            _callstackFrm.setCallstack(callstack);
        }
Ejemplo n.º 4
0
        private bool OnXdebugConnectionInitialized(XDebugEventArgs e)
        {
            if (this.LoadFile(e.Filename))
            {
                this.ToggleMenuItems(true);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 5
0
        private void OnXdebugBreakpointHit(XDebugEventArgs e)
        {
            this.PrepareFileForAccess(e.CurrentLocation.filename);
            this.SetActiveFileAndLine(e.CurrentLocation);

            List <StackEntry> callstack = _client.GetCallStack(-1);

            _callstackFrm.setCallstack(callstack);
            // local and global context
            List <Property> ctx = _client.GetContext("0");

            _localContextFrm.LoadPropertyList(ctx);
            ctx = _client.GetContext("1");
            _globalContextFrm.LoadPropertyList(ctx);
        }
Ejemplo n.º 6
0
        /* The methods in this region aren't neccessarily real events as
         * C# defines them. Some of them (those called from _client_EventCallback)
         * as just regular methods.
         *
         * The callback XDebugEventCallback is used as a centralized
         * place to further instruct the GUI what to do. We use only one event as
         * the client uses asynchronized methods (threading). By using 1 callback the
         * number of threading-related reinvoking (see MainForm.ReinvokeInOwnThread)
         */

        /// <summary>
        /// The XDebugEventCallback is called whenever something changes within the Xdebug.Client
        /// implementation. It serves mostly as a dispatcher.
        /// </summary>
        private bool XDebugEventCallback(XDebugEventArgs e)
        {
            if (!this.ReinvokeInOwnThread(new XdebugClientCallback(XDebugEventCallback), new object[] { e }))
            {
                switch (e.EventType)
                {
                case XDebugEventType.DebuggerConnected:
                    this.OnXdebuggerConnected(e);
                    break;

                case XDebugEventType.ConnectionInitialized:
                    return(this.OnXdebugConnectionInitialized(e));

                case XDebugEventType.MessageReceived:
                    this.OnXdebugMessageReceived(e);
                    break;

                case XDebugEventType.CommandSent:
                    this.OnXdebugCommandSent(e);

                    break;

                case XDebugEventType.BreakpointHit:
                    this.OnXdebugBreakpointHit(e);
                    break;

                case XDebugEventType.ErrorOccured:
                    this.OnXdebugErrorOccurred(e);
                    break;

                case XDebugEventType.ScriptFinished:
                    this.OnXdebugScriptFinished(e);
                    break;

                default:
                    WriteDebugLine("(!) Unknown event happened.");
                    break;
                }
            }

            return(false);
        }
Ejemplo n.º 7
0
        private void OnXdebugErrorOccurred(XDebugEventArgs e)
        {
            if (e.ErrorType == XDebugErrorType.Warning)
            {
                WriteDebugLine("(!) PHP Notice: " + e.ErrorMessage);
                this._client.Run();
            }
            else
            {
                WriteDebugLine("(!) PHP Fatal error: " + e.ErrorMessage);

                MessageBox.Show(
                    "A Fatal error occurred:\r\n\r\n" + e.ErrorMessage + "\r\n\r\nYour script has been terminated.",
                    "Fatal Error",
                    MessageBoxButtons.OK
                    );

                this.StopDebuggingSession();
            }
        }
Ejemplo n.º 8
0
 private void OnXdebugMessageReceived(XDebugEventArgs e)
 {
     // Nothing to do for now
 }
Ejemplo n.º 9
0
 private void OnXdebugCommandSent(XDebugEventArgs e)
 {
     WriteDebugLine(" -> SENT: " + e.Message.RawMessage);
 }