[debugger] IDEA-350301 Refactor: migrate from DebugProcessImpl.getManagerThread

GitOrigin-RevId: aeb58d697d0a0d841958798690dfcf8dff538fc4
This commit is contained in:
Maksim Zuev
2024-11-15 13:16:54 +00:00
committed by intellij-monorepo-bot
parent e009b86193
commit c11d11ade8
68 changed files with 175 additions and 155 deletions
@@ -3,6 +3,7 @@ package com.intellij.debugger.actions;
import com.intellij.debugger.JavaDebuggerBundle;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.events.DebuggerCommandImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
@@ -23,13 +24,15 @@ import org.jetbrains.annotations.NotNull;
public class AddSteppingFilterAction extends DebuggerAction {
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
DebugProcessImpl process = debuggerContext.getDebugProcess();
if (process == null) {
return;
}
StackFrameProxyImpl proxy = getStackFrameProxy(e);
process.getManagerThread().schedule(new DebuggerCommandImpl() {
DebuggerManagerThreadImpl managerThread = debuggerContext.getManagerThread();
if (managerThread == null) return;
managerThread.schedule(new DebuggerCommandImpl() {
@Override
protected void action() {
final String name = getClassName(proxy != null ? proxy : debuggerContext.getFrameProxy());
@@ -2,6 +2,7 @@
package com.intellij.debugger.actions;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.JavaValue;
import com.intellij.debugger.engine.SuspendContextImpl;
import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
@@ -108,9 +109,9 @@ public abstract class ArrayAction extends DebuggerAction {
ValueDescriptorImpl descriptor = ((JavaValue)container).getDescriptor();
DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess != null) {
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) {
DebuggerManagerThreadImpl managerThread = debuggerContext.getManagerThread();
if (managerThread != null) {
managerThread.schedule(new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
final Renderer lastRenderer = descriptor.getLastRenderer();
@@ -1,7 +1,7 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.debugger.actions;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.JavaValue;
import com.intellij.debugger.engine.SuspendContextImpl;
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
@@ -18,11 +18,11 @@ public class AutoRendererAction extends AnAction {
public void actionPerformed(@NotNull final AnActionEvent e) {
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess != null) {
final DebuggerManagerThreadImpl managerThread = debuggerContext.getManagerThread();
if (managerThread != null) {
final List<JavaValue> selectedValues = ViewAsGroup.getSelectedValues(e);
if (!selectedValues.isEmpty()) {
debugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
managerThread.schedule(new DebuggerContextCommandImpl(debuggerContext) {
@Override
public void threadAction(@NotNull SuspendContextImpl suspendContext) {
for (JavaValue selectedValue : selectedValues) {
@@ -54,7 +54,7 @@ public class CreateRendererAction extends AnAction {
final Project project = event.getProject();
process.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
javaValue.getEvaluationContext().getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
@Override
public void threadAction(@NotNull SuspendContextImpl suspendContext) {
Type type = javaValue.getDescriptor().getType();
@@ -4,6 +4,7 @@ package com.intellij.debugger.actions;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.events.DebuggerCommandImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerSession;
@@ -33,8 +34,9 @@ public class ExportThreadsAction extends AnAction {
final DebuggerSession session = context.getDebuggerSession();
if (session != null && session.isAttached()) {
final DebugProcessImpl process = context.getDebugProcess();
if (process != null) {
process.getManagerThread().invoke(new DebuggerCommandImpl() {
DebuggerManagerThreadImpl managerThread = context.getManagerThread();
if (process != null && managerThread != null) {
managerThread.invoke(new DebuggerCommandImpl() {
@Override
protected void action() {
final List<ThreadState> threads = ThreadDumpAction.buildThreadStates(process.getVirtualMachineProxy());
@@ -34,6 +34,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Objects;
public class ForceEarlyReturnAction extends DebuggerAction {
@Override
@@ -52,7 +53,7 @@ public class ForceEarlyReturnAction extends DebuggerAction {
final StackFrameProxyImpl proxy = stackFrame.getStackFrameProxy();
final ThreadReferenceProxyImpl thread = proxy.threadProxy();
debugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext, thread) {
Objects.requireNonNull(debuggerContext.getManagerThread()).schedule(new DebuggerContextCommandImpl(debuggerContext, thread) {
@Override
public void threadAction(@NotNull SuspendContextImpl suspendContext) {
Method method;
@@ -14,6 +14,8 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
public class FreezeThreadAction extends DebuggerAction {
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
@@ -29,7 +31,7 @@ public class FreezeThreadAction extends DebuggerAction {
final ThreadReferenceProxyImpl thread = threadDescriptor.getThreadReference();
if (!threadDescriptor.isFrozen()) {
DebuggerManagerThreadImpl debuggerManagerThread = debugProcess.getManagerThread();
DebuggerManagerThreadImpl debuggerManagerThread = Objects.requireNonNull(debuggerContext.getManagerThread());
debuggerManagerThread.schedule(new DebuggerCommandImpl() {
@Override
protected void action() {
@@ -19,6 +19,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
final class InterruptThreadAction extends DebuggerAction {
@Override
@@ -40,7 +41,7 @@ final class InterruptThreadAction extends DebuggerAction {
final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess != null) {
debugProcess.getManagerThread().schedule(new DebuggerCommandImpl() {
Objects.requireNonNull(debuggerContext.getManagerThread()).schedule(new DebuggerCommandImpl() {
@Override
protected void action() {
boolean unsupported = false;
@@ -65,7 +65,8 @@ public class JavaSmartStepIntoHandler extends JvmSmartStepIntoHandler {
@NotNull
private Promise<List<SmartStepTarget>> findSmartStepTargetsAsync(SourcePosition position, DebuggerSession session, boolean smart) {
var res = new AsyncPromise<List<SmartStepTarget>>();
session.getProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(session.getContextManager().getContext()) {
DebuggerContextImpl context = session.getContextManager().getContext();
Objects.requireNonNull(context.getManagerThread()).schedule(new DebuggerContextCommandImpl(context) {
@Override
public void threadAction(@NotNull SuspendContextImpl suspendContext) {
Promises.compute(res, () ->
@@ -37,6 +37,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
public class JvmDropFrameActionHandler implements XDropFrameHandler {
@@ -161,7 +162,7 @@ public class JvmDropFrameActionHandler implements XDropFrameHandler {
}
private static void popFrame(DebugProcessImpl debugProcess, DebuggerContextImpl debuggerContext, JavaStackFrame stackFrame) {
debugProcess.getManagerThread()
Objects.requireNonNull(debuggerContext.getManagerThread())
.schedule(debugProcess.createPopFrameCommand(debuggerContext, stackFrame.getStackFrameProxy()));
}
@@ -18,6 +18,8 @@ import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.application.ApplicationManager;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
public class ResumeThreadAction extends DebuggerAction {
@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
@@ -33,8 +35,8 @@ public class ResumeThreadAction extends DebuggerAction {
if (threadDescriptor.isSuspended()) {
final ThreadReferenceProxyImpl thread = threadDescriptor.getThreadReference();
DebuggerManagerThreadImpl debuggerManagerThread = debugProcess.getManagerThread();
debuggerManagerThread.schedule(new DebuggerCommandImpl() {
DebuggerManagerThreadImpl debuggerManagerThread = debuggerContext.getManagerThread();
Objects.requireNonNull(debuggerManagerThread).schedule(new DebuggerCommandImpl() {
@Override
protected void action() {
SuspendContextImpl suspendingContext = SuspendManagerUtil.getSuspendingContext(debugProcess.getSuspendManager(), thread);
@@ -2,8 +2,8 @@
package com.intellij.debugger.actions;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.SuspendContextImpl;
import com.intellij.debugger.engine.SuspendManagerImpl;
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
@@ -12,23 +12,25 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Objects;
public class SwitchToTheNextContextAction extends DebuggerAction {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
DebugProcessImpl process = debuggerContext.getDebugProcess();
if (process == null) {
return;
}
process.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
DebuggerManagerThreadImpl managerThread = Objects.requireNonNull(debuggerContext.getManagerThread());
managerThread.schedule(new DebuggerContextCommandImpl(debuggerContext) {
@Override
public void threadAction(@NotNull SuspendContextImpl suspendContext) {
List<SuspendContextImpl> pausedContexts = process.getSuspendManager().getPausedContexts();
if (pausedContexts.size() > 1) {
int currentIndex = pausedContexts.indexOf(debuggerContext.getSuspendContext());
int newIndex = (currentIndex + 1) % pausedContexts.size();
process.getManagerThread().schedule(new SuspendContextCommandImpl(pausedContexts.get(newIndex)) {
managerThread.schedule(new SuspendContextCommandImpl(pausedContexts.get(newIndex)) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
DebuggerSession.switchContext(suspendContext);
@@ -28,10 +28,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
public final class ThreadDumpAction extends DumbAwareAction {
@Override
@@ -45,7 +42,7 @@ public final class ThreadDumpAction extends DumbAwareAction {
final DebuggerSession session = context.getDebuggerSession();
if (session != null && session.isAttached()) {
final DebugProcessImpl process = context.getDebugProcess();
process.getManagerThread().invoke(new DebuggerCommandImpl() {
Objects.requireNonNull(context.getManagerThread()).invoke(new DebuggerCommandImpl() {
@Override
protected void action() {
final VirtualMachineProxyImpl vm = process.getVirtualMachineProxy();
@@ -32,6 +32,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Objects;
public class ThrowExceptionAction extends DebuggerAction {
@Override
@@ -41,7 +42,7 @@ public class ThrowExceptionAction extends DebuggerAction {
if (stackFrame == null || project == null) {
return;
}
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess == null) {
return;
@@ -50,7 +51,7 @@ public class ThrowExceptionAction extends DebuggerAction {
final StackFrameProxyImpl proxy = stackFrame.getStackFrameProxy();
final ThreadReferenceProxyImpl thread = proxy.threadProxy();
debugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext, thread) {
Objects.requireNonNull(debuggerContext.getManagerThread()).schedule(new DebuggerContextCommandImpl(debuggerContext, thread) {
@Override
public void threadAction(@NotNull SuspendContextImpl suspendContext) {
ApplicationManager.getApplication().invokeLater(
@@ -3,7 +3,7 @@ package com.intellij.debugger.actions;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.SourcePosition;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.SourcePositionProvider;
import com.intellij.debugger.engine.SuspendContextImpl;
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
@@ -109,10 +109,10 @@ public class ToggleFieldBreakpointAction extends AnAction implements ActionRemot
NodeDescriptorImpl descriptor = ((NodeDescriptorProvider)value).getDescriptor();
if (descriptor instanceof FieldDescriptorImpl) {
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(dataContext);
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess != null) { // if there is an active debug session
DebuggerManagerThreadImpl managerThread = debuggerContext.getManagerThread();
if (managerThread != null) { // if there is an active debug session
final Ref<SourcePosition> positionRef = new Ref<>(null);
debugProcess.getManagerThread().invokeAndWait(new DebuggerContextCommandImpl(debuggerContext) {
managerThread.invokeAndWait(new DebuggerContextCommandImpl(debuggerContext) {
@Override
public Priority getPriority() {
return Priority.HIGH;
@@ -2,6 +2,7 @@
package com.intellij.debugger.actions;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.JavaValue;
import com.intellij.debugger.engine.SuspendContextImpl;
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
@@ -25,6 +26,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
public class ViewAsGroup extends ActionGroup implements DumbAware {
@@ -76,12 +78,12 @@ public class ViewAsGroup extends ActionGroup implements DumbAware {
LOG.assertTrue(!values.isEmpty());
DebugProcessImpl process = debuggerContext.getDebugProcess();
if (process == null) {
DebuggerManagerThreadImpl managerThread = debuggerContext.getManagerThread();
if (managerThread == null) {
return;
}
process.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
managerThread.schedule(new DebuggerContextCommandImpl(debuggerContext) {
@Override
public void threadAction(@NotNull SuspendContextImpl suspendContext) {
for (XValueNodeImpl node : selectedNodes) {
@@ -109,7 +111,7 @@ public class ViewAsGroup extends ActionGroup implements DumbAware {
List<JavaValue> values = getSelectedValues(e);
if (!values.isEmpty()) {
CompletableFuture<List<NodeRenderer>> future = new CompletableFuture<>();
boolean scheduled = process.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
boolean scheduled = Objects.requireNonNull(debuggerContext.getManagerThread()).schedule(new DebuggerContextCommandImpl(debuggerContext) {
@Override
public void threadAction(@NotNull SuspendContextImpl suspendContext) {
getApplicableRenderers(values, process)
@@ -20,6 +20,8 @@ import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
public final class JavaWithRuntimeCastSurrounder extends JavaExpressionSurrounder {
@Override
@@ -47,7 +49,7 @@ public final class JavaWithRuntimeCastSurrounder extends JavaExpressionSurrounde
final ProgressWindow progressWindow = new ProgressWindow(true, expr.getProject());
SurroundWithCastWorker worker = new SurroundWithCastWorker(editor, expr, debuggerContext, progressWindow);
progressWindow.setTitle(JavaDebuggerBundle.message("title.evaluating"));
debuggerContext.getDebugProcess().getManagerThread().startProgress(worker, progressWindow);
Objects.requireNonNull(debuggerContext.getManagerThread()).startProgress(worker, progressWindow);
}
return null;
}
@@ -641,7 +641,7 @@ public class DebugProcessEvents extends DebugProcessImpl {
//we use schedule to allow processing other events during processing this one
//this is especially necessary if a method is breakpoint condition
getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
suspendContext.getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
logSuspendContext(suspendContext, "start locatable event processing");
@@ -975,7 +975,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
if (myState.compareAndSet(State.INITIAL, State.DETACHING) || myState.compareAndSet(State.ATTACHED, State.DETACHING)) {
try {
if (!keepManagerThread) {
getManagerThread().close();
myDebuggerManagerThread.close();
}
}
finally {
@@ -1023,7 +1023,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
}
private void onRootProcessClosed() {
getManagerThread().cancelScope();
myDebuggerManagerThread.cancelScope();
myWaitFor.up();
}
@@ -2290,7 +2290,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
for (SuspendContextImpl suspendContext : suspendingContexts) {
if (suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD && suspendContext.getEventThread() == myThread) {
getSession().getXDebugSession().sessionResumed();
getManagerThread().invoke(createResumeCommand(suspendContext));
getCommandManagerThread().invoke(createResumeCommand(suspendContext));
}
else {
DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().removeThreadFilter(context.getDebugProcess());
@@ -2429,7 +2429,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
if (vmData != null && vmData.vm != null) {
myDebuggerManagerThread = vmData.debuggerManagerThread;
reattach(vmData.connection, () -> {}, () -> {
afterProcessStarted(() -> getManagerThread().schedule(new DebuggerCommandImpl() {
afterProcessStarted(() -> vmData.debuggerManagerThread.schedule(new DebuggerCommandImpl() {
@Override
protected void action() {
try {
@@ -2619,7 +2619,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
if (vm != null) {
final VirtualMachine vm1 = vm;
afterProcessStarted(() -> getManagerThread().schedule(new DebuggerCommandImpl(PrioritizedTask.Priority.HIGH) {
afterProcessStarted(() -> getCommandManagerThread().schedule(new DebuggerCommandImpl(PrioritizedTask.Priority.HIGH) {
@Override
protected void action() {
try {
@@ -118,7 +118,7 @@ public class JavaDebugProcess extends XDebugProcess {
final SuspendContextImpl newSuspendContext = newContext.getSuspendContext();
if (newSuspendContext != null &&
(shouldApplyContext(newContext) || event == DebuggerSession.Event.REFRESH_WITH_STACK)) {
process.getManagerThread().schedule(new SuspendContextCommandImpl(newSuspendContext) {
newSuspendContext.getManagerThread().schedule(new SuspendContextCommandImpl(newSuspendContext) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
ThreadReferenceProxyImpl threadProxy = newContext.getThreadProxy();
@@ -191,7 +191,8 @@ public class JavaExecutionStack extends XExecutionStack {
if (container.isObsolete()) return;
SuspendContextImpl pausedContext = SuspendManagerUtil.getPausedSuspendingContext(myDebugProcess.getSuspendManager(), myThreadProxy);
SuspendContextImpl context = pausedContext != null ? pausedContext : myDebugProcess.getDebuggerContext().getSuspendContext();
myDebugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(context) {
if (context == null) return;
context.getManagerThread().schedule(new SuspendContextCommandImpl(context) {
@Override
public Priority getPriority() {
return Priority.NORMAL;
@@ -214,7 +215,7 @@ public class JavaExecutionStack extends XExecutionStack {
iterator.next();
added++;
}
myDebugProcess.getManagerThread().schedule(
suspendContext.getManagerThread().schedule(
new AppendFrameCommand(suspendContext, iterator, container, added, firstFrameIndex));
}
catch (EvaluateException e) {
@@ -393,7 +394,7 @@ public class JavaExecutionStack extends XExecutionStack {
@Nullable List<? extends StackFrameItem> asyncStackFrames,
@Nullable List<? extends StackFrameItem> creationStackFrames,
boolean separator) {
myDebugProcess.getManagerThread().schedule(
suspendContext.getManagerThread().schedule(
new AppendFrameCommand(suspendContext, stackFramesIterator, myContainer,
myAdded, mySkip, myHiddenFrames, asyncStackFrames, creationStackFrames, myAddedAsync, separator));
}
@@ -115,7 +115,7 @@ public class JavaStackFrame extends XStackFrame implements JVMStackFrameInfoProv
}
private void scheduleComputeChildrenTask(@NotNull XCompositeNode node, DebuggerContextImpl context, ThreadReferenceProxyImpl thread) {
myDebugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(context, thread) {
Objects.requireNonNull(context.getManagerThread()).schedule(new DebuggerContextCommandImpl(context, thread) {
@Override
public Priority getPriority() {
return Priority.NORMAL;
@@ -522,7 +522,7 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
public void computeTypeSourcePosition(@NotNull final XNavigatable navigatable) {
if (myEvaluationContext.getSuspendContext().isResumed()) return;
DebugProcessImpl debugProcess = myEvaluationContext.getDebugProcess();
debugProcess.getManagerThread().schedule(new NavigateCommand(getDebuggerContext(), myValueDescriptor, debugProcess, null) {
myEvaluationContext.getManagerThread().schedule(new NavigateCommand(getDebuggerContext(), myValueDescriptor, debugProcess, null) {
@Override
public Priority getPriority() {
return Priority.HIGH;
@@ -738,7 +738,7 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
catch (ClassNotLoadedException ex) {
final String className = ex.className();
if (loadClass(className) != null) {
myDebugProcess.getManagerThread().schedule(createRetryCommand());
suspendContext.getManagerThread().schedule(createRetryCommand());
}
}
}
@@ -254,7 +254,7 @@ public abstract class JavaValueModifier extends XValueModifier implements XStrin
};
progressWindow.setTitle(JavaDebuggerBundle.message("title.evaluating"));
evaluationContext.getDebugProcess().getManagerThread().startProgress(askSetAction, progressWindow);
evaluationContext.getManagerThread().startProgress(askSetAction, progressWindow);
}
@Override
@@ -33,8 +33,7 @@ public abstract class PossiblySyncCommand extends SuspendContextCommandImpl {
if (delay < 0 || myRetries-- <= 0) {
return false;
}
DebugProcess process = suspendContext.getDebugProcess();
DebuggerManagerThreadImpl managerThread = ((DebuggerManagerThreadImpl)process.getManagerThread());
DebuggerManagerThreadImpl managerThread = suspendContext.getManagerThread();
VirtualMachine virtualMachine = suspendContext.getVirtualMachineProxy().getVirtualMachine();
if (!(virtualMachine instanceof VirtualMachineImpl) ||
!managerThread.hasAsyncCommands() && ((VirtualMachineImpl)virtualMachine).isIdle()) {
@@ -43,10 +42,7 @@ public abstract class PossiblySyncCommand extends SuspendContextCommandImpl {
else {
// reschedule with a small delay
hold();
AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> {
DebuggerManagerThreadImpl thread = (DebuggerManagerThreadImpl)process.getManagerThread();
return thread.schedule(this);
}, delay, TimeUnit.MILLISECONDS);
AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> managerThread.schedule(this), delay, TimeUnit.MILLISECONDS);
return true;
}
}
@@ -49,7 +49,8 @@ private class CancelingSteppingListener : SteppingListener {
val steppingName = steppingAction.steppingName
val stepCompetedStatus = CompletableDeferred<Unit>()
debuggerProcessImpl.managerThread.schedule(PrioritizedTask.Priority.NORMAL) {
val managerThread = suspendContext.managerThread
managerThread.schedule(PrioritizedTask.Priority.NORMAL) {
// Need to schedule in the separate debugger command, so async name getter will not fail
// because of the current suspend context become resumed
val whereStrFuture: CompletableFuture<String> = if (threadForStepping != null) {
@@ -64,11 +65,11 @@ private class CancelingSteppingListener : SteppingListener {
whereStrFuture.thenAccept { whereStr ->
@Suppress("HardCodedStringLiteral")
val steppingRestrictionMessage = getSteppingRestrictionMessage(whereStr, steppingAction)
debuggerProcessImpl.managerThread.makeCancelable(debuggerProcessImpl.project, steppingRestrictionMessage, steppingName, stepCompetedStatus) {
managerThread.makeCancelable(debuggerProcessImpl.project, steppingRestrictionMessage, steppingName, stepCompetedStatus) {
val command: DebuggerCommandImpl =
if (needSuspendOnlyThread) debuggerProcessImpl.createFreezeThreadCommand(threadForStepping)
else debuggerProcessImpl.createPauseCommand(threadForStepping)
debuggerProcessImpl.managerThread.schedule(command)
managerThread.schedule(command)
}
}
}
@@ -487,7 +487,7 @@ public abstract class SuspendContextImpl extends XSuspendContext implements Susp
@Override
public void computeExecutionStacks(final XExecutionStackContainer container) {
assertCanBeUsed();
myDebugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(this) {
getManagerThread().schedule(new SuspendContextCommandImpl(this) {
final Set<ThreadReferenceProxyImpl> myAddedThreads = new HashSet<>();
@Override
@@ -348,7 +348,7 @@ public class SuspendManagerImpl implements SuspendManager {
}
// resume in a separate request to allow other requests be processed (e.g. dependent bpts enable)
suspendContext.myIsGoingToResume = true;
myDebugProcess.getManagerThread().schedule(PrioritizedTask.Priority.HIGH, () -> resume(suspendContext));
suspendContext.getManagerThread().schedule(PrioritizedTask.Priority.HIGH, () -> resume(suspendContext));
}
private void notifyPaused(@NotNull SuspendContextImpl suspendContext, boolean pushPaused) {
@@ -87,7 +87,7 @@ public final class SuspendManagerUtil {
public static void switchToThreadInSuspendAllContext(@NotNull SuspendContextImpl suspendAllContext, @NotNull ThreadReferenceProxyImpl threadProxy) {
assert suspendAllContext.getSuspendPolicy() == EventRequest.SUSPEND_ALL;
DebugProcessImpl debugProcess = suspendAllContext.getDebugProcess();
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(suspendAllContext) {
suspendAllContext.getManagerThread().schedule(new SuspendContextCommandImpl(suspendAllContext) {
@Override
public void contextAction(@NotNull SuspendContextImpl c) {
DebuggerSession session = debugProcess.getSession();
@@ -123,7 +123,7 @@ public class SuspendOtherThreadsRequestor implements FilteredRequestor {
//noinspection DataFlowIssue
newSuspendContext.setThread(suspendContext.getEventThread().getThreadReference());
if (processSuspendAll(newSuspendContext, suspendContext, performOnSuspendAll)) {
process.getManagerThread().schedule(new SuspendContextCommandImpl(newSuspendContext) {
newSuspendContext.getManagerThread().schedule(new SuspendContextCommandImpl(newSuspendContext) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
//noinspection DataFlowIssue
@@ -199,7 +199,7 @@ public class SuspendOtherThreadsRequestor implements FilteredRequestor {
.warn("Fails attempt to switch from suspend-thread context to suspend-all context. Will be rescheduled.");
// Reschedule the request after some time to finish the evaluation.
// noinspection SSBasedInspection
new SingleAlarm(() -> myProcess.getManagerThread().schedule(new DebuggerCommandImpl() {
new SingleAlarm(() -> suspendContext.getManagerThread().schedule(new DebuggerCommandImpl() {
@Override
protected void action() {
enableRequest(myProcess, myParameters);
@@ -117,7 +117,7 @@ public class ThreadBlockedMonitor {
protected void action() {
ThreadReferenceProxyImpl threadProxy = process.getVirtualMachineProxy().getThreadReferenceProxy(blockingThread);
SuspendContextImpl suspendingContext = SuspendManagerUtil.getSuspendingContext(process.getSuspendManager(), threadProxy);
process.getManagerThread()
getCommandManagerThread()
.invoke(process.createResumeThreadCommand(suspendingContext, threadProxy));
}
});
@@ -36,6 +36,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.concurrency.CancellablePromise;
import java.util.Objects;
import java.util.concurrent.Callable;
import static com.intellij.xdebugger.impl.dfaassist.DfaAssistBase.AssistMode.*;
@@ -123,7 +124,7 @@ public final class DfaAssist extends DfaAssistBase implements DebuggerContextLis
return;
}
SmartPsiElementPointer<PsiElement> pointer = SmartPointerManager.createPointer(element);
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(newContext.getSuspendContext()) {
Objects.requireNonNull(newContext.getManagerThread()).schedule(new SuspendContextCommandImpl(newContext.getSuspendContext()) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
StackFrameProxyImpl proxy = suspendContext.getFrameProxy();
@@ -6,6 +6,7 @@ import com.intellij.codeInsight.completion.JavaCompletionUtil;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.JavaDebuggerBundle;
import com.intellij.debugger.codeinsight.RuntimeTypeEvaluator;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.JavaDebuggerCodeFragmentFactory;
import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilder;
import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilderImpl;
@@ -82,8 +83,8 @@ public class DefaultCodeFragmentFactory extends JavaDebuggerCodeFragmentFactory
}
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(project).getContext();
DebuggerSession debuggerSession = debuggerContext.getDebuggerSession();
if (debuggerSession != null && debuggerContext.getSuspendContext() != null) {
DebuggerManagerThreadImpl managerThread = debuggerContext.getManagerThread();
if (managerThread != null) {
final Semaphore semaphore = new Semaphore();
semaphore.down();
final AtomicReference<PsiType> nameRef = new AtomicReference<>();
@@ -95,7 +96,7 @@ public class DefaultCodeFragmentFactory extends JavaDebuggerCodeFragmentFactory
semaphore.up();
}
};
debuggerSession.getProcess().getManagerThread().invoke(worker);
managerThread.invoke(worker);
for (int i = 0; i < 50; i++) {
ProgressManager.checkCanceled();
if (semaphore.waitFor(20)) break;
@@ -83,7 +83,7 @@ public final class EvaluationContextImpl extends UserDataHolderBase implements E
}
public DebuggerManagerThreadImpl getManagerThread() {
return getDebugProcess().getManagerThread();
return getSuspendContext().getManagerThread();
}
@Override
@@ -83,7 +83,7 @@ abstract class SuspendContextCommandImpl protected constructor(open val suspendC
else {
val postponed = suspendContext.pollPostponedCommand()
if (postponed != null) {
suspendContext.debugProcess.managerThread.pushBack(postponed)
suspendContext.managerThread.pushBack(postponed)
}
}
}
@@ -90,6 +90,13 @@ public final class DebuggerContextImpl implements DebuggerContext {
return myFrameProxy;
}
public @Nullable DebuggerManagerThreadImpl getManagerThread() {
if (mySuspendContext != null) return mySuspendContext.getManagerThread();
DebugProcessImpl debugProcess = getDebugProcess();
//noinspection UsagesOfObsoleteApi
return debugProcess != null ? debugProcess.getManagerThread() : null;
}
public SourcePosition getSourcePosition() {
LOG.assertTrue(myInitialized);
return mySourcePosition;
@@ -28,6 +28,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -38,7 +39,7 @@ public final class DebuggerContextUtil {
final DebuggerSession session = context.getDebuggerSession();
if (session != null) {
session.getProcess().getManagerThread().schedule(new DebuggerCommandImpl(PrioritizedTask.Priority.HIGH) {
Objects.requireNonNull(context.getManagerThread()).schedule(new DebuggerCommandImpl(PrioritizedTask.Priority.HIGH) {
@Override
protected void action() {
SuspendContextImpl threadSuspendContext =
@@ -86,7 +87,7 @@ public final class DebuggerContextUtil {
action.accept(defaultDebuggerContext);
}
else {
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(pausedContext) {
pausedContext.getManagerThread().schedule(new SuspendContextCommandImpl(pausedContext) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
DebuggerContextImpl debuggerContext = DebuggerContextImpl.createDebuggerContext(
@@ -176,11 +176,12 @@ public final class DebuggerSession implements AbstractDebuggerSession {
fireStateChanged(context, event);
};
if (context.getSuspendContext() == null) {
SuspendContextImpl suspendContext = context.getSuspendContext();
if (suspendContext == null) {
setStateRunnable.run();
}
else {
getProcess().getManagerThread().schedule(new SuspendContextCommandImpl(context.getSuspendContext()) {
suspendContext.getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
@Override
public Priority getPriority() {
return Priority.HIGH;
@@ -783,7 +784,7 @@ public final class DebuggerSession implements AbstractDebuggerSession {
public static void switchContext(@NotNull SuspendContextImpl suspendContext) {
DebugProcessImpl debugProcess = suspendContext.getDebugProcess();
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
suspendContext.getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
DebuggerSession session = debugProcess.getSession();
@@ -54,7 +54,7 @@ public final class SourceCodeChecker {
if (suspendContext == null) {
return;
}
suspendContext.getDebugProcess().getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
suspendContext.getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
@@ -45,7 +45,7 @@ public class CalculateRetainedSizeAction extends DebuggerTreeAction {
dialog.show();
SuspendContextImpl suspendContext = debugProcess.getSuspendManager().getPausedContext();
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
suspendContext.getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
try {
@@ -56,7 +56,7 @@ public class PathsToClosestGcRootsDialog extends MemoryAgentDialog {
DebugProcessImpl debugProcess = javaDebugProcess.getDebuggerSession().getProcess();
SuspendContextImpl suspendContext = debugProcess.getSuspendManager().getPausedContext();
PathsToClosestGcRootsDialog dialog = this;
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
suspendContext.getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
if (dialog.isDisposed()) {
@@ -210,7 +210,7 @@ public class ClassesFilteredView extends ClassesFilteredViewBase {
@Override
protected void scheduleUpdateClassesCommand(XSuspendContext context) {
SuspendContextImpl suspendContext = (SuspendContextImpl)context;
suspendContext.getDebugProcess().getManagerThread().schedule(new MyUpdateClassesCommand(suspendContext));
suspendContext.getManagerThread().schedule(new MyUpdateClassesCommand(suspendContext));
}
@Nullable
@@ -167,7 +167,7 @@ class CollectionHistoryView(private val myClsName: String,
private fun createChildren(values: List<Value>, renderer: NodeRenderer?): XValueChildrenList {
val children = XValueChildrenList()
myDebugProcess.managerThread.invokeAndWait(object : DebuggerCommandImpl() {
mySuspendContext.managerThread.invokeAndWait(object : DebuggerCommandImpl() {
override fun action() {
for (ins in values) {
val evalContext = EvaluationContextImpl(mySuspendContext, mySuspendContext.frameProxy)
@@ -184,7 +184,7 @@ class CollectionHistoryView(private val myClsName: String,
}
private fun invokeInDebuggerThread(runnable: () -> Unit) {
myDebugProcess.managerThread.schedule(object : DebuggerCommandImpl() {
mySuspendContext.managerThread.schedule(object : DebuggerCommandImpl() {
override fun action() {
runnable()
}
@@ -46,6 +46,7 @@ import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperti
import javax.swing.*;
import java.util.List;
import java.util.Objects;
public abstract class BreakpointWithHighlighter<P extends JavaBreakpointProperties> extends Breakpoint<P> {
private static final Logger LOG = Logger.getInstance(BreakpointWithHighlighter.class);
@@ -337,7 +338,7 @@ public abstract class BreakpointWithHighlighter<P extends JavaBreakpointProperti
updateCaches(null);
}
else {
debugProcess.getManagerThread().invoke(new DebuggerCommandImpl() {
Objects.requireNonNull(context.getManagerThread()).invoke(new DebuggerCommandImpl() {
@Override
protected void action() {
if (!myProject.isDisposed()) {
@@ -800,7 +800,7 @@ public final class CollectionBreakpoint extends BreakpointWithHighlighter<JavaCo
try {
DebugProcessImpl debugProcess = context.getDebugProcess();
DebugProcessImpl.ResumeCommand stepOutCommand = debugProcess.createStepOutCommand(context);
debugProcess.getManagerThread().schedule(stepOutCommand);
context.getManagerThread().schedule(stepOutCommand);
}
catch (Exception e) {
DebuggerUtilsImpl.logError(e);
@@ -24,10 +24,7 @@ import com.intellij.xdebugger.XDebuggerBundle;
import javax.swing.*;
import javax.swing.event.TreeModelEvent;
import javax.swing.tree.TreePath;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.*;
public class ThreadsDebuggerTree extends DebuggerTree {
private static final Logger LOG = Logger.getInstance(ThreadsDebuggerTree.class);
@@ -64,7 +61,7 @@ public class ThreadsDebuggerTree extends DebuggerTree {
final DebuggerSession.State state = session != null ? session.getState() : DebuggerSession.State.DISPOSED;
if (ApplicationManager.getApplication().isUnitTestMode() || state == DebuggerSession.State.PAUSED || state == DebuggerSession.State.RUNNING) {
showMessage(MessageDescriptor.EVALUATING);
context.getDebugProcess().getManagerThread().schedule(command);
Objects.requireNonNull(context.getManagerThread()).schedule(command);
}
else {
showMessage(session != null ? session.getStateDescription() : JavaDebuggerBundle.message("status.debug.stopped"));
@@ -3,7 +3,7 @@ package com.intellij.debugger.ui.impl;
import com.intellij.debugger.actions.DebuggerAction;
import com.intellij.debugger.actions.GotoFrameSourceAction;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.events.DebuggerCommandImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerContextListener;
@@ -81,9 +81,9 @@ public final class ThreadsPanel extends DebuggerTreePanel {
final ThreadsDebuggerTree tree = getThreadsTree();
final DebuggerTreeNodeImpl root = (DebuggerTreeNodeImpl)tree.getModel().getRoot();
if (root != null) {
final DebugProcessImpl process = getContext().getDebugProcess();
if (process != null) {
process.getManagerThread().invoke(new DebuggerCommandImpl() {
DebuggerManagerThreadImpl managerThread = getContext().getManagerThread();
if (managerThread != null) {
managerThread.invoke(new DebuggerCommandImpl() {
@Override
protected void action() {
try {
@@ -7,7 +7,7 @@
package com.intellij.debugger.ui.impl.watch;
import com.intellij.debugger.DebuggerInvocationUtil;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.SuspendContextImpl;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
@@ -123,12 +123,12 @@ public abstract class DebuggerTree extends DnDAwareTree implements UiDataProvide
if (node == null || node.getDescriptor() == null) {
return;
}
final DebugProcessImpl debugProcess = getDebuggerContext().getDebugProcess();
if (debugProcess != null) {
DebuggerManagerThreadImpl managerThread = getDebuggerContext().getManagerThread();
if (managerThread != null) {
DebuggerCommandImpl command = getBuildNodeCommand(node);
if (command != null) {
node.add(myNodeManager.createMessageNode(MessageDescriptor.EVALUATING));
debugProcess.getManagerThread().schedule(command);
managerThread.schedule(command);
}
}
}
@@ -280,13 +280,13 @@ public abstract class DebuggerTree extends DnDAwareTree implements UiDataProvide
public void rebuild(final DebuggerContextImpl context) {
ThreadingAssertions.assertEventDispatchThread();
final DebugProcessImpl process = context.getDebugProcess();
if (process == null) {
DebuggerManagerThreadImpl managerThread = context.getManagerThread();
if (managerThread == null) {
return; // empty context, no process available yet
}
myDebuggerContext = context;
saveState();
process.getManagerThread().schedule(PrioritizedTask.Priority.NORMAL, () -> getNodeFactory().setHistoryByContext(context));
managerThread.schedule(PrioritizedTask.Priority.NORMAL, () -> getNodeFactory().setHistoryByContext(context));
build(context);
}
@@ -28,6 +28,7 @@ import javax.swing.*;
import javax.swing.tree.MutableTreeNode;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
public class DebuggerTreeNodeImpl extends TreeBuilderNode implements DebuggerTreeNode, NodeDescriptorProvider, MutableTreeNode {
private Icon myIcon;
@@ -108,7 +109,7 @@ public class DebuggerTreeNodeImpl extends TreeBuilderNode implements DebuggerTre
myIcon = DebuggerTreeRenderer.getDescriptorIcon(MessageDescriptor.EVALUATING);
myText = DebuggerTreeRenderer.getDescriptorText(context, MessageDescriptor.EVALUATING, false);
context.getDebugProcess().getManagerThread().invoke(new DebuggerContextCommandImpl(context) {
Objects.requireNonNull(context.getManagerThread()).invoke(new DebuggerContextCommandImpl(context) {
@Override
public void threadAction(@NotNull SuspendContextImpl suspendContext) {
runnable.run();
@@ -173,7 +173,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
final Semaphore semaphore = new Semaphore();
semaphore.down();
evalContext.getDebugProcess().getManagerThread().invoke(new SuspendContextCommandImpl(evalContext.getSuspendContext()) {
evalContext.getManagerThread().invoke(new SuspendContextCommandImpl(evalContext.getSuspendContext()) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
// re-setting the context will cause value recalculation
@@ -96,8 +96,7 @@ final class ArrayFilterInplaceEditor(node: XDebuggerTreeNode, private val myTemp
fun edit(node: XDebuggerTreeNode, temp: Boolean) {
val javaValue = (node.parent as XValueNodeImpl).valueContainer
if (javaValue is JavaValue) {
val debugProcess = javaValue.evaluationContext.debugProcess
debugProcess.managerThread.schedule(
javaValue.evaluationContext.managerThread.schedule(
object : SuspendContextCommandImpl(javaValue.evaluationContext.suspendContext) {
override fun getPriority(): PrioritizedTask.Priority {
return PrioritizedTask.Priority.NORMAL
@@ -25,32 +25,28 @@ import java.util.*;
public final class BatchEvaluator {
private static final Logger LOG = Logger.getInstance(BatchEvaluator.class);
private final DebugProcess myDebugProcess;
private static final Key<BatchEvaluator> BATCH_EVALUATOR_KEY = new Key<>("BatchEvaluator");
public static final Key<Boolean> REMOTE_SESSION_KEY = new Key<>("is_remote_session_key");
private final HashMap<SuspendContext, List<ToStringCommand>> myBuffer = new HashMap<>();
private BatchEvaluator(DebugProcess process) {
myDebugProcess = process;
private BatchEvaluator() {
}
public void invoke(ToStringCommand command) {
DebuggerManagerThreadImpl.assertIsManagerThread();
EvaluationContext evaluationContext = command.getEvaluationContext();
SuspendContextImpl suspendContext = (SuspendContextImpl)evaluationContext.getSuspendContext();
if (!Registry.is("debugger.batch.evaluation.force") && !Registry.is("debugger.batch.evaluation")) {
myDebugProcess.getManagerThread().invokeCommand(command);
suspendContext.getManagerThread().invokeCommand(command);
}
else {
EvaluationContext evaluationContext = command.getEvaluationContext();
SuspendContext suspendContext = evaluationContext.getSuspendContext();
List<ToStringCommand> toStringCommands = myBuffer.get(suspendContext);
if (toStringCommands == null) {
toStringCommands = new ArrayList<>();
myBuffer.put(suspendContext, toStringCommands);
((DebuggerManagerThreadImpl)myDebugProcess.getManagerThread()).schedule(new BatchEvaluatorCommand(evaluationContext));
suspendContext.getManagerThread().schedule(new BatchEvaluatorCommand(evaluationContext));
}
toStringCommands.add(command);
@@ -61,7 +57,7 @@ public final class BatchEvaluator {
BatchEvaluator batchEvaluator = debugProcess.getUserData(BATCH_EVALUATOR_KEY);
if (batchEvaluator == null) {
batchEvaluator = new BatchEvaluator(debugProcess);
batchEvaluator = new BatchEvaluator();
debugProcess.putUserData(BATCH_EVALUATOR_KEY, batchEvaluator);
}
return batchEvaluator;
@@ -55,7 +55,7 @@ final class ColorObjectRenderer extends CompoundRendererProvider {
else {
EvaluationContextImpl evalContext = ((EvaluationContextImpl)evaluationContext);
DebugProcessImpl debugProcess = evalContext.getDebugProcess();
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(evalContext.getSuspendContext()) {
evalContext.getManagerThread().schedule(new SuspendContextCommandImpl(evalContext.getSuspendContext()) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
try {
@@ -58,7 +58,7 @@ public final class ExpressionChildrenRenderer extends ReferenceRenderer implemen
@Override
public void buildChildren(Value value, ChildrenBuilder builder, EvaluationContext evaluationContext) {
EvaluationContextImpl evaluationContextImpl = (EvaluationContextImpl)evaluationContext;
evaluationContextImpl.getDebugProcess().getManagerThread().schedule(new PossiblySyncCommand(evaluationContextImpl.getSuspendContext()) {
evaluationContextImpl.getManagerThread().schedule(new PossiblySyncCommand(evaluationContextImpl.getSuspendContext()) {
@Override
public void syncAction(@NotNull SuspendContextImpl suspendContext) {
try {
@@ -153,8 +153,7 @@ public final class ExpressionChildrenRenderer extends ReferenceRenderer implemen
public CompletableFuture<Boolean> isExpandableAsync(Value value, EvaluationContext context, NodeDescriptor parentDescriptor) {
CompletableFuture<Boolean> res = new CompletableFuture<>();
EvaluationContextImpl evaluationContextImpl = (EvaluationContextImpl)context;
DebugProcessImpl debugProcess = evaluationContextImpl.getDebugProcess();
debugProcess.getManagerThread().schedule(new PossiblySyncCommand(evaluationContextImpl.getSuspendContext()) {
evaluationContextImpl.getManagerThread().schedule(new PossiblySyncCommand(evaluationContextImpl.getSuspendContext()) {
@Override
public void syncAction(@NotNull SuspendContextImpl suspendContext) {
EvaluationContext evaluationContext = context.createEvaluationContext(value);
@@ -38,7 +38,7 @@ final class IconObjectRenderer extends CompoundRendererProvider {
if (!Registry.is("debugger.auto.fetch.icons") || DebuggerUtilsImpl.isRemote(debugProcess)) return null;
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(evalContext.getSuspendContext()) {
((EvaluationContextImpl)evaluationContext).getManagerThread().schedule(new SuspendContextCommandImpl(evalContext.getSuspendContext()) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
String getterName = AllIcons.Debugger.Value.getIconHeight() <= 16 ? "iconToBytesPreviewNormal" : "iconToBytesPreviewRetina";
@@ -61,7 +61,7 @@ public class LabelRenderer extends ReferenceRenderer implements ValueLabelRender
EvaluationContextImpl evaluationContextImpl = (EvaluationContextImpl)evaluationContext;
DebugProcessImpl debugProcess = evaluationContextImpl.getDebugProcess();
debugProcess.getManagerThread().schedule(new PossiblySyncCommand(evaluationContextImpl.getSuspendContext()) {
evaluationContextImpl.getManagerThread().schedule(new PossiblySyncCommand(evaluationContextImpl.getSuspendContext()) {
@Override
public void syncAction(@NotNull SuspendContextImpl suspendContext) {
ExpressionEvaluator evaluator = null;
@@ -78,7 +78,7 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa
protected void resume(SuspendContextImpl context) {
DebugProcessImpl debugProcess = context.getDebugProcess();
debugProcess.getManagerThread().schedule(debugProcess.createResumeCommand(context, PrioritizedTask.Priority.LOWEST));
context.getManagerThread().schedule(debugProcess.createResumeCommand(context, PrioritizedTask.Priority.LOWEST));
}
protected void stepInto(SuspendContextImpl context) {
@@ -87,17 +87,17 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa
protected void stepInto(SuspendContextImpl context, boolean ignoreFilters) {
DebugProcessImpl debugProcess = context.getDebugProcess();
debugProcess.getManagerThread().schedule(debugProcess.createStepIntoCommand(context, ignoreFilters, null));
context.getManagerThread().schedule(debugProcess.createStepIntoCommand(context, ignoreFilters, null));
}
protected void stepOver(SuspendContextImpl context) {
DebugProcessImpl debugProcess = context.getDebugProcess();
debugProcess.getManagerThread().schedule(debugProcess.createStepOverCommand(context, false));
context.getManagerThread().schedule(debugProcess.createStepOverCommand(context, false));
}
protected void stepOut(SuspendContextImpl context) {
DebugProcessImpl debugProcess = context.getDebugProcess();
debugProcess.getManagerThread().schedule(debugProcess.createStepOutCommand(context));
context.getManagerThread().schedule(debugProcess.createStepOutCommand(context));
}
@Override
@@ -272,9 +272,9 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa
if (!myRatherLaterRequests.isEmpty()) pumpSwingThread();
}
if (request.myDebuggerCommand instanceof SuspendContextCommandImpl) {
request.myDebugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(
((SuspendContextCommandImpl)request.myDebuggerCommand).getSuspendContext()) {
if (request.myDebuggerCommand instanceof SuspendContextCommandImpl suspendContextCommand) {
SuspendContextImpl suspendContext = suspendContextCommand.getSuspendContext();
Objects.requireNonNull(suspendContext).getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
pumpDebuggerThread(request);
@@ -584,7 +584,7 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa
@Override
public void paused(SuspendContextImpl suspendContext) {
// Need to add SuspendContextCommandImpl because the stepping pause is not now in SuspendContextCommandImpl
DebuggerManagerThreadImpl debuggerManagerThread = Objects.requireNonNull(suspendContext.getDebugProcess()).getManagerThread();
DebuggerManagerThreadImpl debuggerManagerThread = suspendContext.getManagerThread();
debuggerManagerThread.invoke(new SuspendContextCommandImpl(suspendContext) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
@@ -624,7 +624,7 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa
public void resumed(SuspendContextImpl suspendContext) {
SuspendContextImpl pausedContext = myDebugProcess.getSuspendManager().getPausedContext();
if (pausedContext != null) {
myDebugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(pausedContext) {
suspendContext.getManagerThread().schedule(new SuspendContextCommandImpl(pausedContext) {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
paused(pausedContext);
@@ -74,7 +74,7 @@ public abstract class DescriptorTestCase extends DebuggerTestCase {
@Override
public void contextAction(@NotNull SuspendContextImpl suspendContext) {
flushDescriptors();
localProcess.getManagerThread().schedule(localProcess.createResumeCommand(suspendContext, Priority.LOW));
suspendContext.getManagerThread().schedule(localProcess.createResumeCommand(suspendContext, Priority.LOW));
}
});
}
@@ -177,7 +177,7 @@ public interface DebuggerMethods extends CompilerMethods {
DebuggerContextImpl ctx = DebuggerContextUtil.createDebuggerContext(getDebugSession(),
getDebugProcess().getSuspendManager().getPausedContext());
ManagedCommand<T> command = new ManagedCommand<>(ctx, cl);
getDebugProcess().getManagerThread().invoke(command);
ctx.getManagerThread().invoke(command);
boolean finished = command.getSemaphore().waitFor(ourTimeout);
assertTrue("Too long debugger action", finished);
return command.getResult();
@@ -121,6 +121,8 @@ fun <T : Any> DebugProcessImpl.invokeInManagerThread(f: (DebuggerContextImpl) ->
return f(debuggerContext)
}
var result: T? = null
@Suppress("UsagesOfObsoleteApi")
val managerThread = debuggerContext.managerThread ?: managerThread
managerThread.invokeAndWait(object : DebuggerContextCommandImpl(debuggerContext) {
override fun threadAction(suspendContext: SuspendContextImpl) {
result = f(debuggerContext)
@@ -35,8 +35,7 @@ class CoroutineDumpAction : AnAction() {
val context = DebuggerManagerEx.getInstanceEx(project).context
val session = context.debuggerSession
if (session != null && session.isAttached) {
val process = context.debugProcess ?: return
process.managerThread.schedule(object : SuspendContextCommandImpl(context.suspendContext) {
context.managerThread?.schedule(object : SuspendContextCommandImpl(context.suspendContext) {
override fun contextAction(suspendContext: SuspendContextImpl) {
val states = CoroutineDebugProbesProxy(suspendContext).dumpCoroutines()
if (states.isOk()) {
@@ -2,7 +2,6 @@
package org.jetbrains.kotlin.idea.debugger.coroutine.view
import com.intellij.debugger.engine.DebugProcessImpl
import com.intellij.debugger.engine.JavaDebugProcess
import com.intellij.debugger.engine.SuspendContextImpl
import com.intellij.debugger.engine.events.SuspendContextCommandImpl
@@ -154,7 +153,7 @@ class CoroutineView(project: Project, javaDebugProcess: JavaDebugProcess) :
inner class JobsContainer(val suspendContext: SuspendContextImpl) :
RendererContainer(renderer.renderNoIconNode(KotlinDebuggerCoroutinesBundle.message("coroutine.view.node.jobs"))) {
override fun computeChildren(node: XCompositeNode) {
debugProcess.invokeInSuspendContext(suspendContext) { suspendContext ->
invokeInSuspendContext(suspendContext) { suspendContext ->
val coroutineCache = CoroutineDebugProbesProxy(suspendContext).dumpCoroutines()
if (!coroutineCache.isOk()) {
node.addChildren(XValueChildrenList.singleton(ErrorNode("coroutine.view.fetching.error")), true)
@@ -219,7 +218,7 @@ class CoroutineView(project: Project, javaDebugProcess: JavaDebugProcess) :
override fun computeChildren(node: XCompositeNode) {
node.setAlreadySorted(true)
debugProcess.invokeInSuspendContext(suspendContext) { suspendContext ->
invokeInSuspendContext(suspendContext) { suspendContext ->
val children = XValueChildrenList()
jobs.forEach {
@@ -243,7 +242,7 @@ class CoroutineView(project: Project, javaDebugProcess: JavaDebugProcess) :
inner class DispatchersContainer(val suspendContext: SuspendContextImpl) :
RendererContainer(renderer.renderNoIconNode(KotlinDebuggerCoroutinesBundle.message("coroutine.view.node.dispatchers"))) {
override fun computeChildren(node: XCompositeNode) {
debugProcess.invokeInSuspendContext(suspendContext) { suspendContext ->
invokeInSuspendContext(suspendContext) { suspendContext ->
val coroutineCache = CoroutineDebugProbesProxy(suspendContext).dumpCoroutines()
if (!coroutineCache.isOk()) {
node.addChildren(XValueChildrenList.singleton(ErrorNode("coroutine.view.fetching.error")), true)
@@ -275,7 +274,7 @@ class CoroutineView(project: Project, javaDebugProcess: JavaDebugProcess) :
private val coroutines: List<CoroutineInfoData>?
) : RendererContainer(renderer.renderThreadGroup(groupName, isCurrent)) {
override fun computeChildren(node: XCompositeNode) {
debugProcess.invokeInSuspendContext(suspendContext) { suspendContext ->
invokeInSuspendContext(suspendContext) { suspendContext ->
val children = XValueChildrenList()
coroutines?.forEach {
val isCurrent = it.isRunningOnCurrentThread(suspendContext)
@@ -303,7 +302,7 @@ class CoroutineView(project: Project, javaDebugProcess: JavaDebugProcess) :
override fun computeChildren(node: XCompositeNode) {
node.setAlreadySorted(true)
debugProcess.invokeInSuspendContext(suspendContext) { suspendContext ->
invokeInSuspendContext(suspendContext) { suspendContext ->
val children = XValueChildrenList()
val doubleFrameList = CoroutineFrameBuilder.build(infoData, suspendContext)
doubleFrameList?.frames?.forEach {
@@ -369,11 +368,11 @@ class CoroutineView(project: Project, javaDebugProcess: JavaDebugProcess) :
CoroutineSelectedNodeListener(debugProcess, tree).install()
}
private fun DebugProcessImpl.invokeInSuspendContext(
private fun invokeInSuspendContext(
suspendContext: SuspendContextImpl,
command: (SuspendContextImpl) -> Unit
): Unit =
managerThread.invoke(object : SuspendContextCommandImpl(suspendContext) {
suspendContext.managerThread.invoke(object : SuspendContextCommandImpl(suspendContext) {
override fun getPriority() =
PrioritizedTask.Priority.NORMAL
@@ -66,7 +66,7 @@ class KotlinK1CodeFragmentFactory : JavaDebuggerCodeFragmentFactory() {
}
}
debuggerContext.debugProcess?.managerThread?.invoke(worker)
debuggerContext.managerThread?.invoke(worker)
for (i in 0..50) {
ProgressManager.checkCanceled()
@@ -168,7 +168,7 @@ class KotlinK1CodeFragmentFactory : JavaDebuggerCodeFragmentFactory() {
}
}
debuggerContext.debugProcess?.managerThread?.invoke(worker)
debuggerContext.managerThread?.invoke(worker)
for (i in 0..50) {
if (semaphore.waitFor(20)) break
@@ -57,7 +57,7 @@ class KotlinRuntimeTypeCastSurrounder : Surrounder {
val progressWindow = ProgressWindow(true, expression.project)
val worker = SurroundWithCastWorker(editor, expression, debuggerContext, progressWindow)
progressWindow.title = JavaDebuggerBundle.message("title.evaluating")
debuggerContext.debugProcess?.managerThread?.startProgress(worker, progressWindow)
debuggerContext.managerThread?.startProgress(worker, progressWindow)
}
return null
}
@@ -198,7 +198,7 @@ abstract class AbstractIrKotlinEvaluateExpressionTest : KotlinDescriptorTestCase
print(result, ProcessOutputTypes.SYSTEM)
}
assert(debugProcess.isAttached)
debugProcess.managerThread.schedule(object : SuspendContextCommandImpl(suspendContext) {
suspendContext.managerThread.schedule(object : SuspendContextCommandImpl(suspendContext) {
override fun contextAction(suspendContext: SuspendContextImpl) {
completion()
}
@@ -146,14 +146,14 @@ abstract class KotlinDescriptorTestCaseWithStepping : KotlinDescriptorTestCase()
runReadAction { commandProvider.getStepIntoCommand(this, ignoreFilters, smartStepFilter) }
?: dp.createStepIntoCommand(this, ignoreFilters, smartStepFilter)
dp.managerThread.schedule(stepIntoCommand)
managerThread.schedule(stepIntoCommand)
}
private fun SuspendContextImpl.doStepOut() {
val stepOutCommand = runReadAction { commandProvider.getStepOutCommand(this, debuggerContext) }
?: dp.createStepOutCommand(this)
dp.managerThread.schedule(stepOutCommand)
managerThread.schedule(stepOutCommand)
}
private fun SuspendContextImpl.doRunToCursor(lineIndex: Int, fileName: String) {
@@ -165,7 +165,7 @@ abstract class KotlinDescriptorTestCaseWithStepping : KotlinDescriptorTestCase()
commandProvider.getRunToCursorCommand(this, xSourcePosition, false) ?: dp.createRunToCursorCommand(this, xSourcePosition, false)
}
dp.managerThread.schedule(runToCursorCommand)
managerThread.schedule(runToCursorCommand)
}
override fun setUp() {
@@ -179,7 +179,7 @@ abstract class KotlinDescriptorTestCaseWithStepping : KotlinDescriptorTestCase()
commandProvider.getStepOverCommand(this, ignoreBreakpoints, sourcePosition)
} ?: dp.createStepOverCommand(this, ignoreBreakpoints)
dp.managerThread.schedule(stepOverCommand)
managerThread.schedule(stepOverCommand)
}
private fun process(instruction: SteppingInstruction) {
@@ -348,7 +348,7 @@ abstract class KotlinDescriptorTestCaseWithStepping : KotlinDescriptorTestCase()
}
// Try to execute the action inside a command if we aren't already inside it.
debuggerSession.process.managerThread.invoke(command)
managerThread.invoke(command)
}
}
@@ -128,7 +128,7 @@ class FramePrinter(private val suspendContext: SuspendContextImpl) {
semaphore.up()
}
suspendContext.debugProcess.managerThread.schedule(object : SuspendContextCommandImpl(suspendContext) {
suspendContext.managerThread.schedule(object : SuspendContextCommandImpl(suspendContext) {
override fun contextAction(suspendContext: SuspendContextImpl) {
val evaluationContext = EvaluationContextImpl(suspendContext, suspendContext.frameProxy)
valueDescriptor.setContext(evaluationContext)
@@ -87,7 +87,7 @@ public class CollectionTree extends XDebuggerTree implements TraceContainer {
final XValueContainer container = ((XValueContainerNode<?>)node).getValueContainer();
if (container instanceof JavaValue) {
final ValueDescriptorImpl descriptor = ((JavaValue)container).getDescriptor();
evaluationContext.getDebugProcess().getManagerThread().schedule(new DebuggerCommandImpl() {
evaluationContext.getManagerThread().schedule(new DebuggerCommandImpl() {
@Override
protected void action() {
final Value value = descriptor.getValue();