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 StringBuffer 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, StringBuffer 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 args = new HashMap();
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 intellij-plugins by JetBrains.
the class DebugCLI method doBreak.
/**
* Set a breakpoint
*/
void doBreak() throws NotConnectedException {
/* wait a bit if we are not halted */
waitTilHalted();
int module = propertyGet(LIST_MODULE);
int line = propertyGet(LIST_LINE);
String arg = null;
/* currentXXX may NOT be invalid! */
try {
if (hasMoreTokens()) {
arg = nextToken();
int[] result = parseLocationArg(module, line, arg);
module = result[0];
line = result[1];
} else {
// no parameter mean use current location; null pointer if nothing works
Location l = getCurrentLocation();
SourceFile file = l.getFile();
module = file.getId();
line = l.getLine();
}
// // check to see if there are any existing breakpoints at this file/line
// LinkedList existingBreakpoints = new LinkedList();
// int start = 0;
// for (;;)
// {
// int bp = breakpointIndexOf(module, line, start, true);
// if (bp == -1)
// break; // no more matches
// boolean isEnabled = breakpointAt(bp).isEnabled();
// existingBreakpoints.add("" + bp + (isEnabled ? "" : " (disabled)"));
// }
// if (existingBreakpoints.size() > 0)
// {
// String
// }
// go off; create it and set it
// throws npe if not able to set
BreakAction b = addBreakpoint(module, line);
Location l = b.getLocation();
int which = b.getId();
String name = l.getFile().getName();
int offset = adjustOffsetForUnitTests(l.getFile().getOffsetForLine(line));
Map<String, Object> args = new HashMap<String, Object>();
//$NON-NLS-1$
args.put("breakpointNumber", Integer.toString(which));
//$NON-NLS-1$
args.put("file", name);
//$NON-NLS-1$
args.put("line", Integer.toString(line));
String formatString;
if (offset != 0) {
//$NON-NLS-1$ //$NON-NLS-2$
args.put("offset", "0x" + Integer.toHexString(offset));
//$NON-NLS-1$
formatString = "createdBreakpointWithOffset";
} else {
//$NON-NLS-1$
formatString = "createdBreakpoint";
}
out(getLocalizationManager().getLocalizedTextString(formatString, args));
// worked so add it to our tracking state
propertyPut(BPNUM, which);
} catch (ParseException pe) {
err(pe.getMessage());
} catch (AmbiguousException ae) {
err(ae.getMessage());
} catch (NoMatchException nme) {
// We couldn't find a function name or filename which matched what
// the user entered. Do *not* fail; instead, just save this breakpoint
// away, and later, as more ABCs get loaded from the SWF, we may be
// able to resolve this breakpoint.
BreakAction b = addUnresolvedBreakpoint(arg);
Map<String, Object> args = new HashMap<String, Object>();
//$NON-NLS-1$
args.put("breakpointNumber", Integer.toString(b.getId()));
//$NON-NLS-1$
out(getLocalizationManager().getLocalizedTextString("breakpointCreatedButNotYetResolved", args));
// add it to our tracking state
propertyPut(BPNUM, b.getId());
} catch (NullPointerException npe) {
String filename;
try {
//$NON-NLS-1$
filename = m_fileInfo.getFile(module).getName() + "#" + module;
} catch (Exception e) {
Map<String, Object> args = new HashMap<String, Object>();
//$NON-NLS-1$
args.put("fileNumber", Integer.toString(module));
//$NON-NLS-1$
filename = getLocalizationManager().getLocalizedTextString("fileNumber", args);
}
Map<String, Object> args = new HashMap<String, Object>();
//$NON-NLS-1$
args.put("filename", filename);
//$NON-NLS-1$
args.put("line", Integer.toString(line));
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("breakpointNotSetNoCode", args));
}
}
Aggregations