Search in sources :

Example 6 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 StringBuffer 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, StringBuffer 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 args = new HashMap();
                    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) Map(java.util.Map) HashMap(java.util.HashMap) Location(flash.tools.debugger.Location)

Example 7 with NotConnectedException

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

the class DebugCLI method doBreak.

/**
	 * Set a breakpoint
	 */
void doBreak() throws NotConnectedException {
    /* wait a bit if we are not halted */
    waitTilHalted();
    int module = propertyGet(LIST_MODULE);
    int line = propertyGet(LIST_LINE);
    String arg = null;
    /* currentXXX may NOT be invalid! */
    try {
        if (hasMoreTokens()) {
            arg = nextToken();
            int[] result = parseLocationArg(module, line, arg);
            module = result[0];
            line = result[1];
        } else {
            // no parameter mean use current location;  null pointer if nothing works
            Location l = getCurrentLocation();
            SourceFile file = l.getFile();
            module = file.getId();
            line = l.getLine();
        }
        //			// check to see if there are any existing breakpoints at this file/line
        //			LinkedList existingBreakpoints = new LinkedList();
        //			int start = 0;
        //			for (;;)
        //			{
        //				int bp = breakpointIndexOf(module, line, start, true);
        //				if (bp == -1)
        //					break; // no more matches
        //				boolean isEnabled = breakpointAt(bp).isEnabled();
        //				existingBreakpoints.add("" + bp + (isEnabled ? "" : " (disabled)"));
        //			}
        //			if (existingBreakpoints.size() > 0)
        //			{
        //				String
        //			}
        // go off; create it and set it
        // throws npe if not able to set
        BreakAction b = addBreakpoint(module, line);
        Location l = b.getLocation();
        int which = b.getId();
        String name = l.getFile().getName();
        int offset = adjustOffsetForUnitTests(l.getFile().getOffsetForLine(line));
        Map<String, Object> args = new HashMap<String, Object>();
        //$NON-NLS-1$
        args.put("breakpointNumber", Integer.toString(which));
        //$NON-NLS-1$
        args.put("file", name);
        //$NON-NLS-1$
        args.put("line", Integer.toString(line));
        String formatString;
        if (offset != 0) {
            //$NON-NLS-1$ //$NON-NLS-2$
            args.put("offset", "0x" + Integer.toHexString(offset));
            //$NON-NLS-1$
            formatString = "createdBreakpointWithOffset";
        } else {
            //$NON-NLS-1$
            formatString = "createdBreakpoint";
        }
        out(getLocalizationManager().getLocalizedTextString(formatString, args));
        // worked so add it to our tracking state
        propertyPut(BPNUM, which);
    } catch (ParseException pe) {
        err(pe.getMessage());
    } catch (AmbiguousException ae) {
        err(ae.getMessage());
    } catch (NoMatchException nme) {
        // We couldn't find a function name or filename which matched what
        // the user entered.  Do *not* fail; instead, just save this breakpoint
        // away, and later, as more ABCs get loaded from the SWF, we may be
        // able to resolve this breakpoint.
        BreakAction b = addUnresolvedBreakpoint(arg);
        Map<String, Object> args = new HashMap<String, Object>();
        //$NON-NLS-1$
        args.put("breakpointNumber", Integer.toString(b.getId()));
        //$NON-NLS-1$
        out(getLocalizationManager().getLocalizedTextString("breakpointCreatedButNotYetResolved", args));
        // add it to our tracking state
        propertyPut(BPNUM, b.getId());
    } catch (NullPointerException npe) {
        String filename;
        try {
            //$NON-NLS-1$
            filename = m_fileInfo.getFile(module).getName() + "#" + module;
        } catch (Exception e) {
            Map<String, Object> args = new HashMap<String, Object>();
            //$NON-NLS-1$
            args.put("fileNumber", Integer.toString(module));
            //$NON-NLS-1$
            filename = getLocalizationManager().getLocalizedTextString("fileNumber", args);
        }
        Map<String, Object> args = new HashMap<String, Object>();
        //$NON-NLS-1$
        args.put("filename", filename);
        //$NON-NLS-1$
        args.put("line", Integer.toString(line));
        //$NON-NLS-1$
        err(getLocalizationManager().getLocalizedTextString("breakpointNotSetNoCode", args));
    }
}
Also used : HashMap(java.util.HashMap) VersionException(flash.tools.debugger.VersionException) PlayerFaultException(flash.tools.debugger.expression.PlayerFaultException) ParseException(java.text.ParseException) NotSupportedException(flash.tools.debugger.NotSupportedException) 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) SocketException(java.net.SocketException) NoSuchVariableException(flash.tools.debugger.expression.NoSuchVariableException) SocketTimeoutException(java.net.SocketTimeoutException) NoSuchElementException(java.util.NoSuchElementException) IOException(java.io.IOException) NotConnectedException(flash.tools.debugger.NotConnectedException) SourceFile(flash.tools.debugger.SourceFile) ParseException(java.text.ParseException) Map(java.util.Map) HashMap(java.util.HashMap) 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