Search in sources :

Example 1 with VersionException

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

the class SWFDebugSession method launch.

public void launch(Response response, LaunchRequest.LaunchRequestArguments args) {
    LaunchRequestArguments swfArgs = (LaunchRequestArguments) args;
    ThreadSafeSessionManager manager = ThreadSafeBootstrap.sessionManager();
    swfSession = null;
    try {
        manager.startListening();
        if (manager.supportsLaunch()) {
            String program = swfArgs.program;
            Path programPath = Paths.get(program);
            if (!programPath.isAbsolute()) {
                //if it's not an absolute path, we'll treat it as a
                //relative path within the workspace
                String workspacePath = System.getProperty(WORKSPACE_PROPERTY);
                if (workspacePath != null) {
                    program = Paths.get(workspacePath).resolve(programPath).toAbsolutePath().toString();
                }
            }
            Player player = null;
            CustomRuntimeLauncher launcher = null;
            if (swfArgs.runtimeExecutable != null) {
                //if runtimeExecutable is specified, we'll launch that
                launcher = new CustomRuntimeLauncher(swfArgs.runtimeExecutable, swfArgs.runtimeArgs);
            } else {
                //otherwise, let the SWF debugger automatically figure out
                //which runtime is required based on the program path
                String playerPath = program;
                try {
                    URI uri = Paths.get(playerPath).toUri();
                    playerPath = uri.toString();
                } catch (Exception e) {
                //safe to ignore
                }
                player = manager.playerForUri(playerPath, null);
                if (player == null && !playerPath.startsWith("http:") && !playerPath.startsWith("https:") && playerPath.endsWith(".swf")) {
                    if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
                        launcher = findWindowsStandalonePlayer();
                    } else if (//linux
                    !System.getProperty("os.name").toLowerCase().startsWith("mac os")) {
                        launcher = findLinuxStandalonePlayer();
                    }
                }
            }
            if (player == null && launcher == null) {
                sendErrorResponse(response, 10001, "Error launching SWF debug session. Runtime not found for program: " + program);
                return;
            } else {
                AIRLaunchInfo launchInfo = null;
                //check if the debugger automatically detected AIR
                boolean isAIR = player != null && player.getType() == Player.AIR;
                if (!isAIR && player == null && program.endsWith(FILE_EXTENSION_XML)) {
                    //otherwise, check if the program to launch is an AIR
                    //application descriptor
                    isAIR = true;
                }
                if (isAIR && adlPath != null) {
                    launchInfo = new AIRLaunchInfo();
                    launchInfo.profile = swfArgs.profile;
                    launchInfo.screenSize = swfArgs.screensize;
                    launchInfo.dpi = swfArgs.screenDPI;
                    launchInfo.versionPlatform = swfArgs.versionPlatform;
                    launchInfo.airDebugLauncher = adlPath.toFile();
                    launchInfo.extDir = swfArgs.extdir;
                    if (launcher != null) {
                        launcher.isAIR = true;
                    }
                }
                if (launcher != null) {
                    swfSession = (ThreadSafeSession) manager.launch(program, launchInfo, true, null, null, launcher);
                } else {
                    swfSession = (ThreadSafeSession) manager.launch(program, launchInfo, true, null, null);
                }
            }
        }
    } catch (CommandLineException e) {
        OutputEvent.OutputBody body = new OutputEvent.OutputBody();
        body.output = e.getMessage() + "\n" + e.getCommandOutput();
        body.category = OutputEvent.CATEGORY_STDERR;
        sendEvent(new OutputEvent(body));
        e.printStackTrace(System.err);
        sendErrorResponse(response, 10001, "Error launching SWF debug session. Process exited with code: " + e.getExitValue());
        return;
    } catch (IOException e) {
        e.printStackTrace(System.err);
        sendErrorResponse(response, 10001, "Error launching SWF debug session.");
        return;
    }
    try {
        swfSession.bind();
    } catch (VersionException e) {
        e.printStackTrace(System.err);
    }
    try {
        manager.stopListening();
    } catch (IOException e) {
        e.printStackTrace(System.err);
    }
    sendResponse(response);
    cancelRunner = false;
    sessionThread = new java.lang.Thread(new SessionRunner());
    sessionThread.start();
}
Also used : Path(java.nio.file.Path) OutputEvent(com.nextgenactionscript.vscode.debug.events.OutputEvent) Player(flash.tools.debugger.Player) AIRLaunchInfo(flash.tools.debugger.AIRLaunchInfo) IOException(java.io.IOException) URI(java.net.URI) VersionException(flash.tools.debugger.VersionException) PlayerDebugException(flash.tools.debugger.PlayerDebugException) InProgressException(flash.tools.debugger.InProgressException) NoResponseException(flash.tools.debugger.NoResponseException) JsonParseException(com.google.gson.JsonParseException) IOException(java.io.IOException) NotConnectedException(flash.tools.debugger.NotConnectedException) CommandLineException(flash.tools.debugger.CommandLineException) CommandLineException(flash.tools.debugger.CommandLineException) ThreadSafeSessionManager(flash.tools.debugger.threadsafe.ThreadSafeSessionManager) VersionException(flash.tools.debugger.VersionException)

Example 2 with VersionException

use of flash.tools.debugger.VersionException 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)

Aggregations

InProgressException (flash.tools.debugger.InProgressException)2 NoResponseException (flash.tools.debugger.NoResponseException)2 NotConnectedException (flash.tools.debugger.NotConnectedException)2 PlayerDebugException (flash.tools.debugger.PlayerDebugException)2 VersionException (flash.tools.debugger.VersionException)2 IOException (java.io.IOException)2 JsonParseException (com.google.gson.JsonParseException)1 OutputEvent (com.nextgenactionscript.vscode.debug.events.OutputEvent)1 AIRLaunchInfo (flash.tools.debugger.AIRLaunchInfo)1 CommandLineException (flash.tools.debugger.CommandLineException)1 NotSuspendedException (flash.tools.debugger.NotSuspendedException)1 Player (flash.tools.debugger.Player)1 SuspendedException (flash.tools.debugger.SuspendedException)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 ThreadSafeSessionManager (flash.tools.debugger.threadsafe.ThreadSafeSessionManager)1 EOFException (java.io.EOFException)1 FileNotFoundException (java.io.FileNotFoundException)1