void () { DebuggerManagerThreadImpl.assertIsManagerThread(); LOG.assertTrue(!isAttached()); if (myState.compareAndSet(State.INITIAL, State.ATTACHED)) { final VirtualMachineProxyImpl machineProxy = getVirtualMachineProxy(); boolean canBeModified = machineProxy.canBeModified(); if (canBeModified) { final EventRequestManager requestManager = machineProxy.eventRequestManager(); if (machineProxy.canGetMethodReturnValues()) { myReturnValueWatcher = new MethodReturnValueWatcher(requestManager, this); } enableNonSuspendingRequest(platformThreadsOnly(requestManager.createThreadStartRequest()), event -> { ThreadReference thread = ((ThreadStartEvent)event).thread(); machineProxy.threadStarted(thread); myDebugProcessDispatcher.getMulticaster().threadStarted(this, thread); }); enableNonSuspendingRequest(platformThreadsOnly(requestManager.createThreadDeathRequest()), event -> { ThreadReference thread = ((ThreadDeathEvent)event).thread(); machineProxy.threadStopped(thread); myDebugProcessDispatcher.getMulticaster().threadStopped(this, thread); }); } // Workaround for IDEA-280752 for 212 (a call to getExtensionList will sort and cache the extensions) PositionManagerFactory.EP_NAME.getExtensionList(); // fill position managers and watch for dynamic changes PositionManagerFactory.EP_NAME.getPoint().addExtensionPointListener(new ExtensionPointListener<>() { final Map<PositionManagerFactory, PositionManager> mapping = new HashMap<>(); @Override public void extensionAdded(@NotNull PositionManagerFactory extension, @NotNull PluginDescriptor pluginDescriptor) { getManagerThread().invoke(PrioritizedTask.Priority.NORMAL, () -> { PositionManager manager = extension.createPositionManager(DebugProcessEvents.this); if (manager != null) { mapping.put(extension, manager); appendPositionManager(manager); } }); } @Override public void extensionRemoved(@NotNull PositionManagerFactory extension, @NotNull PluginDescriptor pluginDescriptor) { getManagerThread().invoke(PrioritizedTask.Priority.NORMAL, () -> { PositionManager manager = mapping.remove(extension); if (manager != null) { myPositionManager.removePositionManager(manager); } }); } }, true, myDisposable); myDebugProcessDispatcher.getMulticaster().processAttached(this); if (canBeModified) { createStackCapturingBreakpoints(); AsyncStacksUtils.setupAgent(this); CollectionBreakpointUtils.setupCollectionBreakpointAgent(this); } XDebugSessionImpl session = (XDebugSessionImpl)getSession().getXDebugSession(); // breakpoints should be initialized after all processAttached listeners work ApplicationManager.getApplication().runReadAction(() -> { if (session != null) { // reload to make sure that source positions are initialized DebuggerManagerEx.getInstanceEx(getProject()).getBreakpointManager().reloadBreakpoints(); session.initBreakpoints(); } }); if (Registry.is("debugger.track.instrumentation", true) && canBeModified) { trackClassRedefinitions(); } showStatusText(JavaDebuggerBundle.message("status.connected", DebuggerUtilsImpl.getConnectionDisplayName(getConnection()))); LOG.debug("leave: processVMStartEvent()"); if (session != null) { session.setReadOnly(!canBeModified); session.setPauseActionSupported(canBeModified); } if (!canBeModified) { myDebugProcessDispatcher.getMulticaster().paused(getSuspendManager().pushSuspendContext(EventRequest.SUSPEND_ALL, 0)); UIUtil.invokeLaterIfNeeded(() -> XDebugSessionTab.showFramesView(session)); } } }