use of flash.tools.debugger.NotConnectedException in project intellij-plugins by JetBrains.
the class ExpressionCache method appendVariableValue.
/**
* Given any arbitrary constant value, such as a Double, a String, etc.,
* format its value appropriately. For example, strings will be quoted.
*
* @param sb
* a StringBuilder to which the formatted value will be appended.
* @param o
* the value to format.
*/
public static void appendVariableValue(StringBuilder sb, final Object o) {
Value v;
if (o instanceof Value) {
v = (Value) o;
} else {
v = new Value() {
public int getAttributes() {
return 0;
}
public String[] getClassHierarchy(boolean allLevels) {
return new String[0];
}
public String getClassName() {
//$NON-NLS-1$
return "";
}
public long getId() {
return UNKNOWN_ID;
}
public int getMemberCount(Session s) throws NotSuspendedException, NoResponseException, NotConnectedException {
return 0;
}
public Variable getMemberNamed(Session s, String name) throws NotSuspendedException, NoResponseException, NotConnectedException {
return null;
}
public Variable[] getMembers(Session s) throws NotSuspendedException, NoResponseException, NotConnectedException {
return new Variable[0];
}
public int getType() {
if (o instanceof Number)
return VariableType.NUMBER;
else if (o instanceof Boolean)
return VariableType.BOOLEAN;
else if (o instanceof String)
return VariableType.STRING;
else if (o == Value.UNDEFINED)
return VariableType.UNDEFINED;
else if (o == null)
return VariableType.NULL;
assert false;
return VariableType.UNKNOWN;
}
public String getTypeName() {
//$NON-NLS-1$
return "";
}
public Object getValueAsObject() {
return o;
}
public String getValueAsString() {
return DValue.getValueAsString(o);
}
public boolean isAttributeSet(int variableAttribute) {
return false;
}
public Variable[] getPrivateInheritedMembers() {
return new Variable[0];
}
public Variable[] getPrivateInheritedMemberNamed(String name) {
return new Variable[0];
}
};
}
appendVariableValue(sb, v);
}
use of flash.tools.debugger.NotConnectedException in project intellij-plugins by JetBrains.
the class DebugCLI method process.
/**
* Process this reader until its done
*/
void process() throws IOException {
boolean done = false;
while (!done) {
try {
/**
* Now if we are in a session and that session is suspended then we go
* into a state where we wait for some user interaction to get us out
*/
runningLoop();
/* if we are in the stdin then put out a prompt */
if (!haveStreams())
displayPrompt();
/* now read in the next line */
readLine();
if (m_currentLine == null)
break;
done = processLine();
} catch (NoResponseException nre) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("noResponseException"));
} catch (NotSuspendedException nse) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("notSuspendedException"));
} catch (AmbiguousException ae) {
// we already put up a warning for the user
} catch (IllegalStateException ise) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("illegalStateException"));
} catch (IllegalMonitorStateException ime) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("illegalMonitorStateException"));
} catch (NoSuchElementException nse) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("noSuchElementException"));
} catch (NumberFormatException nfe) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("numberFormatException"));
} catch (SocketException se) {
Map socketArgs = new HashMap();
//$NON-NLS-1$
socketArgs.put("message", se.getMessage());
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("socketException", socketArgs));
} catch (VersionException ve) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("versionException"));
} catch (NotConnectedException nce) {
// handled by isConnectionLost()
} catch (Exception e) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("unexpectedError"));
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("stackTraceFollows"));
e.printStackTrace();
}
// check for a lost connection and if it is clean-up!
if (isConnectionLost()) {
try {
dumpHaltState(false);
} catch (PlayerDebugException pde) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("sessionEndedAbruptly"));
}
}
}
}
use of flash.tools.debugger.NotConnectedException 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;
}
use of flash.tools.debugger.NotConnectedException in project vscode-nextgenas by BowlerHatLLC.
the class SWFDebugSession method stackTrace.
public void stackTrace(Response response, StackTraceRequest.StackTraceArguments arguments) {
List<StackFrame> stackFrames = new ArrayList<>();
try {
Frame[] swfFrames = swfSession.getFrames();
for (int i = 0, count = swfFrames.length; i < count; i++) {
Frame swfFrame = swfFrames[i];
Location location = swfFrame.getLocation();
SourceFile file = location.getFile();
StackFrame stackFrame = new StackFrame();
stackFrame.id = i;
stackFrame.name = swfFrame.getCallSignature();
if (file != null) {
Source source = new Source();
source.name = file.getName();
source.path = transformPath(file.getFullPath());
stackFrame.source = source;
stackFrame.line = location.getLine();
stackFrame.column = 0;
}
stackFrames.add(stackFrame);
}
} catch (NotConnectedException e) {
//ignore
}
sendResponse(response, new StackTraceResponseBody(stackFrames));
}
use of flash.tools.debugger.NotConnectedException in project vscode-nextgenas by BowlerHatLLC.
the class SWFDebugSession method setBreakpoints.
public void setBreakpoints(Response response, SetBreakpointsRequest.SetBreakpointsArguments arguments) {
String path = arguments.source.path;
Path pathAsPath = Paths.get(path);
List<Breakpoint> breakpoints = new ArrayList<>();
for (int i = 0, count = arguments.breakpoints.length; i < count; i++) {
SourceBreakpoint sourceBreakpoint = arguments.breakpoints[i];
int sourceLine = sourceBreakpoint.line;
Breakpoint responseBreakpoint = new Breakpoint();
responseBreakpoint.line = sourceLine;
int fileId = -1;
try {
SwfInfo[] swfs = swfSession.getSwfs();
for (SwfInfo swf : swfs) {
SourceFile[] sourceFiles = swf.getSourceList(swfSession);
for (SourceFile sourceFile : sourceFiles) {
//file system case sensitivity.
if (pathAsPath.equals(Paths.get(sourceFile.getFullPath())) && (path.endsWith(FILE_EXTENSION_AS) || path.endsWith(FILE_EXTENSION_MXML))) {
fileId = sourceFile.getId();
break;
}
}
if (fileId != -1) {
break;
}
}
if (fileId == -1) {
//either the file was not found, or it has an unsupported
//extension
responseBreakpoint.verified = false;
} else {
Location breakpointLocation = swfSession.setBreakpoint(fileId, sourceLine);
if (breakpointLocation != null) {
//I don't know if the line could change, but might as well
//use the one returned by the location
responseBreakpoint.line = breakpointLocation.getLine();
responseBreakpoint.verified = true;
} else {
//setBreakpoint() may return null if the breakpoint could
//not be set. that's fine. the user will see that the
//breakpoint is not verified, so it's fine.
responseBreakpoint.verified = false;
}
}
} catch (InProgressException e) {
e.printStackTrace(System.err);
responseBreakpoint.verified = false;
} catch (NoResponseException e) {
e.printStackTrace(System.err);
responseBreakpoint.verified = false;
} catch (NotConnectedException e) {
e.printStackTrace(System.err);
responseBreakpoint.verified = false;
}
breakpoints.add(responseBreakpoint);
}
sendResponse(response, new SetBreakpointsResponseBody(breakpoints));
}
Aggregations