Search in sources :

Example 6 with InProgressException

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

the class DebugCLI method dumpBreakLine.

void dumpBreakLine(boolean postStep, StringBuffer sb) throws NotConnectedException {
    int bp = -1;
    //$NON-NLS-1$
    String name = getLocalizationManager().getLocalizedTextString("unknownFilename");
    int line = -1;
    // clear our current frame display
    propertyPut(DISPLAY_FRAME_NUMBER, 0);
    /* dump a context line to the console */
    Location l = getCurrentLocation();
    // figure out why we stopped
    int reason = SuspendReason.Unknown;
    try {
        reason = m_session.suspendReason();
    } catch (PlayerDebugException pde) {
    }
    // then see if it because of a swfloaded event
    if (reason == SuspendReason.ScriptLoaded) {
        // since the player takes a long time to provide swf/swd, try 80 * 250ms = ~20s
        if (propertyGet(METADATA_ATTEMPTS) > 0)
            try {
                waitForMetaData(80);
            } catch (InProgressException ipe) {
            }
        m_fileInfo.setDirty();
        processEvents();
        propagateBreakpoints();
        //$NON-NLS-1$
        sb.append(getLocalizationManager().getLocalizedTextString("additionalCodeLoaded"));
        sb.append(m_newline);
        if (resolveBreakpoints(sb))
            //$NON-NLS-1$
            sb.append(getLocalizationManager().getLocalizedTextString("setAdditionalBreakpoints") + m_newline);
        else
            //$NON-NLS-1$
            sb.append(getLocalizationManager().getLocalizedTextString("fixBreakpoints") + m_newline);
    } else if (l == null || l.getFile() == null) {
        // no idea where we are ?!?
        propertyPut(LAST_FRAME_DEPTH, 0);
        //$NON-NLS-1$
        sb.append(getLocalizationManager().getLocalizedTextString("executionHalted"));
        sb.append(' ');
        /** disable this line (and enable the one after) if implementation Extensions are not provided */
        appendBreakInfo(sb);
    //sb.append("unknown location");
    } else {
        SourceFile file = l.getFile();
        name = file.getName();
        line = l.getLine();
        String funcName = file.getFunctionNameForLine(m_session, line);
        // where were we last time
        int lastModule = propertyGet(LIST_MODULE);
        int lastDepth = propertyGet(LAST_FRAME_DEPTH);
        int thisModule = file.getId();
        // triggered via getCurrentLocation()
        int thisDepth = propertyGet(CURRENT_FRAME_DEPTH);
        // mark where we stopped
        propertyPut(LAST_FRAME_DEPTH, thisDepth);
        // if we have changed our context or we are not spitting out source then dump our location
        if (!postStep || lastModule != thisModule || lastDepth != thisDepth) {
            // is it a fault?
            String reasonForHalting;
            if (reason == SuspendReason.Fault || reason == SuspendReason.StopRequest) {
                StringBuffer s = new StringBuffer();
                appendReason(s, reason);
                reasonForHalting = s.toString();
            } else // if its a breakpoint add that information
            if ((bp = enabledBreakpointIndexOf(l)) > -1) {
                Map args = new HashMap();
                //$NON-NLS-1$
                args.put("breakpointNumber", Integer.toString(breakpointAt(bp).getId()));
                //$NON-NLS-1$
                reasonForHalting = getLocalizationManager().getLocalizedTextString("hitBreakpoint", args);
            } else {
                //$NON-NLS-1$
                reasonForHalting = getLocalizationManager().getLocalizedTextString("executionHalted");
            }
            Map args = new HashMap();
            //$NON-NLS-1$
            args.put("reasonForHalting", reasonForHalting);
            //$NON-NLS-1$
            args.put("fileAndLine", name + ':' + line);
            String formatString;
            if (funcName != null) {
                //$NON-NLS-1$
                args.put("functionName", funcName);
                //$NON-NLS-1$
                formatString = "haltedInFunction";
            } else {
                //$NON-NLS-1$
                formatString = "haltedInFile";
            }
            sb.append(getLocalizationManager().getLocalizedTextString(formatString, args));
            if (!m_fullnameOption)
                sb.append(m_newline);
        }
        // set current listing poistion and emit emacs trigger
        setListingPosition(thisModule, line);
        // dump our source line if not in emacs mode
        if (!m_fullnameOption)
            appendSource(sb, file.getId(), line, file.getLine(line), false);
    }
}
Also used : InProgressException(flash.tools.debugger.InProgressException) HashMap(java.util.HashMap) PlayerDebugException(flash.tools.debugger.PlayerDebugException) SourceFile(flash.tools.debugger.SourceFile) Map(java.util.Map) HashMap(java.util.HashMap) Location(flash.tools.debugger.Location)

