use of com.oracle.truffle.api.debug.Breakpoint.BreakpointConditionFailure in project graal by oracle.
the class DebuggerSessionSnippets method notifyCallback.
@TruffleBoundary
void notifyCallback(DebuggerNode source, MaterializedFrame frame, SuspendAnchor suspendAnchor, InputValuesProvider inputValuesProvider, Object returnValue, BreakpointConditionFailure conditionFailure) {
ThreadSuspension suspensionDisabled = threadSuspensions.get();
if (suspensionDisabled != null && !suspensionDisabled.enabled) {
return;
}
// SuspensionFilter:
if (source.isStepNode()) {
if (ignoreLanguageContextInitialization.get() && !source.getContext().isLanguageContextInitialized()) {
return;
}
}
Thread currentThread = Thread.currentThread();
SuspendedEvent event = currentSuspendedEventMap.get(currentThread);
if (event != null) {
if (Debugger.TRACE) {
trace("ignored suspended reason: recursive from source:%s context:%s location:%s", source, source.getContext(), source.getSuspendAnchors());
}
// avoid recursive suspensions in non legacy mode.
return;
}
if (source.consumeIsDuplicate(this)) {
if (Debugger.TRACE) {
trace("ignored suspended reason: duplicate from source:%s context:%s location:%s", source, source.getContext(), source.getSuspendAnchors());
}
return;
}
// only the first DebuggerNode for a source location and thread will reach here.
// mark all other nodes at this source location as duplicates
List<DebuggerNode> nodes = collectDebuggerNodes(source, suspendAnchor);
for (DebuggerNode node : nodes) {
if (node == source) {
// for the current one we won't call isDuplicate
continue;
}
node.markAsDuplicate(this);
}
SteppingStrategy s = getSteppingStrategy(currentThread);
if (suspendNext) {
synchronized (this) {
// double checked locking to avoid more than one suspension
if (suspendNext) {
s = SteppingStrategy.createAlwaysHalt();
setSteppingStrategy(currentThread, s, true);
suspendNext = false;
}
}
}
if (s == null) {
// a new Thread just appeared
s = notifyNewThread(currentThread);
}
Map<Breakpoint, Throwable> breakpointFailures = null;
if (conditionFailure != null) {
breakpointFailures = new HashMap<>();
Breakpoint fb = conditionFailure.getBreakpoint();
if (fb.isGlobal()) {
fb = fb.getROWrapper();
}
breakpointFailures.put(fb, conditionFailure.getConditionFailure());
}
List<Breakpoint> breaks = null;
for (DebuggerNode node : nodes) {
Breakpoint breakpoint = node.getBreakpoint();
if (breakpoint == null || !isBreakpointsActive()) {
// not a breakpoint node
continue;
}
boolean hit = true;
BreakpointConditionFailure failure = null;
try {
hit = breakpoint.notifyIndirectHit(source, node, frame);
} catch (BreakpointConditionFailure e) {
failure = e;
}
if (hit) {
if (breaks == null) {
breaks = new ArrayList<>();
}
breaks.add(breakpoint.isGlobal() ? breakpoint.getROWrapper() : breakpoint);
}
if (failure != null) {
if (breakpointFailures == null) {
breakpointFailures = new HashMap<>();
}
Breakpoint fb = failure.getBreakpoint();
if (fb.isGlobal()) {
fb = fb.getROWrapper();
}
breakpointFailures.put(fb, failure.getConditionFailure());
}
}
boolean hitStepping = s.step(this, source.getContext(), suspendAnchor);
boolean hitBreakpoint = breaks != null && !breaks.isEmpty();
if (hitStepping || hitBreakpoint) {
s.consume();
doSuspend(SuspendedContext.create(source.getContext()), suspendAnchor, frame, inputValuesProvider, returnValue, breaks, breakpointFailures);
} else {
if (Debugger.TRACE) {
trace("ignored suspended reason: strategy(%s) from source:%s context:%s location:%s", s, source, source.getContext(), source.getSuspendAnchors());
}
}
if (s.isKill()) {
// ComposedStrategy can become kill
throw new KillException();
}
}
Aggregations