Search in sources :

Example 16 with Location

use of flash.tools.debugger.Location 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 17 with Location

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

Example 18 with Location

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

the class DebugCLI method isCurrentLocation.

// see if this module, line combo is the current location
boolean isCurrentLocation(int module, int line) {
    boolean yes = false;
    Location l = getCurrentLocation();
    if (l != null) {
        SourceFile file = l.getFile();
        if (file != null && file.getId() == module && l.getLine() == line)
            yes = true;
    }
    return yes;
}
Also used : SourceFile(flash.tools.debugger.SourceFile) Location(flash.tools.debugger.Location)

Example 19 with Location

use of flash.tools.debugger.Location 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 20 with Location

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

the class DebugCLI method breakDisableRequest.

/**
	 * Notification that a breakpoint has been removed (or disabled)
	 * at the CLI level and we may need to remove it at the session level
	 */
void breakDisableRequest(LocationCollection col) throws NotConnectedException {
    // now let's comb the table looking to see if this breakpoint should
    // be removed at the session level.  Use the first entry as a template
    // for which location we are talking about.
    int at = 0;
    boolean hit = false;
    Location l = col.first();
    do {
        at = breakpointIndexOf(l, at);
        if (at > -1) {
            if (breakpointAt(at).isEnabled())
                hit = true;
            else
                // our location match is not enabled but let's continue after the hit
                at++;
        }
    } while (at > -1 && !hit);
    // no one matches, so let's remove it at the session level
    if (!hit) {
        Iterator<Location> itr = col.iterator();
        while (itr.hasNext()) {
            l = itr.next();
            try {
                m_session.clearBreakpoint(l);
            } catch (NoResponseException nre) {
            }
        }
    }
}
Also used : NoResponseException(flash.tools.debugger.NoResponseException) Location(flash.tools.debugger.Location)

Aggregations

Location (flash.tools.debugger.Location)21 SourceFile (flash.tools.debugger.SourceFile)15 HashMap (java.util.HashMap)8 InProgressException (flash.tools.debugger.InProgressException)6 NotConnectedException (flash.tools.debugger.NotConnectedException)5 SwfInfo (flash.tools.debugger.SwfInfo)5 Map (java.util.Map)5 PlayerDebugException (flash.tools.debugger.PlayerDebugException)4 DSwfInfo (flash.tools.debugger.concrete.DSwfInfo)4 Frame (flash.tools.debugger.Frame)3 NoResponseException (flash.tools.debugger.NoResponseException)3 ParseException (java.text.ParseException)3 SourceBreakpoint (com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint)2 Breakpoint (com.nextgenactionscript.vscode.debug.responses.Breakpoint)2 Variable (flash.tools.debugger.Variable)2 ArrayList (java.util.ArrayList)2 Source (com.nextgenactionscript.vscode.debug.requests.Source)1 SetBreakpointsResponseBody (com.nextgenactionscript.vscode.debug.responses.SetBreakpointsResponseBody)1 StackFrame (com.nextgenactionscript.vscode.debug.responses.StackFrame)1 StackTraceResponseBody (com.nextgenactionscript.vscode.debug.responses.StackTraceResponseBody)1