Search in sources :

Example 1 with NotSuspendedException

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

the class ExpressionCache method appendVariableValue.

/**
	 * Given any arbitrary constant value, such as a Double, a String, etc.,
	 * format its value appropriately. For example, strings will be quoted.
	 *
	 * @param sb
	 *            a StringBuilder to which the formatted value will be appended.
	 * @param o
	 *            the value to format.
	 */
public static void appendVariableValue(StringBuilder sb, final Object o) {
    Value v;
    if (o instanceof Value) {
        v = (Value) o;
    } else {
        v = new Value() {

            public int getAttributes() {
                return 0;
            }

            public String[] getClassHierarchy(boolean allLevels) {
                return new String[0];
            }

            public String getClassName() {
                //$NON-NLS-1$
                return "";
            }

            public long getId() {
                return UNKNOWN_ID;
            }

            public int getMemberCount(Session s) throws NotSuspendedException, NoResponseException, NotConnectedException {
                return 0;
            }

            public Variable getMemberNamed(Session s, String name) throws NotSuspendedException, NoResponseException, NotConnectedException {
                return null;
            }

            public Variable[] getMembers(Session s) throws NotSuspendedException, NoResponseException, NotConnectedException {
                return new Variable[0];
            }

            public int getType() {
                if (o instanceof Number)
                    return VariableType.NUMBER;
                else if (o instanceof Boolean)
                    return VariableType.BOOLEAN;
                else if (o instanceof String)
                    return VariableType.STRING;
                else if (o == Value.UNDEFINED)
                    return VariableType.UNDEFINED;
                else if (o == null)
                    return VariableType.NULL;
                assert false;
                return VariableType.UNKNOWN;
            }

            public String getTypeName() {
                //$NON-NLS-1$
                return "";
            }

            public Object getValueAsObject() {
                return o;
            }

            public String getValueAsString() {
                return DValue.getValueAsString(o);
            }

            public boolean isAttributeSet(int variableAttribute) {
                return false;
            }

            public Variable[] getPrivateInheritedMembers() {
                return new Variable[0];
            }

            public Variable[] getPrivateInheritedMemberNamed(String name) {
                return new Variable[0];
            }
        };
    }
    appendVariableValue(sb, v);
}
Also used : Variable(flash.tools.debugger.Variable) NotConnectedException(flash.tools.debugger.NotConnectedException) Value(flash.tools.debugger.Value) DValue(flash.tools.debugger.concrete.DValue) NotSuspendedException(flash.tools.debugger.NotSuspendedException) NoResponseException(flash.tools.debugger.NoResponseException) Session(flash.tools.debugger.Session)

Example 2 with NotSuspendedException

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

the class DebugCLI method process.

/**
	 * Process this reader until its done
	 */
