use of com.oracle.truffle.tools.chromeinspector.commands.Params in project graal by oracle.
the class InspectServerSession method processCommand.
private Params processCommand(Command cmd, CommandPostProcessor postProcessor) throws CommandProcessException {
Params resultParams = null;
switch(cmd.getMethod()) {
case "Runtime.enable":
runtime.enable();
break;
case "Runtime.compileScript":
JSONObject json = cmd.getParams().getJSONObject();
resultParams = runtime.compileScript(json.optString("expression"), json.optString("sourceURL"), json.optBoolean("persistScript"), json.optInt("executionContextId", -1));
break;
case "Runtime.evaluate":
json = cmd.getParams().getJSONObject();
resultParams = runtime.evaluate(json.optString("expression"), json.optString("objectGroup"), json.optBoolean("includeCommandLineAPI"), json.optBoolean("silent"), json.optInt("contextId", -1), json.optBoolean("returnByValue"), json.optBoolean("awaitPromise"));
break;
case "Runtime.runIfWaitingForDebugger":
runtime.runIfWaitingForDebugger();
break;
case "Runtime.getProperties":
json = cmd.getParams().getJSONObject();
resultParams = runtime.getProperties(json.optString("objectId"), json.optBoolean("ownProperties"));
break;
case "Runtime.callFunctionOn":
json = cmd.getParams().getJSONObject();
resultParams = runtime.callFunctionOn(json.optString("objectId"), json.optString("functionDeclaration"), json.optJSONArray("arguments"), json.optBoolean("silent"), json.optBoolean("returnByValue"), json.optBoolean("awaitPromise"));
break;
case "Debugger.enable":
debugger.enable();
break;
case "Debugger.disable":
debugger.disable();
break;
case "Debugger.evaluateOnCallFrame":
json = cmd.getParams().getJSONObject();
resultParams = debugger.evaluateOnCallFrame(json.optString("callFrameId"), json.optString("expression"), json.optString("objectGroup"), json.optBoolean("includeCommandLineAPI"), json.optBoolean("silent"), json.optBoolean("returnByValue"), json.optBoolean("generatePreview"), json.optBoolean("throwOnSideEffect"));
break;
case "Debugger.getPossibleBreakpoints":
json = cmd.getParams().getJSONObject();
resultParams = debugger.getPossibleBreakpoints(Location.create(json.getJSONObject("start")), Location.create(json.getJSONObject("end")), json.optBoolean("restrictToFunction"));
break;
case "Debugger.getScriptSource":
resultParams = debugger.getScriptSource(cmd.getParams().getScriptId());
break;
case "Debugger.pause":
debugger.pause();
break;
case "Debugger.resume":
debugger.resume(postProcessor);
break;
case "Debugger.stepInto":
debugger.stepInto(postProcessor);
break;
case "Debugger.stepOver":
debugger.stepOver(postProcessor);
break;
case "Debugger.stepOut":
debugger.stepOut(postProcessor);
break;
case "Debugger.setAsyncCallStackDepth":
debugger.setAsyncCallStackDepth(cmd.getParams().getMaxDepth());
break;
case "Debugger.setBlackboxPatterns":
debugger.setBlackboxPatterns(cmd.getParams().getPatterns());
break;
case "Debugger.setPauseOnExceptions":
debugger.setPauseOnExceptions(cmd.getParams().getState());
break;
case "Debugger.setBreakpointsActive":
debugger.setBreakpointsActive(cmd.getParams().getBreakpointsActive());
break;
case "Debugger.setBreakpointByUrl":
json = cmd.getParams().getJSONObject();
resultParams = debugger.setBreakpointByUrl(json.optString("url"), json.optString("urlRegex"), json.optInt("lineNumber", -1) + 1, json.optInt("columnNumber", -1) + 1, json.optString("condition"));
break;
case "Debugger.setBreakpoint":
json = cmd.getParams().getJSONObject();
resultParams = debugger.setBreakpoint(Location.create(json.getJSONObject("location")), json.optString("condition"));
break;
case "Debugger.removeBreakpoint":
debugger.removeBreakpoint(cmd.getParams().getBreakpointId());
break;
case "Debugger.continueToLocation":
debugger.continueToLocation(Location.create(cmd.getParams().getJSONObject().getJSONObject("location")), postProcessor);
break;
case "Debugger.restartFrame":
json = cmd.getParams().getJSONObject();
resultParams = debugger.restartFrame(cmd.getId(), json.optString("callFrameId"), postProcessor);
break;
case "Debugger.setVariableValue":
json = cmd.getParams().getJSONObject();
debugger.setVariableValue(json.optInt("scopeNumber", -1), json.optString("variableName"), CallArgument.get(json.getJSONObject("newValue")), json.optString("callFrameId"));
break;
case "Profiler.enable":
profiler.enable();
break;
case "Profiler.disable":
profiler.disable();
break;
case "Profiler.setSamplingInterval":
profiler.setSamplingInterval(cmd.getParams().getSamplingInterval());
break;
case "Profiler.start":
profiler.start();
break;
case "Profiler.stop":
resultParams = profiler.stop();
break;
case "Profiler.startPreciseCoverage":
Params params = cmd.getParams();
if (params != null) {
json = params.getJSONObject();
profiler.startPreciseCoverage(json.optBoolean("callCount"), json.optBoolean("detailed"));
} else {
profiler.startPreciseCoverage(false, false);
}
break;
case "Profiler.stopPreciseCoverage":
profiler.stopPreciseCoverage();
break;
case "Profiler.takePreciseCoverage":
resultParams = profiler.takePreciseCoverage();
break;
case "Profiler.getBestEffortCoverage":
resultParams = profiler.getBestEffortCoverage();
break;
case "Profiler.startTypeProfile":
profiler.startTypeProfile();
break;
case "Profiler.stopTypeProfile":
profiler.stopTypeProfile();
break;
case "Profiler.takeTypeProfile":
resultParams = profiler.takeTypeProfile();
break;
case "Schema.getDomains":
resultParams = getDomains();
break;
default:
throw new CommandProcessException("'" + cmd.getMethod() + "' wasn't found");
}
return resultParams;
}
use of com.oracle.truffle.tools.chromeinspector.commands.Params 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.commands.Params 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.commands.Params 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.commands.Params in project graal by oracle.
the class TruffleProfiler method takePreciseCoverage.
@Override
public Params takePreciseCoverage() {
synchronized (tracer) {
Params coverage = getCoverage(tracer.getPayloads());
tracer.clearData();
return coverage;
}
}
Aggregations