diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java b/java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java index 9fcf1549c937..315d6241b752 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java @@ -194,17 +194,7 @@ public class RequestHint { public int getNextStepDepth(final SuspendContextImpl context) { try { - Location location; - // getting location from the event set is much faster than obtaining the frame and getting it from there - LocatableEvent event = - StreamEx.of(ContainerUtil.notNullize(context.getEventSet())).select(LocatableEvent.class).findFirst().orElse(null); - if (event != null) { - location = event.location(); - } - else { - StackFrameProxyImpl frameProxy = context.getFrameProxy(); - location = frameProxy != null ? frameProxy.location() : null; - } + Location location = context.getLocation(); // smart step feature stop check if (myMethodFilter != null && diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java index c0bac0b57433..b45ec442f2cf 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java @@ -14,9 +14,11 @@ import com.intellij.diagnostic.ThreadDumper; import com.intellij.openapi.diagnostic.Logger; import com.intellij.xdebugger.frame.XExecutionStack; import com.intellij.xdebugger.frame.XSuspendContext; +import com.sun.jdi.Location; import com.sun.jdi.ObjectReference; import com.sun.jdi.ThreadReference; import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.LocatableEvent; import com.sun.jdi.request.EventRequest; import one.util.streamex.StreamEx; import org.intellij.lang.annotations.MagicConstant; @@ -68,6 +70,25 @@ public abstract class SuspendContextImpl extends XSuspendContext implements Susp myThread = threadProxy; } + @Nullable + public Location getLocation() { + // getting location from the event set is much faster than obtaining the frame and getting it from there + if (myEventSet != null) { + LocatableEvent event = StreamEx.of(myEventSet).select(LocatableEvent.class).findFirst().orElse(null); + if (event != null) { + return event.location(); + } + } + try { + StackFrameProxyImpl frameProxy = getFrameProxy(); + return frameProxy != null ? frameProxy.location() : null; + } + catch (Throwable e) { + LOG.debug(e); + } + return null; + } + protected abstract void resumeImpl(); protected void resume(){ diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java index 7ae59baf95b3..c4819fed81e2 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java @@ -487,6 +487,7 @@ public class DebuggerSession implements AbstractDebuggerSession { } final StackFrameContext positionContext; + SourcePosition position; if (currentThread == null) { //Pause pressed @@ -545,9 +546,11 @@ public class DebuggerSession implements AbstractDebuggerSession { } } positionContext = new SimpleStackFrameContext(proxy, myDebugProcess); + position = ContextUtil.getSourcePosition(positionContext); } else { positionContext = suspendContext; + position = myDebugProcess.getPositionManager().getSourcePosition(suspendContext.getLocation()); } if (currentThread != null) { @@ -563,8 +566,6 @@ public class DebuggerSession implements AbstractDebuggerSession { } } - SourcePosition position = ContextUtil.getSourcePosition(positionContext); - if (position != null) { final List> eventDescriptors = DebuggerUtilsEx.getEventDescriptors(suspendContext); final RequestManagerImpl requestsManager = suspendContext.getDebugProcess().getRequestsManager();