Search in sources :

Example 1 with SwfInfo

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

the class DebugCLI method propagateBreakpoints.

/**
     * Propagate current breakpoints to the newly loaded swf.
     */
void propagateBreakpoints() throws NotConnectedException {
    // get the newly added swf, which lands at the end list
    SwfInfo[] swfs = m_fileInfo.getSwfs();
    SwfInfo swf = (swfs.length > 1) ? swfs[swfs.length - 1] : null;
    // now walk through all breakpoints propagating the 
    // the break for each source and line number we
    // find in the new swf
    int size = m_breakpoints.size();
    for (int i = 0; (swf != null) && i < size; i++) {
        // dont do this for single swf breakpoints
        BreakAction bp = breakpointAt(i);
        if (bp.isSingleSwf())
            continue;
        if (bp.getStatus() != BreakAction.RESOLVED)
            continue;
        try {
            Location l = bp.getLocation();
            int line = l.getLine();
            SourceFile f = l.getFile();
            Location newLoc = findAndEnableBreak(swf, f, line);
            if (newLoc != null)
                bp.addLocation(newLoc);
        } catch (InProgressException ipe) {
            if (breakpointCount() > 0) {
                Map<String, Object> args = new HashMap<String, Object>();
                //$NON-NLS-1$
                args.put("breakpointNumber", Integer.toString(bp.getId()));
                //$NON-NLS-1$
                out(getLocalizationManager().getLocalizedTextString("breakpointNotPropagated", args));
            }
        }
    }
}
Also used : InProgressException(flash.tools.debugger.InProgressException) SwfInfo(flash.tools.debugger.SwfInfo) DSwfInfo(flash.tools.debugger.concrete.DSwfInfo) SourceFile(flash.tools.debugger.SourceFile) Map(java.util.Map) HashMap(java.util.HashMap) Location(flash.tools.debugger.Location)

Example 2 with SwfInfo

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

the class DebugCLI method doShowLocations.

void doShowLocations() {
    StringBuilder sb = new StringBuilder();
    sb.append("Num Type           Disp Enb Address    What" + m_newline);
    // our list of breakpoints
    int count = breakpointCount();
    for (int i = 0; i < count; i++) {
        BreakAction b = breakpointAt(i);
        int num = b.getId();
        FieldFormat.formatLong(sb, num, 3);
        sb.append(" breakpoint     ");
        if (b.isAutoDisable())
            sb.append("dis  ");
        else if (b.isAutoDelete())
            sb.append("del  ");
        else
            sb.append("keep ");
        if (b.isEnabled())
            sb.append("y   ");
        else
            sb.append("n   ");
        Iterator<Location> itr = b.getLocations().iterator();
        while (itr.hasNext()) {
            Location l = itr.next();
            SourceFile file = l.getFile();
            String funcName = (file == null) ? //$NON-NLS-1$
            getLocalizationManager().getLocalizedTextString("unknownBreakpointLocation") : file.getFunctionNameForLine(m_session, l.getLine());
            int offset = adjustOffsetForUnitTests((file == null) ? 0 : file.getOffsetForLine(l.getLine()));
            //$NON-NLS-1$
            sb.append("0x");
            FieldFormat.formatLongToHex(sb, offset, 8);
            sb.append(' ');
            if (funcName != null) {
                Map<String, Object> funcArgs = new HashMap<String, Object>();
                //$NON-NLS-1$
                funcArgs.put("functionName", funcName);
                //$NON-NLS-1$
                sb.append(getLocalizationManager().getLocalizedTextString("inFunctionAt", funcArgs));
            }
            sb.append(file.getName());
            if (file != null) {
                //$NON-NLS-1$
                sb.append("#");
                sb.append(file.getId());
            }
            sb.append(':');
            sb.append(l.getLine());
            try {
                SwfInfo info = m_fileInfo.swfForFile(file);
                Map<String, Object> swfArgs = new HashMap<String, Object>();
                //$NON-NLS-1$
                swfArgs.put("swf", FileInfoCache.shortNameOfSwf(info));
                //$NON-NLS-1$
                sb.append(getLocalizationManager().getLocalizedTextString("inSwf", swfArgs));
            } catch (NullPointerException npe) {
                // can't find the swf
                //$NON-NLS-1$
                sb.append(getLocalizationManager().getLocalizedTextString("nonRestorable"));
            }
            sb.append(m_newline);
            if (itr.hasNext())
                //$NON-NLS-1$
                sb.append("                            ");
        }
    }
    out(sb.toString());
}
Also used : HashMap(java.util.HashMap) SwfInfo(flash.tools.debugger.SwfInfo) DSwfInfo(flash.tools.debugger.concrete.DSwfInfo) SourceFile(flash.tools.debugger.SourceFile) Location(flash.tools.debugger.Location)

Example 3 with SwfInfo

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

the class DebugCLI method doInfoSwfs.