Example 7 with InProgressException

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

the class DebugCLI method enableBreak.

/**
	 * Enable a breakpoint using the SourceFile as a template
	 * for the source file in which the breakpoint should be 
	 * set.
	 */
LocationCollection enableBreak(SourceFile f, int line) throws NotConnectedException {
    LocationCollection col = new LocationCollection();
    boolean singleSwfBreakpoint = m_fileInfo.isSwfFilterOn();
    SwfInfo swf = m_fileInfo.getSwfFilter();
    // set a breakpoint in a specific swf not all of them
    try {
        if (singleSwfBreakpoint) {
            Location l = findAndEnableBreak(swf, f, line);
            col.add(l);
        } else {
            // walk all swfs looking to add this breakpoint
            SwfInfo[] swfs = m_fileInfo.getSwfs();
            for (int i = 0; i < swfs.length; i++) {
                swf = swfs[i];
                if (swf != null) {
                    Location l = findAndEnableBreak(swf, f, line);
                    if (l != null)
                        col.add(l);
                }
            }
        }
    } catch (InProgressException ipe) {
        if (Trace.error)
            //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
            Trace.trace(((swf == null) ? "SWF " : swf.getUrl()) + " still loading, breakpoint at " + f.getName() + ":" + line + " not set");
    }
    return col;
}
Also used : InProgressException(flash.tools.debugger.InProgressException) SwfInfo(flash.tools.debugger.SwfInfo) DSwfInfo(flash.tools.debugger.concrete.DSwfInfo) Location(flash.tools.debugger.Location)

Example 8 with InProgressException

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

the class DebugCLI method dumpBreakLine.

