Search in sources :

Example 1 with Frame

use of flash.tools.debugger.Frame in project vscode-nextgenas by BowlerHatLLC.

the class SWFDebugSession method scopes.

public void scopes(Response response, ScopesRequest.ScopesArguments arguments) {
    List<Scope> scopes = new ArrayList<>();
    int frameId = arguments.frameId;
    try {
        Frame[] swfFrames = swfSession.getFrames();
        if (frameId >= 0 && frameId < swfFrames.length) {
            Scope localScope = new Scope();
            localScope.name = "Locals";
            //this is a hacky way to store the frameId
            localScope.variablesReference = frameId * 10 + LOCAL_VARIABLES_REFERENCE;
            scopes.add(localScope);
        }
    } catch (PlayerDebugException e) {
    //ignore and return no scopes
    }
    sendResponse(response, new ScopesResponseBody(scopes));
}
Also used : ScopesResponseBody(com.nextgenactionscript.vscode.debug.responses.ScopesResponseBody) StackFrame(com.nextgenactionscript.vscode.debug.responses.StackFrame) Frame(flash.tools.debugger.Frame) Scope(com.nextgenactionscript.vscode.debug.responses.Scope) ArrayList(java.util.ArrayList) PlayerDebugException(flash.tools.debugger.PlayerDebugException) SourceBreakpoint(com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint) Breakpoint(com.nextgenactionscript.vscode.debug.responses.Breakpoint)

Example 2 with Frame

use of flash.tools.debugger.Frame in project vscode-nextgenas by BowlerHatLLC.

the class SWFDebugSession method variables.

public void variables(Response response, VariablesRequest.VariablesArguments arguments) {
    List<Variable> variables = new ArrayList<>();
    try {
        Value swfValue = null;
        long variablesReference = arguments.variablesReference;
        int frameId = -1;
        if (variablesReference < 1000) {
            frameId = (int) variablesReference / 10;
            variablesReference -= frameId * 10;
        }
        flash.tools.debugger.Variable[] members = null;
        if (variablesReference == LOCAL_VARIABLES_REFERENCE) {
            Frame[] swfFrames = swfSession.getFrames();
            if (frameId >= 0 && frameId < swfFrames.length) {
                Frame swfFrame = swfFrames[frameId];
                flash.tools.debugger.Variable[] args = swfFrame.getArguments(swfSession);
                flash.tools.debugger.Variable[] locals = swfFrame.getLocals(swfSession);
                flash.tools.debugger.Variable swfThis = swfFrame.getThis(swfSession);
                int memberCount = locals.length + args.length;
                int offset = 0;
                if (swfThis != null) {
                    offset = 1;
                }
                members = new flash.tools.debugger.Variable[memberCount + offset];
                if (swfThis != null) {
                    members[0] = swfThis;
                }
                System.arraycopy(args, 0, members, offset, args.length);
                System.arraycopy(locals, 0, members, args.length + offset, locals.length);
            } else {
                members = new flash.tools.debugger.Variable[0];
            }
        } else {
            swfValue = swfSession.getValue(arguments.variablesReference);
            members = swfValue.getMembers(swfSession);
        }
        for (flash.tools.debugger.Variable member : members) {
            Value memberValue = member.getValue();
            Variable variable = new Variable();
            variable.name = member.getName();
            variable.type = memberValue.getTypeName();
            long id = memberValue.getId();
            if (id != Value.UNKNOWN_ID) {
                variable.value = memberValue.getTypeName();
                variable.variablesReference = memberValue.getId();
            } else {
                if (memberValue.getType() == VariableType.STRING) {
                    variable.value = "\"" + memberValue.getValueAsString() + "\"";
                } else {
                    variable.value = memberValue.getValueAsString();
                }
            }
            variables.add(variable);
        }
    } catch (PlayerDebugException e) {
    //ignore
    }
    sendResponse(response, new VariablesResponseBody(variables));
}
Also used : StackFrame(com.nextgenactionscript.vscode.debug.responses.StackFrame) Frame(flash.tools.debugger.Frame) Variable(com.nextgenactionscript.vscode.debug.responses.Variable) ArrayList(java.util.ArrayList) PlayerDebugException(flash.tools.debugger.PlayerDebugException) VariablesResponseBody(com.nextgenactionscript.vscode.debug.responses.VariablesResponseBody) SourceBreakpoint(com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint) Breakpoint(com.nextgenactionscript.vscode.debug.responses.Breakpoint) Value(flash.tools.debugger.Value)

Example 3 with Frame

use of flash.tools.debugger.Frame 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 4 with Frame

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

the class DebugCLI method doInfoScopeChain.

void doInfoScopeChain() throws PlayerDebugException {
    waitTilHalted();
    // dump the scope chain
    StringBuilder sb = new StringBuilder();
    // use our expression cache formatting routine
    try {
        // get the scope chainfrom the requested frame
        int num = propertyGet(DISPLAY_FRAME_NUMBER);
        Frame[] ar = m_session.getFrames();
        Frame ctx = ar[num];
        Variable[] scopes = ctx.getScopeChain(m_session);
        for (int i = 0; i < scopes.length; i++) {
            Variable scope = scopes[i];
            ExpressionCache.appendVariable(sb, scope);
            sb.append(m_newline);
        }
    } catch (NullPointerException npe) {
        //$NON-NLS-1$
        sb.append(getLocalizationManager().getLocalizedTextString("noScopeChain"));
    } catch (ArrayIndexOutOfBoundsException aix) {
        //$NON-NLS-1$
        sb.append(getLocalizationManager().getLocalizedTextString("notInValidFrame"));
    }
    out(sb.toString());
}
Also used : Frame(flash.tools.debugger.Frame) Variable(flash.tools.debugger.Variable)

Example 5 with Frame

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

the class DebugCLI method getCurrentLocation.

Location getCurrentLocation() {
    Location where = null;
    try {
        Frame[] ar = m_session.getFrames();
        propertyPut(CURRENT_FRAME_DEPTH, (ar.length > 0) ? ar.length : 0);
        where = ((ar.length > 0) ? ar[0].getLocation() : null);
    } catch (PlayerDebugException pde) {
    // where == null
    }
    return where;
}
Also used : Frame(flash.tools.debugger.Frame) PlayerDebugException(flash.tools.debugger.PlayerDebugException) Location(flash.tools.debugger.Location)

Aggregations

Frame (flash.tools.debugger.Frame)8 SourceBreakpoint (com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint)3 Breakpoint (com.nextgenactionscript.vscode.debug.responses.Breakpoint)3 StackFrame (com.nextgenactionscript.vscode.debug.responses.StackFrame)3 Location (flash.tools.debugger.Location)3 PlayerDebugException (flash.tools.debugger.PlayerDebugException)3 ArrayList (java.util.ArrayList)3 SourceFile (flash.tools.debugger.SourceFile)2 Variable (flash.tools.debugger.Variable)2 Source (com.nextgenactionscript.vscode.debug.requests.Source)1 Scope (com.nextgenactionscript.vscode.debug.responses.Scope)1 ScopesResponseBody (com.nextgenactionscript.vscode.debug.responses.ScopesResponseBody)1 StackTraceResponseBody (com.nextgenactionscript.vscode.debug.responses.StackTraceResponseBody)1 Variable (com.nextgenactionscript.vscode.debug.responses.Variable)1 VariablesResponseBody (com.nextgenactionscript.vscode.debug.responses.VariablesResponseBody)1 NotConnectedException (flash.tools.debugger.NotConnectedException)1 Value (flash.tools.debugger.Value)1