/**
	 * Dump some stats about our currently loaded swfs.
	 */
void doInfoSwfs() {
    try {
        StringBuilder sb = new StringBuilder();
        SwfInfo[] swfs = m_fileInfo.getSwfs();
        for (int i = 0; i < swfs.length; i++) {
            SwfInfo e = swfs[i];
            if (e == null || e.isUnloaded())
                continue;
            Map<String, Object> args = new HashMap<String, Object>();
            //$NON-NLS-1$
            args.put("swfName", FileInfoCache.nameOfSwf(e));
            //$NON-NLS-1$
            args.put("size", NumberFormat.getInstance().format(e.getSwfSize()));
            try {
                int size = e.getSwdSize(m_session);
                // our swd is loaded so let's comb through our
                // list of scripts and locate the range of ids.
                SourceFile[] files = e.getSourceList(m_session);
                int max = Integer.MIN_VALUE;
                int min = Integer.MAX_VALUE;
                for (int j = 0; j < files.length; j++) {
                    SourceFile f = files[j];
                    int id = f.getId();
                    max = (id > max) ? id : max;
                    min = (id < min) ? id : min;
                }
                //$NON-NLS-1$
                args.put("scriptCount", Integer.toString(e.getSourceCount(m_session)));
                //$NON-NLS-1$
                args.put("min", Integer.toString(min));
                //$NON-NLS-1$
                args.put("max", Integer.toString(max));
                //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                args.put("plus", (e.isProcessingComplete()) ? "+" : "");
                //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                args.put("moreInfo", (size == 0) ? getLocalizationManager().getLocalizedTextString("remainingSourceBeingLoaded") : "");
            } catch (InProgressException ipe) {
                //$NON-NLS-1$
                sb.append(getLocalizationManager().getLocalizedTextString("debugInfoBeingLoaded"));
            }
            //$NON-NLS-1$
            args.put("url", e.getUrl());
            //$NON-NLS-1$
            sb.append(getLocalizationManager().getLocalizedTextString("swfInfo", args));
            sb.append(m_newline);
        }
        out(sb.toString());
    } catch (NullPointerException npe) {
        //$NON-NLS-1$
        err(getLocalizationManager().getLocalizedTextString("noSWFs"));
    }
}
Also used : InProgressException(flash.tools.debugger.InProgressException) HashMap(java.util.HashMap) SwfInfo(flash.tools.debugger.SwfInfo) DSwfInfo(flash.tools.debugger.concrete.DSwfInfo) SourceFile(flash.tools.debugger.SourceFile)

Example 4 with SwfInfo

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

Example 5 with SwfInfo

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

the class DebugCLI method doInfoBreak.

