Search in sources :

Example 1 with NotConnectedException

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

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

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

the class DebugCLI method tryResolveBreakpoint.

/**
	 * Try to resolve one breakpoint.  We do this every time a new ABC or
	 * SWF is loaded.
	 * @param b the breakpoint to resolve (it's okay if it's already resolved)
	 * @param sb a StringBuilder to which any messages for are appended;
	 * 			to the user.
	 * @return true if the breakpoint is resolved
	 * @throws AmbiguousException
	 * @throws NullPointerException 
	 */
private boolean tryResolveBreakpoint(BreakAction b, StringBuilder sb) throws AmbiguousException {
    int status = b.getStatus();
    boolean resolved = (status == BreakAction.RESOLVED);
    if (// we don't do anything for RESOLVED or AMBIGUOUS
    status == BreakAction.UNRESOLVED) {
        /* wait a bit if we are not halted */
        try {
            waitTilHalted();
            // a filename and line number.
            if (enableBreakpoint(b, b.isAutoDisable(), b.isAutoDelete())) {
                resolved = true;
            } else {
                int module = propertyGet(LIST_MODULE);
                int line = propertyGet(LIST_LINE);
                String arg = b.getBreakpointExpression();
                if (arg != null) {
                    int[] result = parseLocationArg(module, line, arg);
                    // whoo-hoo, it resolved!
                    module = result[0];
                    line = result[1];
                    // use module SourceFile to denote the name of file in which we wish to set a breakpoint
                    SourceFile f = m_fileInfo.getFile(module);
                    LocationCollection col = enableBreak(f, line);
                    if (col.isEmpty())
                        //$NON-NLS-1$
                        throw new NullPointerException(getLocalizationManager().getLocalizedTextString("noExecutableCode"));
                    b.setLocations(col);
                    Location l = col.first();
                    SourceFile file = (l != null) ? l.getFile() : null;
                    String funcName = (file == null) ? null : file.getFunctionNameForLine(m_session, l.getLine());
                    Map<String, Object> args = new HashMap<String, Object>();
                    String formatString;
                    //$NON-NLS-1$
                    args.put("breakpointNumber", Integer.toString(b.getId()));
                    String filename = file.getName();
                    if (b.isSingleSwf() && file != null) {
                        //$NON-NLS-1$
                        filename = filename + "#" + file.getId();
                    }
                    //$NON-NLS-1$
                    args.put("file", filename);
                    //$NON-NLS-1$
                    args.put("line", new Integer(l.getLine()));
                    if (funcName != null) {
                        //$NON-NLS-1$
                        args.put("functionName", funcName);
                        //$NON-NLS-1$
                        formatString = "resolvedBreakpointToFunction";
                    } else {
                        //$NON-NLS-1$
                        formatString = "resolvedBreakpointToFile";
                    }
                    sb.append(getLocalizationManager().getLocalizedTextString(formatString, args));
                    sb.append(m_newline);
                    sb.append(m_newline);
                    resolved = true;
                }
            }
        } catch (NotConnectedException e) {
        // Ignore
        } catch (NoMatchException e) {
        // Okay, it's still not resolved; do nothing
        } catch (ParseException e) {
            // this shouldn't happen
            if (Trace.error)
                Trace.trace(e.toString());
        } catch (AmbiguousException e) {
            b.setStatus(BreakAction.AMBIGUOUS);
            // rethrow
            throw e;
        } catch (NullPointerException e) {
            b.setStatus(BreakAction.NOCODE);
            // rethrow
            throw e;
        }
    }
    return resolved;
}
Also used : NotConnectedException(flash.tools.debugger.NotConnectedException) HashMap(java.util.HashMap) SourceFile(flash.tools.debugger.SourceFile) ParseException(java.text.ParseException) Location(flash.tools.debugger.Location)

Example 4 with NotConnectedException

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

the class SWFDebugSession method stackTrace.

public void stackTrace(Response response, StackTraceRequest.StackTraceArguments arguments) {
    List<StackFrame> stackFrames = new ArrayList<>();
    try {
        Frame[] swfFrames = swfSession.getFrames();
        for (int i = 0, count = swfFrames.length; i < count; i++) {
            Frame swfFrame = swfFrames[i];
            Location location = swfFrame.getLocation();
            SourceFile file = location.getFile();
            StackFrame stackFrame = new StackFrame();
            stackFrame.id = i;
            stackFrame.name = swfFrame.getCallSignature();
            if (file != null) {
                Source source = new Source();
                source.name = file.getName();
                source.path = transformPath(file.getFullPath());
                stackFrame.source = source;
                stackFrame.line = location.getLine();
                stackFrame.column = 0;
            }
            stackFrames.add(stackFrame);
        }
    } catch (NotConnectedException e) {
    //ignore
    }
    sendResponse(response, new StackTraceResponseBody(stackFrames));
}
Also used : StackTraceResponseBody(com.nextgenactionscript.vscode.debug.responses.StackTraceResponseBody) StackFrame(com.nextgenactionscript.vscode.debug.responses.StackFrame) Frame(flash.tools.debugger.Frame) NotConnectedException(flash.tools.debugger.NotConnectedException) StackFrame(com.nextgenactionscript.vscode.debug.responses.StackFrame) ArrayList(java.util.ArrayList) SourceFile(flash.tools.debugger.SourceFile) SourceBreakpoint(com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint) Breakpoint(com.nextgenactionscript.vscode.debug.responses.Breakpoint) Source(com.nextgenactionscript.vscode.debug.requests.Source) Location(flash.tools.debugger.Location)

