Creation and Stopping of Debug Sessions in IntelliJ
The article explains how IntelliJ creates a debug session via XDebuggerManager.startSessionAndShowTab, the role of XDebugSession and XDebugProcess, and details the sequence of events and listeners involved when the session is stopped, including process termination and listener cleanup.
Debug session creation is initiated by XDebuggerManager.startSessionAndShowTab , which returns an XDebugSession instance (implemented by XDebugSessionImpl ) and creates a session in the Debug window.
After the session is created, an XDebugProcess is created and the XDebuggerManagerListener receives a processStarted event.
The showToolWindowOnSuspendOnly property determines when the debug UI is shown: true shows it only on breakpoint hit, false shows it by default.
Subsequently, the processHandler#startNotified event is broadcast, and an XDebugProcess is created via XDebugProcessStarter , binding one XDebugProcess to each XDebugSession .
During initialization, XDebugSession registers a listener on the processHandler ; when the handler triggers a processTerminated event, a callback is broadcast.
Debug Stopping
The debug session is managed by XDebugSession , which is linked to an XDebugProcess that in turn holds a processHandler . When the processHandler is destroyed, the XDebugSession is also destroyed.
Debug sessions do not close automatically; users can close them via the UI.
Stopping the debug session works as follows:
Obtain all current RunContentDescriptor objects and iterate to build HandlerItem nodes.
Each HandlerItem has a stop method; invoking it triggers ExecutionManagerImpl.stopProcess(descriptor) to destroy the process.
The final destruction targets a processHandler , which is an instance of DefaultDebugProcessHandler .
Java Captain
Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.