in com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/StepRequestHandler.java [145:206]
private void handleDebugEvent(DebugEvent debugEvent, IDebugSession debugSession, IDebugAdapterContext context,
ThreadState threadState) {
Event event = debugEvent.event;
EventRequestManager eventRequestManager = debugSession.getVM().eventRequestManager();
// When a breakpoint occurs, abort any pending step requests from the same thread.
if (event instanceof BreakpointEvent || event instanceof ExceptionEvent) {
long threadId = ((LocatableEvent) event).thread().uniqueID();
if (threadId == threadState.threadId && threadState.pendingStepRequest != null) {
threadState.deleteStepRequest(eventRequestManager);
threadState.deleteMethodExitRequest(eventRequestManager);
context.getStepResultManager().removeMethodResult(threadId);
if (threadState.eventSubscription != null) {
threadState.eventSubscription.dispose();
}
}
} else if (event instanceof StepEvent) {
ThreadReference thread = ((StepEvent) event).thread();
threadState.deleteStepRequest(eventRequestManager);
if (isStepFiltersConfigured(context.getStepFilters())) {
try {
if (threadState.pendingStepType == Command.STEPIN) {
int currentStackDepth = thread.frameCount();
Location currentStepLocation = getTopFrame(thread).location();
// If the ending step location is filtered, or same as the original location where the step into operation is originated,
// do another step of the same kind.
if (shouldFilterLocation(threadState.stepLocation, currentStepLocation, context)
|| shouldDoExtraStepInto(threadState.stackDepth, threadState.stepLocation, currentStackDepth, currentStepLocation)) {
threadState.pendingStepRequest = DebugUtility.createStepIntoRequest(thread,
context.getStepFilters().allowClasses,
context.getStepFilters().skipClasses);
threadState.pendingStepRequest.enable();
debugEvent.shouldResume = true;
return;
}
}
} catch (IncompatibleThreadStateException | IndexOutOfBoundsException ex) {
// ignore.
}
}
threadState.deleteMethodExitRequest(eventRequestManager);
if (threadState.eventSubscription != null) {
threadState.eventSubscription.dispose();
}
context.getProtocolServer().sendEvent(new Events.StoppedEvent("step", thread.uniqueID()));
debugEvent.shouldResume = false;
} else if (event instanceof MethodExitEvent) {
MethodExitEvent methodExitEvent = (MethodExitEvent) event;
long threadId = methodExitEvent.thread().uniqueID();
if (threadId == threadState.threadId && methodExitEvent.method().equals(threadState.stepLocation.method())) {
Value returnValue = methodExitEvent.returnValue();
if (returnValue instanceof VoidValue) {
context.getStepResultManager().removeMethodResult(threadId);
} else {
JdiMethodResult methodResult = new JdiMethodResult(methodExitEvent.method(), returnValue);
context.getStepResultManager().setMethodResult(threadId, methodResult);
}
}
debugEvent.shouldResume = true;
}
}