| 294 | } |
| 295 | |
| 296 | void DebugController::addSession(IDebugSession* session) |
| 297 | { |
| 298 | qCDebug(SHELL) << session; |
| 299 | Q_ASSERT(session->variableController()); |
| 300 | Q_ASSERT(session->breakpointController()); |
| 301 | Q_ASSERT(session->frameStackModel()); |
| 302 | |
| 303 | //TODO support multiple sessions |
| 304 | if (m_currentSession) { |
| 305 | // Disconnect from no longer relevant signals of the previous session. But keep the stateChanged |
| 306 | // and killAllDebuggersNow connections because they are always applicable to all sessions. |
| 307 | disconnect(m_currentSession, &IDebugSession::showStepInSource, this, &DebugController::showStepInSource); |
| 308 | disconnect(m_currentSession, &IDebugSession::clearExecutionPoint, this, &DebugController::clearExecutionPoint); |
| 309 | disconnect(m_currentSession, &IDebugSession::raiseFramestackViews, this, |
| 310 | &DebugController::raiseFramestackViews); |
| 311 | |
| 312 | // Remove the execution point, if any, of the previous session. |
| 313 | clearExecutionPoint(); |
| 314 | |
| 315 | // NOTE: stopping the debugger can synchronously transition m_currentSession into the |
| 316 | // ended state (e.g. if it is not started) and consequently set it to nullptr. |
| 317 | m_currentSession->stopDebugger(); |
| 318 | } |
| 319 | auto* const previousSession = m_currentSession; |
| 320 | m_currentSession = session; |
| 321 | |
| 322 | connect(session, &IDebugSession::stateChanged, this, &DebugController::debuggerStateChanged); |
| 323 | connect(session, &IDebugSession::showStepInSource, this, &DebugController::showStepInSource); |
| 324 | connect(session, &IDebugSession::clearExecutionPoint, this, &DebugController::clearExecutionPoint); |
| 325 | connect(session, &IDebugSession::raiseFramestackViews, this, &DebugController::raiseFramestackViews); |
| 326 | connect(this, &DebugController::killAllDebuggersNow, session, &IDebugSession::killDebuggerNow); |
| 327 | |
| 328 | updateDebuggerState(session->state(), session); |
| 329 | |
| 330 | Q_EMIT currentSessionChanged(session, previousSession); |
| 331 | |
| 332 | if((Core::self()->setupFlags() & Core::NoUi)) return; |
| 333 | |
| 334 | |
| 335 | Sublime::MainWindow* mainWindow = Core::self()->uiControllerInternal()->activeSublimeWindow(); |
| 336 | auto oldArea = mainWindow->area(); |
| 337 | if (oldArea->objectName() != QLatin1String("debug")) { |
| 338 | ICore::self()->uiController()->switchToArea(QStringLiteral("debug"), IUiController::ThisWindow); |
| 339 | mainWindow->area()->setWorkingSet(oldArea->workingSet(), oldArea->workingSetPersistent(), oldArea); |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | void DebugController::clearExecutionPoint() |
| 344 | { |