diff --git a/src/io/flutter/vmService/DartVmServiceDebugProcess.java b/src/io/flutter/vmService/DartVmServiceDebugProcess.java index eed64ad61..f89b279fa 100644 --- a/src/io/flutter/vmService/DartVmServiceDebugProcess.java +++ b/src/io/flutter/vmService/DartVmServiceDebugProcess.java @@ -514,7 +514,7 @@ public void received(Isolate isolate) { else if (eventKind == EventKind.Resume) { // Currently true if we got here via 'flutter attach' OpenApiUtils.safeInvokeLater(() -> { - myVmServiceWrapper.attachIsolate(isolateRef, isolate); + myVmServiceWrapper.attachIsolate(isolateRef); }); } } diff --git a/src/io/flutter/vmService/VmServiceWrapper.java b/src/io/flutter/vmService/VmServiceWrapper.java index 7f4999391..a55bcb194 100644 --- a/src/io/flutter/vmService/VmServiceWrapper.java +++ b/src/io/flutter/vmService/VmServiceWrapper.java @@ -24,7 +24,6 @@ import com.intellij.xdebugger.impl.XDebugSessionImpl; import com.jetbrains.lang.dart.DartFileType; import io.flutter.bazel.WorkspaceCache; -import io.flutter.run.daemon.FlutterApp; import io.flutter.sdk.FlutterSdk; import io.flutter.sdk.FlutterSdkVersion; import io.flutter.utils.OpenApiUtils; @@ -33,13 +32,56 @@ import io.flutter.vmService.frame.DartVmServiceStackFrame; import io.flutter.vmService.frame.DartVmServiceValue; import org.dartlang.vm.service.VmService; -import org.dartlang.vm.service.consumer.*; -import org.dartlang.vm.service.element.*; +import org.dartlang.vm.service.consumer.AddBreakpointWithScriptUriConsumer; +import org.dartlang.vm.service.consumer.EvaluateConsumer; +import org.dartlang.vm.service.consumer.EvaluateInFrameConsumer; +import org.dartlang.vm.service.consumer.GetIsolateConsumer; +import org.dartlang.vm.service.consumer.GetObjectConsumer; +import org.dartlang.vm.service.consumer.GetStackConsumer; +import org.dartlang.vm.service.consumer.InvokeConsumer; +import org.dartlang.vm.service.consumer.PauseConsumer; +import org.dartlang.vm.service.consumer.RemoveBreakpointConsumer; +import org.dartlang.vm.service.consumer.SetExceptionPauseModeConsumer; +import org.dartlang.vm.service.consumer.SetIsolatePauseModeConsumer; +import org.dartlang.vm.service.consumer.SuccessConsumer; +import org.dartlang.vm.service.consumer.UriListConsumer; +import org.dartlang.vm.service.consumer.VMConsumer; +import org.dartlang.vm.service.consumer.VersionConsumer; +import org.dartlang.vm.service.element.Breakpoint; +import org.dartlang.vm.service.element.ElementList; +import org.dartlang.vm.service.element.ErrorRef; +import org.dartlang.vm.service.element.Event; +import org.dartlang.vm.service.element.EventKind; +import org.dartlang.vm.service.element.ExceptionPauseMode; +import org.dartlang.vm.service.element.Frame; +import org.dartlang.vm.service.element.FrameKind; +import org.dartlang.vm.service.element.InstanceRef; +import org.dartlang.vm.service.element.Isolate; +import org.dartlang.vm.service.element.IsolateRef; +import org.dartlang.vm.service.element.LibraryRef; +import org.dartlang.vm.service.element.Obj; +import org.dartlang.vm.service.element.RPCError; +import org.dartlang.vm.service.element.Script; +import org.dartlang.vm.service.element.ScriptRef; +import org.dartlang.vm.service.element.Sentinel; import org.dartlang.vm.service.element.Stack; +import org.dartlang.vm.service.element.StepOption; +import org.dartlang.vm.service.element.Success; +import org.dartlang.vm.service.element.UnresolvedSourceLocation; +import org.dartlang.vm.service.element.UriList; +import org.dartlang.vm.service.element.VM; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; @@ -93,15 +135,6 @@ private void addRequest(@NotNull Runnable runnable) { } } - @NotNull - public List getExistingIsolates() { - List isolateRefs = new ArrayList<>(); - for (IsolatesInfo.IsolateInfo isolateInfo : myIsolatesInfo.getIsolateInfos()) { - isolateRefs.add(isolateInfo.getIsolateRef()); - } - return isolateRefs; - } - @Nullable public StepOption getLatestStep() { return myLatestStep; @@ -145,7 +178,7 @@ public void received(final Isolate isolate) { // This is the entry point for attaching a debugger to a running app. if (eventKind == EventKind.Resume) { - attachIsolate(isolateRef, isolate); + attachIsolate(isolateRef); return; } // if event is not PauseStart it means that PauseStart event will follow later and will be handled by listener @@ -290,13 +323,16 @@ public void received(Success response) { } } - public void attachIsolate(@NotNull IsolateRef isolateRef, @NotNull Isolate isolate) { + public void attachIsolate(@NotNull IsolateRef isolateRef) { boolean newIsolate = myIsolatesInfo.addIsolate(isolateRef); // Just to make sure that the main isolate is not handled twice, both from handleDebuggerConnected() and DartVmServiceListener.received(PauseStart) if (newIsolate) { - XDebugSessionImpl session = (XDebugSessionImpl)myDebugProcess.getSession(); + var session = myDebugProcess.getSession(); OpenApiUtils.safeRunReadAction(() -> { - session.reset(); + // Only the impl class supports reset so we need to cast. + // Note that `XDebugSessionImpl` is marked internal, so this may not be safe long-run. + // See: https://github.com/flutter/flutter-intellij/issues/7718 + ((XDebugSessionImpl)session).reset(); session.initBreakpoints(); }); setIsolatePauseMode(isolateRef.getId(), myDebugProcess.getBreakOnExceptionMode(), isolateRef); @@ -328,20 +364,6 @@ public void received(final Isolate isolate) { } } - private void setInitialBreakpointsAndCheckExtensions(@NotNull IsolateRef isolateRef, @NotNull Isolate isolate) { - doSetBreakpointsForIsolate(myBreakpointHandler.getXBreakpoints(), isolateRef.getId(), () -> { - myIsolatesInfo.setBreakpointsSet(isolateRef); - }); - FlutterApp app = FlutterApp.fromEnv(myDebugProcess.getExecutionEnvironment()); - // TODO(messick) Consider replacing this test with an assert; could interfere with setExceptionPauseMode(). - if (app != null) { - VMServiceManager service = app.getVMServiceManager(); - if (service != null) { - service.addRegisteredExtensionRPCs(isolate); - } - } - } - private void doSetInitialBreakpointsAndResume(@NotNull IsolateRef isolateRef) { doSetBreakpointsForIsolate(myBreakpointHandler.getXBreakpoints(), isolateRef.getId(), () -> { myIsolatesInfo.setBreakpointsSet(isolateRef); @@ -471,8 +493,7 @@ private boolean isVmServiceMappingSupported(org.dartlang.vm.service.element.Vers if (WorkspaceCache.getInstance(myDebugProcess.getSession().getProject()).isBazel()) { return true; } - - FlutterSdk sdk = FlutterSdk.getFlutterSdk(myDebugProcess.getSession().getProject()); + return VmServiceVersion.hasMapping(version); }