MCPcopy Create free account
hub / github.com/KDE/kdevelop / stopDebugger

Method stopDebugger

plugins/debuggercommon/midebugsession.cpp:582–629  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

580}
581
582void MIDebugSession::stopDebugger()
583{
584 if (debuggerStateIsOn(s_dbgNotStarted)) {
585 qCDebug(DEBUGGERCOMMON) << "Stopping debugger when it's not started";
586 if (debuggerState() != notStartedDebuggerFlags) {
587 setDebuggerState(notStartedDebuggerFlags);
588 }
589 // Transition into EndedState to let DebugController destroy this session.
590 if (state() != EndedState) {
591 setSessionState(EndedState);
592 }
593 return;
594 }
595
596 m_commandQueue->clear();
597
598 qCDebug(DEBUGGERCOMMON) << "try stopping debugger";
599 if (debuggerStateIsOn(s_shuttingDown) || !m_debugger)
600 return;
601
602 setDebuggerStateOn(s_shuttingDown);
603 qCDebug(DEBUGGERCOMMON) << "stopping debugger";
604
605 // Get debugger's attention if it's busy. We need debugger to be at the
606 // command line so we can stop it.
607 if (!m_debugger->isReady()) {
608 qCDebug(DEBUGGERCOMMON) << "debugger busy on shutdown - interrupting";
609 interruptDebugger();
610 }
611
612 // If the app is attached then we release it here. This doesn't stop
613 // the app running.
614 if (debuggerStateIsOn(s_attached)) {
615 addCommand(TargetDetach);
616 emit debuggerUserCommandOutput(QStringLiteral("(gdb) detach\n"));
617 }
618
619 // Now try to stop debugger running.
620 addGdbExitCommand();
621
622 // We cannot wait forever, kill gdb after 5 seconds if it's not yet quit
623 QTimer::singleShot(5000, this, [this]() {
624 if (!debuggerStateIsOn(s_programExited) && debuggerStateIsOn(s_shuttingDown)) {
625 qCDebug(DEBUGGERCOMMON) << "debugger not shutdown - killing";
626 killDebuggerImpl();
627 }
628 });
629}
630
631void MIDebugSession::addGdbExitCommand()
632{

Callers

nothing calls this directly

Calls 2

clearMethod · 0.45
isReadyMethod · 0.45

Tested by

no test coverage detected