Search in sources :

Example 1 with Location

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

the class DebugCLI method appendFrameInfo.

/**
	 * Spit out frame information for a given frame number 
	 */
boolean appendFrameInfo(StringBuffer sb, Frame ctx, int frameNumber, boolean showThis, boolean showFileId) throws PlayerDebugException {
    boolean validFrame = true;
    // some formatting properties
    int i = frameNumber;
    Location loc = ctx.getLocation();
    SourceFile file = loc.getFile();
    int line = loc.getLine();
    //$NON-NLS-1$
    String name = (file == null) ? "<null>" : file.getName();
    String sig = ctx.getCallSignature();
    String func = extractFunctionName(sig);
    // file == null or line < 0 appears to be a terminator for stack info
    if (file == null && line < 0) {
        validFrame = false;
    } else {
        Variable[] var = ctx.getArguments(m_session);
        Variable dis = ctx.getThis(m_session);
        boolean displayArgs = (func != null) || (var != null);
        sb.append('#');
        FieldFormat.formatLong(sb, i, 3);
        sb.append(' ');
        if (showThis && dis != null) {
            ExpressionCache.appendVariable(sb, dis);
            //$NON-NLS-1$
            sb.append(".");
        }
        if (func != null)
            sb.append(func);
        if (displayArgs) {
            sb.append('(');
            for (int j = 0; j < var.length; j++) {
                Variable v = var[j];
                sb.append(v.getName());
                sb.append('=');
                ExpressionCache.appendVariableValue(sb, v.getValue());
                if ((j + 1) < var.length)
                    //$NON-NLS-1$
                    sb.append(", ");
            }
            //$NON-NLS-1$
            sb.append(")");
            //$NON-NLS-1$
            sb.append(getLocalizationManager().getLocalizedTextString("atFilename"));
        }
        sb.append(name);
        // if this file is currently being filtered put the source file id after it
        if (file != null && (showFileId || !m_fileInfo.inFileList(file))) {
            sb.append('#');
            sb.append(file.getId());
        }
        sb.append(':');
        sb.append(line);
    }
    return validFrame;
}
Also used : Variable(flash.tools.debugger.Variable) SourceFile(flash.tools.debugger.SourceFile) Location(flash.tools.debugger.Location)

Example 2 with Location

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

the class DebugCLI method processBreak.

/**
	 * Our logic for handling a break condition.
	 *
	 * @return some hit breakpoint requested silence, shhhh!
	 */
boolean processBreak(boolean postStep, StringBuffer sb) throws NotConnectedException {
    Location l = getCurrentLocation();
    if (l == null || l.getFile() == null)
        return false;
    int fileId = l.getFile().getId();
    int line = l.getLine();
    boolean isSilent = false;
    boolean bpHit = false;
    boolean stoppedDueToBp = false;
    int count = breakpointCount();
    boolean[] markedForRemoval = new boolean[count];
    boolean previousResume = m_requestResume;
    for (int i = 0; i < count; i++) {
        BreakAction a = breakpointAt(i);
        if (a.locationMatches(fileId, line)) {
            /**
				 * Note that it appears that we stopped due to hitting a hard breakpoint
				 * Now if the breakpoint is conditional it may eval to false, meaning we
				 * won't stop here, otherwise we will process the breakpoint.
				 */
            stoppedDueToBp = (m_session.suspendReason() == SuspendReason.Breakpoint);
            if (shouldBreak(a, fileId, line)) {
                // its a hit
                bpHit = true;
                a.hit();
                isSilent = (isSilent) ? true : a.isSilent();
                // autodelete, autodisable
                if (a.isAutoDisable())
                    disableBreakpointAt(i);
                if (a.isAutoDelete())
                    markedForRemoval[i] = true;
                // now issue any commands that are attached to the breakpoint
                int n = a.getCommandCount();
                for (int j = 0; j < n; j++) issueCommand(a.commandAt(j), sb);
            }
        }
    }
    // kill them backwards so our i is acurate
    for (int i = markedForRemoval.length - 1; i > -1; i--) if (markedForRemoval[i])
        removeBreakpointAt(i);
    /**
		 * Now we should request to resume only if it was due to
		 * breakpoints that were hit.
		 *
		 * For the first case, we hit a conditional breakpoint that
		 * eval'd to false, resulting in bpHit == false.  Thus we
		 * want to resume and additionally if we were stepping, we'd
		 * like to do so 'softly' that is without loosing the stepping
		 * information on the Player.
		 *
		 * For the 2nd case, we hit a breakpoint and we executed
		 * commands that resulted in a m_requestResume.
		 */
    if (stoppedDueToBp && !bpHit) {
        m_requestResume = true;
        // resume without losing our stepping
        m_stepResume = postStep;
        // do so quietly
        isSilent = true;
    } else if (stoppedDueToBp && bpHit && m_requestResume && !previousResume) {
        m_requestResume = true;
        // resume as we would
        m_stepResume = postStep;
        processDisplay(sb);
    }
    // If we aren't continuing, then show display variables
    if (!m_requestResume)
        processDisplay(sb);
    return isSilent;
}
Also used : Location(flash.tools.debugger.Location)

Example 3 with Location

use of flash.tools.debugger.Location 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 StringBuilder 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, StringBuilder 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<String, Object> args = new HashMap<String, Object>();
                    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) Location(flash.tools.debugger.Location)

Example 4 with Location

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

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

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