Search in sources :

Example 1 with SuspendedException

use of flash.tools.debugger.SuspendedException in project intellij-plugins by JetBrains.

the class DebugCLI method runningLoop.

/**
	 * Our main loop when the player is off running
	 */
void runningLoop() throws NoResponseException, NotConnectedException {
    int update = propertyGet(UPDATE_DELAY);
    // DEBUG ONLY; do not document
    boolean nowait = (propertyGet(NO_WAITING) == 1) ? true : false;
    boolean stop = false;
    // not there, not connected or already halted and no pending resume requests => we are done
    if (!haveConnection() || (m_session.isSuspended() && !m_requestResume)) {
        processEvents();
        stop = true;
    }
    while (!stop) {
        // allow keyboard input
        if (!nowait)
            m_keyboardReadRequest = true;
        if (m_requestResume) {
            // resume execution (request fulfilled) and look for keyboard input
            try {
                if (m_stepResume)
                    m_session.stepContinue();
                else
                    m_session.resume();
            } catch (NotSuspendedException nse) {
                //$NON-NLS-1$
                err(getLocalizationManager().getLocalizedTextString("playerAlreadyRunning"));
            }
            m_requestResume = false;
            m_requestHalt = false;
            m_stepResume = false;
        }
        // sleep for a bit, then process our events.
        try {
            Thread.sleep(update);
        } catch (InterruptedException ie) {
        }
        processEvents();
        // lost connection?
        if (!haveConnection()) {
            stop = true;
            dumpHaltState(false);
        } else if (m_session.isSuspended()) {
            /**
				 * We have stopped for some reason.  Now for all cases, but conditional
				 * breakpoints, we should be done.  For conditional breakpoints it
				 * may be that the condition has turned out to be false and thus
				 * we need to continue
				 */
            /**
				 * 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 {
                Thread.sleep(100);
                processEvents();
            } catch (InterruptedException ie) {
            }
            dumpHaltState(false);
            if (!m_requestResume)
                stop = true;
        } else if (nowait) {
            // for DEBUG only
            stop = true;
        } else {
            /**
				 * We are still running which is fine.  But let's see if the user has
				 * tried to enter something on the keyboard.  If so, then we need to
				 * stop
				 */
            if (//$NON-NLS-1$
            !m_keyboardInput.isEmpty() && System.getProperty("fdbunit") == null) {
                // flush the queue and prompt the user if they want us to halt
                m_keyboardInput.clear();
                try {
                    if (//$NON-NLS-1$
                    yesNoQuery(getLocalizationManager().getLocalizedTextString("doYouWantToHalt"))) {
                        //$NON-NLS-1$
                        out(getLocalizationManager().getLocalizedTextString("attemptingToHalt"));
                        m_session.suspend();
                        m_requestHalt = true;
                        // no connection => dump state and end
                        if (!haveConnection()) {
                            dumpHaltState(false);
                            stop = true;
                        } else if (!m_session.isSuspended())
                            //$NON-NLS-1$
                            err(getLocalizationManager().getLocalizedTextString("couldNotHalt"));
                    }
                } catch (IllegalArgumentException iae) {
                    //$NON-NLS-1$
                    out(getLocalizationManager().getLocalizedTextString("escapingFromDebuggerPendingLoop"));
                    propertyPut(NO_WAITING, 1);
                    stop = true;
                } catch (IOException io) {
                    Map args = new HashMap();
                    //$NON-NLS-1$
                    args.put("error", io.getMessage());
                    //$NON-NLS-1$
                    err(getLocalizationManager().getLocalizedTextString("continuingDueToError", args));
                } catch (SuspendedException se) {
                // lucky us, already stopped
                }
            }
        }
    //		System.out.println("doContinue resume="+m_requestResume+",isSuspended="+m_session.isSuspended());
    }
    // DEBUG ONLY: if we are not waiting then process some events
    if (nowait)
        processEvents();
}
Also used : HashMap(java.util.HashMap) NotSuspendedException(flash.tools.debugger.NotSuspendedException) SuspendedException(flash.tools.debugger.SuspendedException) NotSuspendedException(flash.tools.debugger.NotSuspendedException) IOException(java.io.IOException) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

NotSuspendedException (flash.tools.debugger.NotSuspendedException)1 SuspendedException (flash.tools.debugger.SuspendedException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1