void dumpBreakLine(boolean postStep, StringBuilder sb) throws NotConnectedException {
    int bp = -1;
    //$NON-NLS-1$
    String name = getLocalizationManager().getLocalizedTextString("unknownFilename");
    int line = -1;
    // clear our current frame display
    propertyPut(DISPLAY_FRAME_NUMBER, 0);
    /* dump a context line to the console */
    Location l = getCurrentLocation();
    // figure out why we stopped
    int reason = SuspendReason.Unknown;
    try {
        reason = m_session.suspendReason();
    } catch (PlayerDebugException pde) {
    }
    // then see if it because of a swfloaded event
    if (reason == SuspendReason.ScriptLoaded) {
        // since the player takes a long time to provide swf/swd, try 80 * 250ms = ~20s
        if (propertyGet(METADATA_ATTEMPTS) > 0)
            try {
                waitForMetaData(80);
            } catch (InProgressException ipe) {
            }
        m_fileInfo.setDirty();
        processEvents();
        propagateBreakpoints();
        //$NON-NLS-1$
        sb.append(getLocalizationManager().getLocalizedTextString("additionalCodeLoaded"));
        sb.append(m_newline);
        if (resolveBreakpoints(sb))
            //$NON-NLS-1$
            sb.append(getLocalizationManager().getLocalizedTextString("setAdditionalBreakpoints") + m_newline);
        else
            //$NON-NLS-1$
            sb.append(getLocalizationManager().getLocalizedTextString("fixBreakpoints") + m_newline);
    } else if (l == null || l.getFile() == null) {
        // no idea where we are ?!?
        propertyPut(LAST_FRAME_DEPTH, 0);
        //$NON-NLS-1$
        sb.append(getLocalizationManager().getLocalizedTextString("executionHalted"));
        sb.append(' ');
        /** disable this line (and enable the one after) if implementation Extensions are not provided */
        appendBreakInfo(sb);
    //sb.append("unknown location");
    } else {
        SourceFile file = l.getFile();
        name = file.getName();
        line = l.getLine();
        String funcName = file.getFunctionNameForLine(m_session, line);
        // where were we last time
        int lastModule = propertyGet(LIST_MODULE);
        int lastDepth = propertyGet(LAST_FRAME_DEPTH);
        int thisModule = file.getId();
        // triggered via getCurrentLocation()
        int thisDepth = propertyGet(CURRENT_FRAME_DEPTH);
        // mark where we stopped
        propertyPut(LAST_FRAME_DEPTH, thisDepth);
        // if we have changed our context or we are not spitting out source then dump our location
        if (!postStep || lastModule != thisModule || lastDepth != thisDepth) {
            // is it a fault?
            String reasonForHalting;
            if (reason == SuspendReason.Fault || reason == SuspendReason.StopRequest) {
                StringBuilder s = new StringBuilder();
                appendReason(s, reason);
                reasonForHalting = s.toString();
            } else // if its a breakpoint add that information
            if ((bp = enabledBreakpointIndexOf(l)) > -1) {
                Map<String, Object> args = new HashMap<String, Object>();
                //$NON-NLS-1$
                args.put("breakpointNumber", Integer.toString(breakpointAt(bp).getId()));
                //$NON-NLS-1$
                reasonForHalting = getLocalizationManager().getLocalizedTextString("hitBreakpoint", args);
            } else {
                //$NON-NLS-1$
                reasonForHalting = getLocalizationManager().getLocalizedTextString("executionHalted");
            }
            Map<String, Object> args = new HashMap<String, Object>();
            //$NON-NLS-1$
            args.put("reasonForHalting", reasonForHalting);
            //$NON-NLS-1$
            args.put("fileAndLine", name + ':' + line);
            String formatString;
            if (funcName != null) {
                //$NON-NLS-1$
                args.put("functionName", funcName);
                //$NON-NLS-1$
                formatString = "haltedInFunction";
            } else {
                //$NON-NLS-1$
                formatString = "haltedInFile";
            }
            sb.append(getLocalizationManager().getLocalizedTextString(formatString, args));
            if (!m_fullnameOption)
                sb.append(m_newline);
        }
        // set current listing poistion and emit emacs trigger
        setListingPosition(thisModule, line);
        // dump our source line if not in emacs mode
        if (!m_fullnameOption)
            appendSource(sb, file.getId(), line, file.getLine(line), false);
    }
}
Also used : InProgressException(flash.tools.debugger.InProgressException) HashMap(java.util.HashMap) PlayerDebugException(flash.tools.debugger.PlayerDebugException) SourceFile(flash.tools.debugger.SourceFile) Map(java.util.Map) HashMap(java.util.HashMap) Location(flash.tools.debugger.Location)

Example 9 with InProgressException

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

the class DebugCLI method waitForMetaData.

/**
	 * Wait for the API to load function names, which
	 * exist in the form of external meta-data.
	 *
	 * Only do this tries times, then give up
	 *
	 * We wait period * attempts
	 */
public int waitForMetaData(int attempts) throws InProgressException {
    int start = attempts;
    int period = propertyGet(METADATA_ATTEMPTS_PERIOD);
    while (attempts > 0) {
        // are we done yet?
        if (isMetaDataAvailable())
            break;
        else
            try {
                attempts--;
                Thread.sleep(period);
            } catch (InterruptedException ie) {
            }
    }
    // throw exception if still not ready
    if (!isMetaDataAvailable())
        throw new InProgressException();
    // remaining number of tries
    return start - attempts;
}
Also used : InProgressException(flash.tools.debugger.InProgressException)

Aggregations

InProgressException (flash.tools.debugger.InProgressException)9 SourceFile (flash.tools.debugger.SourceFile)7 Location (flash.tools.debugger.Location)5 HashMap (java.util.HashMap)5 SwfInfo (flash.tools.debugger.SwfInfo)4 Map (java.util.Map)4 DSwfInfo (flash.tools.debugger.concrete.DSwfInfo)3 PlayerDebugException (flash.tools.debugger.PlayerDebugException)2 ArrayList (java.util.ArrayList)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 NoResponseException (flash.tools.debugger.NoResponseException)1 NotConnectedException (flash.tools.debugger.NotConnectedException)1 Path (java.nio.file.Path)1 ParseException (java.text.ParseException)1 Iterator (java.util.Iterator)1