Search in sources :

Example 6 with SourceFile

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

the class DebugCLI method doShowFiles.

/**
	 * Dump the content of files in a raw format
	 */
void doShowFiles() {
    try {
        StringBuilder sb = new StringBuilder();
        Iterator itr = m_fileInfo.getAllFiles();
        while (itr.hasNext()) {
            SourceFile m = (SourceFile) ((Map.Entry) itr.next()).getValue();
            String name = m.getName();
            int id = m.getId();
            String path = m.getFullPath();
            sb.append(id);
            sb.append(' ');
            sb.append(path);
            //$NON-NLS-1$
            sb.append(", ");
            sb.append(name);
            sb.append(m_newline);
        }
        out(sb.toString());
    } catch (NullPointerException npe) {
        //$NON-NLS-1$
        err(getLocalizationManager().getLocalizedTextString("noSourceFilesFound"));
    }
}
Also used : Iterator(java.util.Iterator) SourceFile(flash.tools.debugger.SourceFile) Map(java.util.Map) HashMap(java.util.HashMap)

Example 7 with SourceFile

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

the class DebugCLI method setListingToFrame.

// set the listing command to point to the file/line of the given frame
void setListingToFrame(int frameNum) throws PlayerDebugException {
    // set the module and line
    Frame[] frames = m_session.getFrames();
    Frame ctx = frames[frameNum];
    Location l = ctx.getLocation();
    SourceFile f = l.getFile();
    int id = f.getId();
    int line = l.getLine();
    setListingPosition(id, line);
}
Also used : Frame(flash.tools.debugger.Frame) SourceFile(flash.tools.debugger.SourceFile) Location(flash.tools.debugger.Location)

Example 8 with SourceFile

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

the class DebugCLI method doInfoFuncs.

void doInfoFuncs() {
    StringBuilder sb = new StringBuilder();
    String arg = null;
    // we take an optional single arg which specifies a module
    try {
        // let's wait a bit for the background load to complete
        waitForMetaData();
        if (hasMoreTokens()) {
            arg = nextToken();
            //$NON-NLS-1$
            int id = arg.equals(".") ? propertyGet(LIST_MODULE) : parseFileArg(-1, arg);
            SourceFile m = m_fileInfo.getFile(id);
            listFunctionsFor(sb, m);
        } else {
            SourceFile[] ar = m_fileInfo.getFileList();
            if (ar == null)
                //$NON-NLS-1$
                err(getLocalizationManager().getLocalizedTextString("noSourceFilesFound"));
            else {
                for (int i = 0; ar != null && i < ar.length; i++) {
                    SourceFile m = ar[i];
                    listFunctionsFor(sb, m);
                }
            }
        }
        out(sb.toString());
    } catch (NullPointerException npe) {
        //$NON-NLS-1$
        err(getLocalizationManager().getLocalizedTextString("noFunctionsFound"));
    } catch (ParseException pe) {
        err(pe.getMessage());
    } catch (NoMatchException nme) {
        err(nme.getMessage());
    } catch (AmbiguousException ae) {
        err(ae.getMessage());
    } catch (InProgressException ipe) {
        //$NON-NLS-1$
        err(getLocalizationManager().getLocalizedTextString("functionListBeingPrepared"));
    }
}
Also used : InProgressException(flash.tools.debugger.InProgressException) SourceFile(flash.tools.debugger.SourceFile) ParseException(java.text.ParseException)

Example 9 with SourceFile

use of flash.tools.debugger.SourceFile 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 10 with SourceFile

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

Aggregations

SourceFile (flash.tools.debugger.SourceFile)30 Location (flash.tools.debugger.Location)15 HashMap (java.util.HashMap)13 InProgressException (flash.tools.debugger.InProgressException)9 Map (java.util.Map)9 ParseException (java.text.ParseException)7 NotConnectedException (flash.tools.debugger.NotConnectedException)6 SwfInfo (flash.tools.debugger.SwfInfo)5 PlayerDebugException (flash.tools.debugger.PlayerDebugException)4 DSwfInfo (flash.tools.debugger.concrete.DSwfInfo)4 NoResponseException (flash.tools.debugger.NoResponseException)3 ArrayList (java.util.ArrayList)3 SourceBreakpoint (com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint)2 Breakpoint (com.nextgenactionscript.vscode.debug.responses.Breakpoint)2 Frame (flash.tools.debugger.Frame)2 NotSupportedException (flash.tools.debugger.NotSupportedException)2 NotSuspendedException (flash.tools.debugger.NotSuspendedException)2 SuspendedException (flash.tools.debugger.SuspendedException)2 Variable (flash.tools.debugger.Variable)2 VersionException (flash.tools.debugger.VersionException)2