use the location from the locatable event to avoid fetching frame information too early

GitOrigin-RevId: bd1fb7f09361b93cc416b8243608830421cea2e9
This commit is contained in:
Egor Ushakov
2019-08-02 12:03:41 +03:00
committed by intellij-monorepo-bot
parent 74a6ffe443
commit 8016e08267
3 changed files with 25 additions and 13 deletions
@@ -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 &&
@@ -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(){
@@ -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<Pair<Breakpoint, com.sun.jdi.event.Event>> eventDescriptors = DebuggerUtilsEx.getEventDescriptors(suspendContext);
final RequestManagerImpl requestsManager = suspendContext.getDebugProcess().getRequestsManager();