Esempio n. 1
0
 /// <summary>
 ///
 /// </summary>
 internal void Stop_Click(Object sender, EventArgs e)
 {
     PluginMain.liveDataTip.Hide();
     CurrentLocation = null;
     m_FlashInterface.Stop();
     FlexDbgTrace.TraceInfo("Stop() FlashInterface.Stop; end");
 }
Esempio n. 2
0
 internal void Finish_Click(Object sender, EventArgs e)
 {
     CurrentLocation = null;
     FlexDbgTrace.TraceInfo("Finish() FlashInterface.Finish();");
     m_FlashInterface.Finish();
     UpdateMenuState(DebuggerState.Running);
 }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        internal void Start(String filename)
        {
            PluginMain.debugBuildStart = false;

            FlexDbgTrace.TraceInfo("----Start(string filename)----");
            //FlexDbgTrace.TraceInfo(PluginMain.settingObject.DebugFlashPlayerPath + " " + filename);

            m_FlashInterface.currentProject     = currentProject;
            m_FlashInterface.outputFileFullPath = filename;

            PanelsHelper.pluginPanel.Show();
            PanelsHelper.breakPointPanel.Show();
            PanelsHelper.stackframePanel.Show();

            PluginBase.MainForm.ProgressBar.Visible   = true;
            PluginBase.MainForm.ProgressLabel.Visible = true;
            PluginBase.MainForm.ProgressLabel.Text    = TextHelper.GetString("Info.WaitingForPlayer");

            if (bgWorker == null || !bgWorker.IsBusy)
            {
                // only run a debugger if one is not already runnin - need to redesign core to support multiple debugging instances
                // other option: detach old worker, wait for it to exit and start new one
                bgWorker         = new BackgroundWorker();
                bgWorker.DoWork += bgWorker_DoWork;
                bgWorker.RunWorkerAsync();
            }
            else
            {
                ErrorManager.ShowInfo(TextHelper.GetString("Info.DebuggingSessionAlreadyRunning"));
            }
        }
