use of com.oracle.truffle.tools.chromeinspector.types.RemoteObject in project graal by oracle.
the class TruffleDebugger method createScope.
private Scope createScope(String scopeType, DebugScope dscope) {
RemoteObject scopeVars = new RemoteObject(dscope);
context.getRemoteObjectsHandler().register(scopeVars);
return new Scope(scopeType, scopeVars, dscope.getName(), null, null);
}
use of com.oracle.truffle.tools.chromeinspector.types.RemoteObject in project graal by oracle.
the class TruffleRuntime method evaluate.
@Override
public Params evaluate(String expression, String objectGroup, boolean includeCommandLineAPI, boolean silent, int contextId, boolean returnByValue, boolean awaitPromise) throws CommandProcessException {
if (expression == null) {
throw new CommandProcessException("An expression required.");
}
JSONObject json = new JSONObject();
DebuggerSuspendedInfo suspendedInfo = context.getSuspendedInfo();
if (suspendedInfo != null) {
try {
context.executeInSuspendThread(new SuspendThreadExecutable<Void>() {
@Override
public Void executeCommand() throws CommandProcessException {
JSONObject result;
DebugValue value = suspendedInfo.getSuspendedEvent().getTopStackFrame().eval(expression);
if (returnByValue) {
result = RemoteObject.createJSONResultValue(value, context.getErr());
} else {
RemoteObject ro = new RemoteObject(value, context.getErr());
context.getRemoteObjectsHandler().register(ro);
result = ro.toJSON();
}
json.put("result", result);
return null;
}
});
} catch (NoSuspendedThreadException ex) {
JSONObject exceptionDetails = new JSONObject();
exceptionDetails.put("text", ex.getLocalizedMessage());
json.put("exceptionDetails", exceptionDetails);
} catch (GuestLanguageException ex) {
fillExceptionDetails(json, ex);
}
} else {
JSONObject exceptionDetails = new JSONObject();
exceptionDetails.put("text", "<Not suspended>");
json.put("exceptionDetails", exceptionDetails);
}
return new Params(json);
}
use of com.oracle.truffle.tools.chromeinspector.types.RemoteObject in project graal by oracle.
the class TruffleRuntime method getProperties.
@Override
public Params getProperties(String objectId, boolean ownProperties) 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();
try {
if (value != null) {
context.executeInSuspendThread(new SuspendThreadExecutable<Void>() {
@Override
public Void executeCommand() throws CommandProcessException {
putResultProperties(json, value.getProperties(), value.isArray() ? value.getArray() : Collections.emptyList());
return null;
}
});
} else {
final DebugScope scope = object.getScope();
context.executeInSuspendThread(new SuspendThreadExecutable<Void>() {
@Override
public Void executeCommand() throws CommandProcessException {
Collection<DebugValue> properties = new ArrayList<>();
for (DebugValue p : scope.getDeclaredValues()) {
properties.add(p);
}
putResultProperties(json, properties, Collections.emptyList());
return null;
}
});
}
} catch (NoSuspendedThreadException ex) {
// Not suspended, no properties
json.put("result", new JSONArray());
} catch (GuestLanguageException ex) {
fillExceptionDetails(json, ex);
}
}
return new Params(json);
}
use of com.oracle.truffle.tools.chromeinspector.types.RemoteObject in project graal by oracle.
the class TruffleRuntime method createPropertyJSON.
private JSONObject createPropertyJSON(DebugValue v, String defaultName) {
PropertyDescriptor pd;
RemoteObject rv = new RemoteObject(v, context.getErr());
context.getRemoteObjectsHandler().register(rv);
String name = v.getName();
if (name == null && defaultName != null) {
name = defaultName;
}
if (!v.isInternal()) {
pd = new PropertyDescriptor(name, rv, v.isWritable(), null, null, true, true, null, true, null);
return pd.toJSON();
} else {
InternalPropertyDescriptor ipd = new InternalPropertyDescriptor(name, rv);
return ipd.toJSON();
}
}
use of com.oracle.truffle.tools.chromeinspector.types.RemoteObject in project graal by oracle.
the class RemoteObjectsHandler method getRemote.
RemoteObject getRemote(DebugValue value) {
RemoteObject remote;
synchronized (remotesByIDs) {
remote = remotesByValue.get(value);
if (remote == null) {
remote = new RemoteObject(value, err);
remotesByValue.put(value, remote);
remotesByIDs.put(remote.getId(), remote);
}
}
return remote;
}
Aggregations