void doInfoBreak() throws NotConnectedException {
    //		waitTilHalted();
    StringBuilder sb = new StringBuilder();
    sb.append("Num Type           Disp Enb Address    What" + m_newline);
    // our list of breakpoints
    int count = breakpointCount();
    for (int i = 0; i < count; i++) {
        BreakAction b = breakpointAt(i);
        int status = b.getStatus();
        boolean isResolved = (status == BreakAction.RESOLVED);
        Location l = b.getLocation();
        SourceFile file = (l != null) ? l.getFile() : null;
        String funcName = (file == null) ? null : file.getFunctionNameForLine(m_session, l.getLine());
        boolean singleSwf = b.isSingleSwf();
        int cmdCount = b.getCommandCount();
        int hits = b.getHits();
        String cond = b.getConditionString();
        boolean silent = b.isSilent();
        int offset = adjustOffsetForUnitTests((file == null) ? 0 : file.getOffsetForLine(l.getLine()));
        int num = b.getId();
        FieldFormat.formatLong(sb, num, 3);
        sb.append(" breakpoint     ");
        if (b.isAutoDisable())
            sb.append("dis  ");
        else if (b.isAutoDelete())
            sb.append("del  ");
        else
            sb.append("keep ");
        if (b.isEnabled())
            sb.append("y   ");
        else
            sb.append("n   ");
        //$NON-NLS-1$
        sb.append("0x");
        FieldFormat.formatLongToHex(sb, offset, 8);
        sb.append(' ');
        if (funcName != null) {
            Map<String, Object> args = new HashMap<String, Object>();
            //$NON-NLS-1$
            args.put("functionName", funcName);
            //$NON-NLS-1$
            sb.append(getLocalizationManager().getLocalizedTextString("inFunctionAt", args));
        }
        if (file != null) {
            sb.append(file.getName());
            if (isResolved && singleSwf) {
                //$NON-NLS-1$
                sb.append("#");
                sb.append(file.getId());
            }
            sb.append(':');
            sb.append(l.getLine());
        } else {
            String expr = b.getBreakpointExpression();
            if (expr != null)
                sb.append(expr);
        }
        switch(status) {
            case BreakAction.UNRESOLVED:
                //$NON-NLS-1$
                sb.append(getLocalizationManager().getLocalizedTextString("breakpointNotYetResolved"));
                break;
            case BreakAction.AMBIGUOUS:
                //$NON-NLS-1$
                sb.append(getLocalizationManager().getLocalizedTextString("breakpointAmbiguous"));
                break;
            case BreakAction.NOCODE:
                //$NON-NLS-1$
                sb.append(getLocalizationManager().getLocalizedTextString("breakpointNoCode"));
                break;
        }
        // if a single swf break action then append more info
        if (singleSwf && isResolved) {
            try {
                SwfInfo info = m_fileInfo.swfForFile(file);
                Map<String, Object> swfArgs = new HashMap<String, Object>();
                //$NON-NLS-1$
                swfArgs.put("swf", FileInfoCache.nameOfSwf(info));
                //$NON-NLS-1$
                sb.append(getLocalizationManager().getLocalizedTextString("inSwf", swfArgs));
            } catch (NullPointerException npe) {
                // can't find the swf
                //$NON-NLS-1$
                sb.append(getLocalizationManager().getLocalizedTextString("nonRestorable"));
            }
        }
        sb.append(m_newline);
        //$NON-NLS-1$
        final String INDENT = "        ";
        // state our condition if we have one
        if (cond != null && cond.length() > 0) {
            sb.append(INDENT);
            Map<String, Object> args = new HashMap<String, Object>();
            //$NON-NLS-1$
            args.put("breakpointCondition", cond);
            //$NON-NLS-1$
            sb.append(getLocalizationManager().getLocalizedTextString(getLocalizationManager().getLocalizedTextString("stopOnlyIfConditionMet", args)));
            sb.append(m_newline);
        }
        // now if its been hit, lets state the fact
        if (hits > 0) {
            sb.append(INDENT);
            Map<String, Object> args = new HashMap<String, Object>();
            //$NON-NLS-1$
            args.put("count", Integer.toString(hits));
            //$NON-NLS-1$
            sb.append(getLocalizationManager().getLocalizedTextString("breakpointAlreadyHit", args));
            sb.append(m_newline);
        }
        // silent?
        if (silent) {
            sb.append(INDENT);
            //$NON-NLS-1$
            sb.append(getLocalizationManager().getLocalizedTextString("silentBreakpoint") + m_newline);
        }
        // now if any commands are trailing then we pump them out
        for (int j = 0; j < cmdCount; j++) {
            sb.append(INDENT);
            sb.append(b.commandAt(j));
            sb.append(m_newline);
        }
    }
    int wcount = watchpointCount();
    for (int k = 0; k < wcount; k++) {
        WatchAction b = watchpointAt(k);
        int id = b.getId();
        FieldFormat.formatLong(sb, id, 4);
        int flags = b.getKind();
        switch(flags) {
            case WatchKind.READ:
                sb.append("rd watchpoint  ");
                break;
            case WatchKind.WRITE:
                sb.append("wr watchpoint  ");
                break;
            case WatchKind.READWRITE:
            default:
                sb.append("watchpoint     ");
                break;
        }
        sb.append("keep ");
        sb.append("y   ");
        //$NON-NLS-1$
        sb.append("           ");
        sb.append(b.getExpr());
        sb.append(m_newline);
    }
    int ccount = catchpointCount();
    for (int k = 0; k < ccount; k++) {
        CatchAction c = catchpointAt(k);
        int id = c.getId();
        FieldFormat.formatLong(sb, id, 4);
        String typeToCatch = c.getTypeToCatch();
        if (typeToCatch == null)
            //$NON-NLS-1$
            typeToCatch = "*";
        sb.append("catch          ");
        sb.append("keep ");
        sb.append("y   ");
        //$NON-NLS-1$
        sb.append("           ");
        sb.append(typeToCatch);
        sb.append(m_newline);
    }
    out(sb.toString());
}
Also used : HashMap(java.util.HashMap) SwfInfo(flash.tools.debugger.SwfInfo) DSwfInfo(flash.tools.debugger.concrete.DSwfInfo) SourceFile(flash.tools.debugger.SourceFile) Location(flash.tools.debugger.Location)

Aggregations

SwfInfo (flash.tools.debugger.SwfInfo)7 DSwfInfo (flash.tools.debugger.concrete.DSwfInfo)6 Location (flash.tools.debugger.Location)5 SourceFile (flash.tools.debugger.SourceFile)5 InProgressException (flash.tools.debugger.InProgressException)4 HashMap (java.util.HashMap)4 NoResponseException (flash.tools.debugger.NoResponseException)2 SourceBreakpoint (com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint)1 Breakpoint (com.nextgenactionscript.vscode.debug.responses.Breakpoint)1 SetBreakpointsResponseBody (com.nextgenactionscript.vscode.debug.responses.SetBreakpointsResponseBody)1 NotConnectedException (flash.tools.debugger.NotConnectedException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1