use of com.oracle.truffle.espresso.jdwp.impl.MethodBreakpointEvent in project graal by oracle.
the class VMEventListenerImpl method onMethodReturn.
@Override
@TruffleBoundary
public boolean onMethodReturn(MethodRef method, Object returnValue) {
boolean active = false;
for (MethodHook hook : method.getMethodHooks()) {
if (hook.onMethodExit(method, returnValue)) {
// OK, tell the Debug API to suspend the thread now
debuggerController.prepareMethodBreakpoint(new MethodBreakpointEvent((MethodBreakpointInfo) hook, returnValue));
debuggerController.suspend(context.asGuestThread(Thread.currentThread()));
active = true;
switch(hook.getKind()) {
case ONE_TIME:
if (hook.hasFired()) {
method.removedMethodHook(hook);
}
break;
case INDEFINITE:
// leave the hook active
break;
}
}
}
return active;
}
use of com.oracle.truffle.espresso.jdwp.impl.MethodBreakpointEvent in project graal by oracle.
the class VMEventListenerImpl method onMethodEntry.
@Override
@TruffleBoundary
public boolean onMethodEntry(MethodRef method, Object scope) {
boolean active = false;
// collect variable information from scope
List<MethodVariable> variables = new ArrayList<>(1);
try {
if (UNCACHED.hasMembers(scope)) {
Object identifiers = UNCACHED.getMembers(scope);
if (UNCACHED.hasArrayElements(identifiers)) {
long size = UNCACHED.getArraySize(identifiers);
for (long i = 0; i < size; i++) {
String identifier = (String) UNCACHED.readArrayElement(identifiers, i);
Object value = UNCACHED.readMember(scope, identifier);
variables.add(new MethodVariable(identifier, value));
}
}
}
} catch (UnsupportedMessageException | InvalidArrayIndexException | UnknownIdentifierException e) {
// not able to fetch locals, so leave variables list empty
}
for (MethodHook hook : method.getMethodHooks()) {
// pass on the variables to the method entry hook
if (hook.onMethodEnter(method, variables.toArray(new MethodVariable[variables.size()]))) {
// OK, tell the Debug API to suspend the thread now
debuggerController.prepareMethodBreakpoint(new MethodBreakpointEvent((MethodBreakpointInfo) hook, null));
debuggerController.suspend(context.asGuestThread(Thread.currentThread()));
active = true;
switch(hook.getKind()) {
case ONE_TIME:
if (hook.hasFired()) {
method.removedMethodHook(hook);
}
break;
case INDEFINITE:
// leave the hook active
break;
}
}
}
return active;
}
Aggregations