use of com.oracle.truffle.api.debug.DebugValue in project graal by oracle.
the class TruffleRuntime method putResultProperties.
private void putResultProperties(JSONObject json, Collection<DebugValue> properties, Collection<DebugValue> arrayElements) {
JSONArray result = new JSONArray();
JSONArray internals = new JSONArray();
HashSet<String> storedPropertyNames = new HashSet<>(properties.size());
for (DebugValue v : properties) {
if (v.isReadable()) {
if (!v.isInternal()) {
result.put(createPropertyJSON(v));
storedPropertyNames.add(v.getName());
} else {
internals.put(createPropertyJSON(v));
}
}
}
int i = 0;
for (DebugValue v : arrayElements) {
String name = Integer.toString(i++);
if (v.isReadable() && !storedPropertyNames.contains(name)) {
result.put(createPropertyJSON(v, name));
}
}
json.put("result", result);
json.put("internalProperties", internals);
}
use of com.oracle.truffle.api.debug.DebugValue 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.api.debug.DebugValue in project sulong by graalvm.
the class LLVMDebugTest method assertValues.
private static void assertValues(DebugScope scope, Map<String, LLVMDebugValue> expectedLocals) {
if (scope == null) {
throw new AssertionError("Missing Scope!");
}
int count = 0;
for (DebugValue actual : scope.getDeclaredValues()) {
final String name = actual.getName();
final LLVMDebugValue expected = expectedLocals.get(actual.getName());
if (expected == null) {
throw new AssertionError(String.format("Unexpected scope member: %s", name));
}
try {
expected.check(actual);
} catch (Throwable t) {
throw new AssertionError(String.format("Error in local %s", name), t);
}
count++;
}
assertEquals("Unexpected number of scope variables", expectedLocals.size(), count);
}
Aggregations