use of com.oracle.truffle.tools.chromeinspector.server.CommandProcessException in project graal by oracle.
the class TruffleDebugger method restartFrame.
@Override
public Params restartFrame(long cmdId, String callFrameId, CommandPostProcessor postProcessor) throws CommandProcessException {
if (callFrameId == null) {
throw new CommandProcessException("A callFrameId required.");
}
int frameId;
try {
frameId = Integer.parseInt(callFrameId);
} catch (NumberFormatException ex) {
throw new CommandProcessException(ex.getLocalizedMessage());
}
DebuggerSuspendedInfo susp = suspendedInfo;
if (susp != null) {
if (frameId >= susp.getCallFrames().length) {
throw new CommandProcessException("Too big callFrameId: " + frameId);
}
CallFrame cf = susp.getCallFrames()[frameId];
susp.getSuspendedEvent().prepareUnwindFrame(cf.getFrame());
postProcessor.setPostProcessJob(() -> {
silentResume = true;
commandLazyResponse = (DebuggerSuspendedInfo suspInfo) -> {
JSONObject res = new JSONObject();
res.put("callFrames", getFramesParam(suspInfo.getCallFrames()));
return new Event(cmdId, new Result(new Params(res)));
};
doResume();
});
}
return new Params(null);
}
use of com.oracle.truffle.tools.chromeinspector.server.CommandProcessException in project graal by oracle.
the class TruffleDebugger method getScriptSource.
@Override
public Params getScriptSource(String scriptId) throws CommandProcessException {
if (scriptId == null) {
throw new CommandProcessException("A scriptId required.");
}
Script script;
try {
script = slh.getScript(Integer.parseInt(scriptId));
if (script == null) {
throw new CommandProcessException("Unknown scriptId: " + scriptId);
}
} catch (NumberFormatException nfe) {
throw new CommandProcessException(nfe.getMessage());
}
JSONObject json = new JSONObject();
json.put("scriptSource", script.getSource().getCharacters());
return new Params(json);
}
use of com.oracle.truffle.tools.chromeinspector.server.CommandProcessException in project graal by oracle.
the class TruffleDebugger method evaluateOnCallFrame.
@Override
public Params evaluateOnCallFrame(String callFrameId, String expression, String objectGroup, boolean includeCommandLineAPI, boolean silent, boolean returnByValue, boolean generatePreview, boolean throwOnSideEffect) throws CommandProcessException {
if (callFrameId == null) {
throw new CommandProcessException("A callFrameId required.");
}
if (expression == null) {
throw new CommandProcessException("An expression required.");
}
int frameId;
try {
frameId = Integer.parseInt(callFrameId);
} catch (NumberFormatException ex) {
throw new CommandProcessException(ex.getLocalizedMessage());
}
JSONObject jsonResult;
try {
jsonResult = context.executeInSuspendThread(new SuspendThreadExecutable<JSONObject>() {
@Override
public JSONObject executeCommand() throws CommandProcessException {
if (frameId >= suspendedInfo.getCallFrames().length) {
throw new CommandProcessException("Too big callFrameId: " + frameId);
}
CallFrame cf = suspendedInfo.getCallFrames()[frameId];
JSONObject json = new JSONObject();
try {
DebugValue value = cf.getFrame().eval(expression);
RemoteObject ro = new RemoteObject(value, context.getErr());
context.getRemoteObjectsHandler().register(ro);
json.put("result", ro.toJSON());
} catch (Throwable t) {
if (t instanceof TruffleException && !((TruffleException) t).isInternalError()) {
JSONObject err = new JSONObject();
err.putOpt("value", t.getLocalizedMessage());
json.put("result", err);
} else {
throw t;
}
}
return json;
}
});
} catch (NoSuspendedThreadException e) {
jsonResult = new JSONObject();
JSONObject err = new JSONObject();
err.putOpt("value", e.getLocalizedMessage());
jsonResult.put("result", err);
} catch (GuestLanguageException e) {
jsonResult = new JSONObject();
TruffleRuntime.fillExceptionDetails(jsonResult, e);
}
return new Params(jsonResult);
}
use of com.oracle.truffle.tools.chromeinspector.server.CommandProcessException in project graal by oracle.
the class TruffleRuntime method callFunctionOn.
@Override
public Params callFunctionOn(String objectId, String functionDeclaration, JSONArray arguments, boolean silent, boolean returnByValue, boolean awaitPromise) throws CommandProcessException {
if (objectId == null) {
throw new CommandProcessException("An objectId required.");
}
RemoteObject object = context.getRemoteObjectsHandler().getRemote(objectId);
JSONObject json = new JSONObject();
if (object != null) {
DebugValue value = object.getDebugValue();
DebuggerSuspendedInfo suspendedInfo = context.getSuspendedInfo();
if (suspendedInfo != null) {
try {
context.executeInSuspendThread(new SuspendThreadExecutable<Void>() {
@Override
public Void executeCommand() throws CommandProcessException {
JSONObject result;
if (functionDeclaration.startsWith("function getCompletions(")) {
result = createCodecompletion(value);
} else {
String code = "(" + functionDeclaration + ")(" + value.getName() + ")";
DebugValue eval = suspendedInfo.getSuspendedEvent().getTopStackFrame().eval(code);
if (!returnByValue) {
RemoteObject ro = new RemoteObject(eval, context.getErr());
context.getRemoteObjectsHandler().register(ro);
result = ro.toJSON();
} else {
result = RemoteObject.createJSONResultValue(eval, context.getErr());
}
}
json.put("result", result);
return null;
}
});
} catch (NoSuspendedThreadException ex) {
json.put("result", new JSONObject());
} catch (GuestLanguageException ex) {
fillExceptionDetails(json, ex);
}
}
}
return new Params(json);
}
use of com.oracle.truffle.tools.chromeinspector.server.CommandProcessException in project graal by oracle.
the class BreakpointsHandler method createOneShotBreakpoint.
void createOneShotBreakpoint(Location location) throws CommandProcessException {
Script script = slh.getScript(location.getScriptId());
if (script == null) {
throw new CommandProcessException("No script with id '" + location.getScriptId() + "'");
}
Breakpoint bp = createBuilder(script.getSource(), location.getLine(), location.getColumn()).oneShot().build();
ds.install(bp);
}
Aggregations