From 57f98ab8bb869ea8ad77b7195dfbf9e26a01eb30 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Mon, 29 Jun 2015 18:44:45 +0300 Subject: [PATCH] IDEA-63378 Switching threads should be optional, not forced --- .../intellij/debugger/actions/PopFrameAction.java | 3 ++- .../intellij/debugger/impl/DebuggerSession.java | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/PopFrameAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/PopFrameAction.java index 8bc65d9c7f28..3eba87e44a96 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/PopFrameAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/PopFrameAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,6 +80,7 @@ public class PopFrameAction extends DebuggerAction { return; } + debugProcess.getSession().setSteppingThrough(stackFrame.getStackFrameProxy().threadProxy()); if (!DebuggerSettings.EVALUATE_FINALLY_NEVER.equals(DebuggerSettings.getInstance().EVALUATE_FINALLY_ON_POP_FRAME)) { List statements = getFinallyStatements(debuggerContext.getSourcePosition()); if (!statements.isEmpty()) { 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 6346d831943f..04bf6d8aa302 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java @@ -55,6 +55,7 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.unscramble.ThreadState; import com.intellij.util.Alarm; import com.intellij.util.TimeoutUtil; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.AbstractDebuggerSession; import com.intellij.xdebugger.XDebugSession; @@ -70,7 +71,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collection; -import java.util.HashSet; import java.util.List; import java.util.Set; @@ -109,7 +109,7 @@ public class DebuggerSession implements AbstractDebuggerSession { private final DebuggerContextImpl SESSION_EMPTY_CONTEXT; //Thread, user is currently stepping through - private final Set mySteppingThroughThreads = new HashSet(); + private final Set mySteppingThroughThreads = ContainerUtil.newConcurrentSet(); protected final Alarm myUpdateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD); private boolean myModifiedClassesScanRequired = false; @@ -118,6 +118,10 @@ public class DebuggerSession implements AbstractDebuggerSession { return mySteppingThroughThreads.contains(threadProxy); } + public boolean setSteppingThrough(ThreadReferenceProxyImpl threadProxy) { + return mySteppingThroughThreads.add(threadProxy); + } + @NotNull public GlobalSearchScope getSearchScope() { //noinspection ConstantConditions @@ -567,10 +571,6 @@ public class DebuggerSession implements AbstractDebuggerSession { } private boolean shouldSetAsActiveContext(final SuspendContextImpl suspendContext) { - // always switch context if it is not a breakpoint stop - if (DebuggerUtilsEx.getEventDescriptors(suspendContext).isEmpty()) { - return true; - } final ThreadReferenceProxyImpl newThread = suspendContext.getThread(); if (newThread == null || suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_ALL || isSteppingThrough(newThread)) { return true; @@ -589,7 +589,7 @@ public class DebuggerSession implements AbstractDebuggerSession { @Override public void resumed(final SuspendContextImpl suspendContext) { - final SuspendContextImpl currentContext = getProcess().getSuspendManager().getPausedContext(); + final SuspendContextImpl currentContext = isSteppingThrough(suspendContext.getThread()) ? null : getProcess().getSuspendManager().getPausedContext(); DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() { @Override public void run() { -- 2.32.0