Example 5 with NotConnectedException

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

the class SWFDebugSession method setBreakpoints.

public void setBreakpoints(Response response, SetBreakpointsRequest.SetBreakpointsArguments arguments) {
    String path = arguments.source.path;
    Path pathAsPath = Paths.get(path);
    List<Breakpoint> breakpoints = new ArrayList<>();
    for (int i = 0, count = arguments.breakpoints.length; i < count; i++) {
        SourceBreakpoint sourceBreakpoint = arguments.breakpoints[i];
        int sourceLine = sourceBreakpoint.line;
        Breakpoint responseBreakpoint = new Breakpoint();
        responseBreakpoint.line = sourceLine;
        int fileId = -1;
        try {
            SwfInfo[] swfs = swfSession.getSwfs();
            for (SwfInfo swf : swfs) {
                SourceFile[] sourceFiles = swf.getSourceList(swfSession);
                for (SourceFile sourceFile : sourceFiles) {
                    //file system case sensitivity.
                    if (pathAsPath.equals(Paths.get(sourceFile.getFullPath())) && (path.endsWith(FILE_EXTENSION_AS) || path.endsWith(FILE_EXTENSION_MXML))) {
                        fileId = sourceFile.getId();
                        break;
                    }
                }
                if (fileId != -1) {
                    break;
                }
            }
            if (fileId == -1) {
                //either the file was not found, or it has an unsupported
                //extension
                responseBreakpoint.verified = false;
            } else {
                Location breakpointLocation = swfSession.setBreakpoint(fileId, sourceLine);
                if (breakpointLocation != null) {
                    //I don't know if the line could change, but might as well
                    //use the one returned by the location
                    responseBreakpoint.line = breakpointLocation.getLine();
                    responseBreakpoint.verified = true;
                } else {
                    //setBreakpoint() may return null if the breakpoint could
                    //not be set. that's fine. the user will see that the
                    //breakpoint is not verified, so it's fine.
                    responseBreakpoint.verified = false;
                }
            }
        } catch (InProgressException e) {
            e.printStackTrace(System.err);
            responseBreakpoint.verified = false;
        } catch (NoResponseException e) {
            e.printStackTrace(System.err);
            responseBreakpoint.verified = false;
        } catch (NotConnectedException e) {
            e.printStackTrace(System.err);
            responseBreakpoint.verified = false;
        }
        breakpoints.add(responseBreakpoint);
    }
    sendResponse(response, new SetBreakpointsResponseBody(breakpoints));
}
Also used : Path(java.nio.file.Path) SourceBreakpoint(com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint) Breakpoint(com.nextgenactionscript.vscode.debug.responses.Breakpoint) InProgressException(flash.tools.debugger.InProgressException) NotConnectedException(flash.tools.debugger.NotConnectedException) SwfInfo(flash.tools.debugger.SwfInfo) ArrayList(java.util.ArrayList) SetBreakpointsResponseBody(com.nextgenactionscript.vscode.debug.responses.SetBreakpointsResponseBody) SourceBreakpoint(com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint) Breakpoint(com.nextgenactionscript.vscode.debug.responses.Breakpoint) SourceBreakpoint(com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint) SourceFile(flash.tools.debugger.SourceFile) NoResponseException(flash.tools.debugger.NoResponseException) Location(flash.tools.debugger.Location)

Aggregations

NotConnectedException (flash.tools.debugger.NotConnectedException)7 Location (flash.tools.debugger.Location)5 SourceFile (flash.tools.debugger.SourceFile)5 NoResponseException (flash.tools.debugger.NoResponseException)4 ParseException (java.text.ParseException)4 HashMap (java.util.HashMap)4 InProgressException (flash.tools.debugger.InProgressException)3 NotSuspendedException (flash.tools.debugger.NotSuspendedException)3 Map (java.util.Map)3 SourceBreakpoint (com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint)2 Breakpoint (com.nextgenactionscript.vscode.debug.responses.Breakpoint)2 PlayerDebugException (flash.tools.debugger.PlayerDebugException)2 SuspendedException (flash.tools.debugger.SuspendedException)2 VersionException (flash.tools.debugger.VersionException)2 NoSuchVariableException (flash.tools.debugger.expression.NoSuchVariableException)2 PlayerFaultException (flash.tools.debugger.expression.PlayerFaultException)2 EOFException (java.io.EOFException)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 SocketException (java.net.SocketException)2