Search in sources :

Example 1 with PlayerDebugException

use of flash.tools.debugger.PlayerDebugException in project vscode-nextgenas by BowlerHatLLC.

the class SWFDebugSession method scopes.

public void scopes(Response response, ScopesRequest.ScopesArguments arguments) {
    List<Scope> scopes = new ArrayList<>();
    int frameId = arguments.frameId;
    try {
        Frame[] swfFrames = swfSession.getFrames();
        if (frameId >= 0 && frameId < swfFrames.length) {
            Scope localScope = new Scope();
            localScope.name = "Locals";
            //this is a hacky way to store the frameId
            localScope.variablesReference = frameId * 10 + LOCAL_VARIABLES_REFERENCE;
            scopes.add(localScope);
        }
    } catch (PlayerDebugException e) {
    //ignore and return no scopes
    }
    sendResponse(response, new ScopesResponseBody(scopes));
}
Also used : ScopesResponseBody(com.nextgenactionscript.vscode.debug.responses.ScopesResponseBody) StackFrame(com.nextgenactionscript.vscode.debug.responses.StackFrame) Frame(flash.tools.debugger.Frame) Scope(com.nextgenactionscript.vscode.debug.responses.Scope) ArrayList(java.util.ArrayList) PlayerDebugException(flash.tools.debugger.PlayerDebugException) SourceBreakpoint(com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint) Breakpoint(com.nextgenactionscript.vscode.debug.responses.Breakpoint)

Example 2 with PlayerDebugException

use of flash.tools.debugger.PlayerDebugException in project vscode-nextgenas by BowlerHatLLC.

the class SWFDebugSession method variables.

public void variables(Response response, VariablesRequest.VariablesArguments arguments) {
    List<Variable> variables = new ArrayList<>();
    try {
        Value swfValue = null;
        long variablesReference = arguments.variablesReference;
        int frameId = -1;
        if (variablesReference < 1000) {
            frameId = (int) variablesReference / 10;
            variablesReference -= frameId * 10;
        }
        flash.tools.debugger.Variable[] members = null;
        if (variablesReference == LOCAL_VARIABLES_REFERENCE) {
            Frame[] swfFrames = swfSession.getFrames();
            if (frameId >= 0 && frameId < swfFrames.length) {
                Frame swfFrame = swfFrames[frameId];
                flash.tools.debugger.Variable[] args = swfFrame.getArguments(swfSession);
                flash.tools.debugger.Variable[] locals = swfFrame.getLocals(swfSession);
                flash.tools.debugger.Variable swfThis = swfFrame.getThis(swfSession);
                int memberCount = locals.length + args.length;
                int offset = 0;
                if (swfThis != null) {
                    offset = 1;
                }
                members = new flash.tools.debugger.Variable[memberCount + offset];
                if (swfThis != null) {
                    members[0] = swfThis;
                }
                System.arraycopy(args, 0, members, offset, args.length);
                System.arraycopy(locals, 0, members, args.length + offset, locals.length);
            } else {
                members = new flash.tools.debugger.Variable[0];
            }
        } else {
            swfValue = swfSession.getValue(arguments.variablesReference);
            members = swfValue.getMembers(swfSession);
        }
        for (flash.tools.debugger.Variable member : members) {
            Value memberValue = member.getValue();
            Variable variable = new Variable();
            variable.name = member.getName();
            variable.type = memberValue.getTypeName();
            long id = memberValue.getId();
            if (id != Value.UNKNOWN_ID) {
                variable.value = memberValue.getTypeName();
                variable.variablesReference = memberValue.getId();
            } else {
                if (memberValue.getType() == VariableType.STRING) {
                    variable.value = "\"" + memberValue.getValueAsString() + "\"";
                } else {
                    variable.value = memberValue.getValueAsString();
                }
            }
            variables.add(variable);
        }
    } catch (PlayerDebugException e) {
    //ignore
    }
    sendResponse(response, new VariablesResponseBody(variables));
}
Also used : StackFrame(com.nextgenactionscript.vscode.debug.responses.StackFrame) Frame(flash.tools.debugger.Frame) Variable(com.nextgenactionscript.vscode.debug.responses.Variable) ArrayList(java.util.ArrayList) PlayerDebugException(flash.tools.debugger.PlayerDebugException) VariablesResponseBody(com.nextgenactionscript.vscode.debug.responses.VariablesResponseBody) SourceBreakpoint(com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint) Breakpoint(com.nextgenactionscript.vscode.debug.responses.Breakpoint) Value(flash.tools.debugger.Value)

Example 3 with PlayerDebugException

use of flash.tools.debugger.PlayerDebugException 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 4 with PlayerDebugException

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

the class DebugCLI method doNext.

/**
	 * Perform step over, optional COUNT parameter
	 */