void process() throws IOException {
    boolean done = false;
    while (!done) {
        try {
            /**
				 * Now if we are in a session and that session is suspended then we go
				 * into a state where we wait for some user interaction to get us out
				 */
            runningLoop();
            /* if we are in the stdin then put out a prompt */
            if (!haveStreams())
                displayPrompt();
            /* now read in the next line */
            readLine();
            if (m_currentLine == null)
                break;
            done = processLine();
        } catch (NoResponseException nre) {
            //$NON-NLS-1$
            err(getLocalizationManager().getLocalizedTextString("noResponseException"));
        } catch (NotSuspendedException nse) {
            //$NON-NLS-1$
            err(getLocalizationManager().getLocalizedTextString("notSuspendedException"));
        } catch (AmbiguousException ae) {
        // we already put up a warning for the user
        } catch (IllegalStateException ise) {
            //$NON-NLS-1$
            err(getLocalizationManager().getLocalizedTextString("illegalStateException"));
        } catch (IllegalMonitorStateException ime) {
            //$NON-NLS-1$
            err(getLocalizationManager().getLocalizedTextString("illegalMonitorStateException"));
        } catch (NoSuchElementException nse) {
            //$NON-NLS-1$
            err(getLocalizationManager().getLocalizedTextString("noSuchElementException"));
        } catch (NumberFormatException nfe) {
            //$NON-NLS-1$
            err(getLocalizationManager().getLocalizedTextString("numberFormatException"));
        } catch (SocketException se) {
            Map socketArgs = new HashMap();
            //$NON-NLS-1$
            socketArgs.put("message", se.getMessage());
            //$NON-NLS-1$
            err(getLocalizationManager().getLocalizedTextString("socketException", socketArgs));
        } catch (VersionException ve) {
            //$NON-NLS-1$
            err(getLocalizationManager().getLocalizedTextString("versionException"));
        } catch (NotConnectedException nce) {
        // handled by isConnectionLost()
        } catch (Exception e) {
            //$NON-NLS-1$
            err(getLocalizationManager().getLocalizedTextString("unexpectedError"));
            //$NON-NLS-1$
            err(getLocalizationManager().getLocalizedTextString("stackTraceFollows"));
            e.printStackTrace();
        }
        // check for a lost connection and if it is clean-up!
        if (isConnectionLost()) {
            try {
                dumpHaltState(false);
            } catch (PlayerDebugException pde) {
                //$NON-NLS-1$
                err(getLocalizationManager().getLocalizedTextString("sessionEndedAbruptly"));
            }
        }
    }
}
Also used : SocketException(java.net.SocketException) NotConnectedException(flash.tools.debugger.NotConnectedException) HashMap(java.util.HashMap) NotSuspendedException(flash.tools.debugger.NotSuspendedException) PlayerDebugException(flash.tools.debugger.PlayerDebugException) VersionException(flash.tools.debugger.VersionException) PlayerFaultException(flash.tools.debugger.expression.PlayerFaultException) IncompleteExpressionException(flash.tools.debugger.expression.IncompleteExpressionException) ParseException(java.text.ParseException) PlayerDebugException(flash.tools.debugger.PlayerDebugException) NotSuspendedException(flash.tools.debugger.NotSuspendedException) EOFException(java.io.EOFException) SuspendedException(flash.tools.debugger.SuspendedException) FileNotFoundException(java.io.FileNotFoundException) InProgressException(flash.tools.debugger.InProgressException) NoResponseException(flash.tools.debugger.NoResponseException) UnknownOperationException(flash.tools.debugger.expression.UnknownOperationException) SocketException(java.net.SocketException) NoSuchVariableException(flash.tools.debugger.expression.NoSuchVariableException) SocketTimeoutException(java.net.SocketTimeoutException) NoSuchElementException(java.util.NoSuchElementException) EmptyStackException(java.util.EmptyStackException) IOException(java.io.IOException) NotConnectedException(flash.tools.debugger.NotConnectedException) NoResponseException(flash.tools.debugger.NoResponseException) Map(java.util.Map) HashMap(java.util.HashMap) NoSuchElementException(java.util.NoSuchElementException) VersionException(flash.tools.debugger.VersionException)

Example 3 with NotSuspendedException

use of flash.tools.debugger.NotSuspendedException 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)3 NoResponseException (flash.tools.debugger.NoResponseException)2 NotConnectedException (flash.tools.debugger.NotConnectedException)2 SuspendedException (flash.tools.debugger.SuspendedException)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 InProgressException (flash.tools.debugger.InProgressException)1 PlayerDebugException (flash.tools.debugger.PlayerDebugException)1 Session (flash.tools.debugger.Session)1 Value (flash.tools.debugger.Value)1 Variable (flash.tools.debugger.Variable)1 VersionException (flash.tools.debugger.VersionException)1 DValue (flash.tools.debugger.concrete.DValue)1 IncompleteExpressionException (flash.tools.debugger.expression.IncompleteExpressionException)1 NoSuchVariableException (flash.tools.debugger.expression.NoSuchVariableException)1 PlayerFaultException (flash.tools.debugger.expression.PlayerFaultException)1 UnknownOperationException (flash.tools.debugger.expression.UnknownOperationException)1 EOFException (java.io.EOFException)1 FileNotFoundException (java.io.FileNotFoundException)1