Esempio n. 4
0
        public void Start()
        {
            try
            {
                FlexDbgTrace.Trace("CheckCurrent()");
                if (!CheckCurrent())
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                ErrorManager.ShowError(ex);
                return;
            }

            PluginMain.debugBuildStart = true;

            UpdateMenuState(DebuggerState.Starting);

            if (!File.Exists(Path.Combine(Path.GetDirectoryName(currentProject.ProjectPath), currentProject.OutputPath)))
            {
                // remove this, let other parts deal with it
                ErrorManager.ShowInfo(TextHelper.GetString("Info.CannotFindOutputFile"));
            }
            else
            {
                Start(currentProject.OutputPathAbsolute);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes the plugin
        /// </summary>
        public void Initialize()
        {
            InitBasics();
            LoadSettings();
            AddEventHandlers();
            InitLocalization();
            CreateMenuItems();
            CreatePluginPanel();

            //debug
            FlexDbgTrace.init();
            FlexDbgTrace.IsTraceLog = settingObject.EnableLogging;
            FlexDbgTrace.Trace("--------------------------");
            FlexDbgTrace.Trace("---FlexDbgTrace Start---");
        }
Esempio n. 6
0
        public bool PreFilterMessage(ref Message m)
        {
            if (m.Msg == Win32.WM_LBUTTONDOWN)
            {
                FlexDbgTrace.TraceInfo("PreFilterMessage: WM_LBUTTONDOWN - wParam = " + m.WParam.ToString("x") + ", lParam = " + m.LParam.ToString("x"));

                Control target = Control.FromHandle(m.HWnd);

                foreach (Control c in m_ControlList)
                {
                    if (c == target || c.Contains(target))
                    {
                        return(false);
                    }
                }

                if (MouseDownEvent != null)
                {
                    MouseDownEvent(MouseButtons.Left, new Point(m.LParam.ToInt32()));
                }
            }
            return(false);
        }
Esempio n. 7
0
 /// <summary>
 ///
 /// </summary>
 internal void Pause_Click(Object sender, EventArgs e)
 {
     CurrentLocation = null;
     FlexDbgTrace.TraceInfo("Pause() FlashInterface.Pause();");
     m_FlashInterface.Pause();
 }
        /// <summary>
        /// Main loop
        /// </summary>
        public void Start()
        {
            m_CurrentState = DebuggerState.Starting;

            SessionManager mgr = Bootstrap.sessionManager();

            mgr.setDebuggerCallbacks(new FlashDebuggerCallbacks());

            mgr.setPreference(SessionManager.PREF_GETVAR_RESPONSE_TIMEOUT, 5000);

            m_RequestDetach = false;

            mgr.startListening();
            FlexDbgTrace.TraceInfo("startListening");

            try
            {
                m_Session = mgr.accept(this);

                if (mgr.Listening)
                {
                    mgr.stopListening();
                }

                FlexDbgTrace.TraceInfo("FlexDbg.START");
                TraceManager.AddAsync("[Starting debug session with FDB]", -1);

                if (m_Session == null)
                {
                    m_CurrentState = DebuggerState.Stopped;

                    throw new Exception(TextHelper.GetString("Info.UnableToStartDebugger"));
                }

                initSession();

                m_CurrentState = DebuggerState.Running;

                if (StartedEvent != null)
                {
                    StartedEvent(this);
                }

                try
                {
                    waitTilHalted();
                }
                catch (System.Exception)
                {
                }

                try
                {
                    waitForMetaData();
                }
                catch (System.Exception)
                {
                }

                m_CurrentState = DebuggerState.Running;

                // now poke to see if the player is good enough
                try
                {
                    if (m_Session.getPreference(SessionManager.PLAYER_SUPPORTS_GET) == 0)
                    {
                        TraceManager.AddAsync(TextHelper.GetString("Info.WarningNotAllCommandsSupported"));
                    }
                }
                catch (System.Exception)
                {
                }

                bool stop = false;

                while (!stop)
                {
                    processEvents();

                    // not there, not connected
                    if (m_RequestStop || m_RequestDetach || !haveConnection())
                    {
                        FlexDbgTrace.TraceInfo("Stopping due to request or lost connection, m_RequestStop = " + m_RequestStop);
                        stop = true;
                        continue;
                    }

                    if (m_RequestResume)
                    {
                        // resume execution (request fulfilled)
                        try
                        {
                            if (m_StepResume)
                            {
                                m_Session.stepContinue();
                            }
                            else
                            {
                                m_Session.resume();
                            }
                        }
                        catch (NotSuspendedException)
                        {
                            TraceManager.AddAsync(TextHelper.GetString("Info.PlayerAlreadyRunning"));
                        }

                        m_RequestResume = false;
                        m_RequestPause  = false;
                        m_StepResume    = false;
                        m_CurrentState  = DebuggerState.Running;

                        continue;
                    }

                    if (m_Session.Suspended)
                    {
                        /*
                         * We have stopped for some reason.
                         */

                        /*
                         * Now before we do this see, if we have a valid break reason, since
                         * we could be still receiving incoming messages, even though we have halted.
                         * This is definately the case with loading of multiple SWFs.  After the load
                         * we get info on the swf.
                         */
                        int tries = 3;
                        while (tries-- > 0 && m_Session.suspendReason() == SuspendReason.Unknown)
                        {
                            try
                            {
                                System.Threading.Thread.Sleep(100);
                                processEvents();
                            }
                            catch (System.Threading.ThreadInterruptedException)
                            {
                            }
                        }

                        m_SuspendWait.Reset();

                        switch (suspendReason)
                        {
                        case SuspendReason.Breakpoint:
                            m_CurrentState = DebuggerState.BreakHalt;
                            if (BreakpointEvent != null)
                            {
                                BreakpointEvent(this);
                            }
                            else
                            {
                                m_RequestResume = true;
                            }
                            break;

                        case SuspendReason.Fault:
                            m_CurrentState = DebuggerState.ExceptionHalt;
                            if (FaultEvent != null)
                            {
                                FaultEvent(this);
                            }
                            else
                            {
                                m_RequestResume = true;
                            }
                            break;

                        case SuspendReason.ScriptLoaded:
                            waitForMetaData();
                            m_CurrentState = DebuggerState.PauseHalt;
                            if (ScriptLoadedEvent != null)
                            {
                                ScriptLoadedEvent(this);
                            }
                            else
                            {
                                m_RequestResume = true;
                            }
                            break;

                        case SuspendReason.Step:
                            m_CurrentState = DebuggerState.BreakHalt;
                            if (StepEvent != null)
                            {
                                StepEvent(this);
                            }
                            else
                            {
                                m_RequestResume = true;
                            }
                            break;

                        case SuspendReason.StopRequest:
                            m_CurrentState = DebuggerState.PauseHalt;
                            if (PauseEvent != null)
                            {
                                PauseEvent(this);
                            }
                            else
                            {
                                m_RequestResume = true;
                            }
                            break;

                        case SuspendReason.Watch:
                            m_CurrentState = DebuggerState.BreakHalt;
                            if (WatchpointEvent != null)
                            {
                                WatchpointEvent(this);
                            }
                            else
                            {
                                m_RequestResume = true;
                            }
                            break;

                        default:
                            m_CurrentState = DebuggerState.BreakHalt;
                            if (UnknownHaltEvent != null)
                            {
                                UnknownHaltEvent(this);
                            }
                            else
                            {
                                m_RequestResume = true;
                            }
                            break;
                        }

                        if (!(m_RequestResume || m_RequestDetach))
                        {
                            m_SuspendWait.WaitOne();
                        }
                    }
                    else
                    {
                        if (m_RequestPause)
                        {
                            try
                            {
                                m_CurrentState = DebuggerState.Pausing;
                                m_Session.suspend();

                                // no connection => dump state and end
                                if (!haveConnection())
                                {
                                    stop = true;
                                    continue;
                                }
                                else if (!m_Session.Suspended)
                                {
                                    TraceManager.AddAsync(TextHelper.GetString("Info.CouldNotHalt"));
                                    m_CurrentState = DebuggerState.Running;

                                    if (PauseFailedEvent != null)
                                    {
                                        PauseFailedEvent(this);
                                    }
                                }
                            }
                            catch (ArgumentException)
                            {
                                TraceManager.AddAsync(TextHelper.GetString("Info.EscapingFromDebuggerPendingLoop"));
                                stop = true;
                            }
                            catch (IOException io)
                            {
                                System.Collections.IDictionary args = new System.Collections.Hashtable();
                                args["error"] = io.Message; //$NON-NLS-1$
                                TraceManager.AddAsync(replaceInlineReferences(TextHelper.GetString("Info.ContinuingDueToError"), args));
                            }
                            catch (SuspendedException)
                            {
                                // lucky us, already paused
                            }
                        }
                    }

                    // sleep for a bit, then process our events.
                    try
                    {
                        System.Threading.Thread.Sleep(m_UpdateDelay);
                    }
                    catch (System.Threading.ThreadInterruptedException)
                    {
                    }
                }
                FlexDbgTrace.TraceInfo("loop end");
            }
            catch (System.Net.Sockets.SocketException ex)
            {
                if (m_RequestStop)
                {
                    throw new Exception(TextHelper.GetString("Info.DebuggerListenAborted"));
                }
                else
                {
                    throw ex;
                }
            }
            finally
            {
                if (DisconnectedEvent != null)
                {
                    DisconnectedEvent(this);
                }
                exitSession();
            }
        }