void doNext() throws PlayerDebugException {
    waitTilHalted();
    if (!allowedToStep())
        return;
    int count = 1;
    if (hasMoreTokens())
        count = nextIntToken();
    try {
        while (count-- > 0) {
            stepWithTimeout(new AnyKindOfStep() {

                public void step() throws PlayerDebugException {
                    m_session.stepOver();
                }
            });
            for (; ; ) {
                dumpStep();
                if (// perhaps we hit a conditional breakpoint
                m_requestResume) {
                    m_requestResume = false;
                    stepWithTimeout(new AnyKindOfStep() {

                        public void step() throws PlayerDebugException {
                            m_session.stepContinue();
                        }
                    });
                } else {
                    break;
                }
            }
        }
    } catch (NoResponseException nre) {
        if (count > 0) {
            Map args = new HashMap();
            //$NON-NLS-1$
            args.put("count", Integer.toString(count));
            //$NON-NLS-1$
            err(getLocalizationManager().getLocalizedTextString("abortingStep", args));
        }
    }
    m_repeatLine = m_currentLine;
}
Also used : HashMap(java.util.HashMap) PlayerDebugException(flash.tools.debugger.PlayerDebugException) NoResponseException(flash.tools.debugger.NoResponseException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with PlayerDebugException

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

the class DebugCLI method handleFault.

/**
	 * We have received a fault and are possibly suspended at this point.
	 * We need to look at our fault table and determine what do.
	 * @return true if we resumed execution
	 */
boolean handleFault(FaultEvent e) {
    // lookup what we need to do
    boolean requestResume = false;
    String name = e.name();
    boolean stop = true;
    boolean print = true;
    try {
        //$NON-NLS-1$
        print = m_faultTable.is(name, "print");
        //$NON-NLS-1$
        stop = m_faultTable.is(name, "stop");
    } catch (NullPointerException npe) {
        if (Trace.error) {
            Map<String, Object> args = new HashMap<String, Object>();
            //$NON-NLS-1$
            args.put("faultName", name);
            //$NON-NLS-1$
            Trace.trace(getLocalizationManager().getLocalizedTextString("faultHasNoTableEntry", args));
            npe.printStackTrace();
        }
    }
    if (e instanceof ExceptionFault) {
        ExceptionFault ef = (ExceptionFault) e;
        Value thrownValue = ef.getThrownValue();
        if (thrownValue != null) {
            if (!ef.willExceptionBeCaught()) {
                stop = true;
            } else {
                stop = false;
                String typeName = thrownValue.getTypeName();
                int at = typeName.indexOf('@');
                if (at != -1)
                    typeName = typeName.substring(0, at);
                for (int i = 0; i < catchpointCount(); ++i) {
                    CatchAction c = catchpointAt(i);
                    String typeToCatch = c.getTypeToCatch();
                    try {
                        if (typeToCatch == null || getSession().evalIs(thrownValue, typeToCatch)) {
                            stop = true;
                            break;
                        }
                    } catch (PlayerDebugException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                        stop = true;
                    } catch (PlayerFaultException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                        stop = true;
                    }
                }
                if (!stop)
                    print = false;
            }
        }
    }
    // should we stop?
    if (!stop)
        requestResume = true;
    if (print)
        dumpFaultLine(e);
    return requestResume;
}
Also used : ExceptionFault(flash.tools.debugger.events.ExceptionFault) Value(flash.tools.debugger.Value) PlayerFaultException(flash.tools.debugger.expression.PlayerFaultException) PlayerDebugException(flash.tools.debugger.PlayerDebugException) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

PlayerDebugException (flash.tools.debugger.PlayerDebugException)8 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Frame (flash.tools.debugger.Frame)3 InProgressException (flash.tools.debugger.InProgressException)3 Location (flash.tools.debugger.Location)3 SourceBreakpoint (com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint)2 Breakpoint (com.nextgenactionscript.vscode.debug.responses.Breakpoint)2 StackFrame (com.nextgenactionscript.vscode.debug.responses.StackFrame)2 NoResponseException (flash.tools.debugger.NoResponseException)2 SourceFile (flash.tools.debugger.SourceFile)2 Value (flash.tools.debugger.Value)2 PlayerFaultException (flash.tools.debugger.expression.PlayerFaultException)2 ArrayList (java.util.ArrayList)2 Scope (com.nextgenactionscript.vscode.debug.responses.Scope)1 ScopesResponseBody (com.nextgenactionscript.vscode.debug.responses.ScopesResponseBody)1 Variable (com.nextgenactionscript.vscode.debug.responses.Variable)1 VariablesResponseBody (com.nextgenactionscript.vscode.debug.responses.VariablesResponseBody)1 NotConnectedException (flash.tools.debugger.NotConnectedException)1 NotSuspendedException (flash.tools.debugger.NotSuspendedException)1