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

Method executeCmd

plugins/debuggercommon/midebugsession.cpp:873–947  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

871}
872
873void MIDebugSession::executeCmd()
874{
875 Q_ASSERT(m_debugger);
876
877 if (debuggerStateIsOn(s_dbgNotListening) && m_commandQueue->haveImmediateCommand()) {
878 // We may have to call this even while a command is currently executing, because
879 // debugger can get into a state where a command such as ExecRun does not send a response
880 // while the inferior is running.
881 ensureDebuggerListening();
882 }
883
884 if (!m_debugger->isReady())
885 return;
886
887 auto currentCmd = m_commandQueue->nextCommand();
888 if (!currentCmd)
889 return;
890
891 if (currentCmd->flags() & (CmdMaybeStartsRunning | CmdInterrupt)) {
892 setDebuggerStateOff(s_automaticContinue);
893 }
894
895 if (currentCmd->flags() & CmdMaybeStartsRunning) {
896 // GDB can be in a state where it is listening for commands while the program is running.
897 // However, when we send a command such as ExecContinue in this state, GDB may return to
898 // the non-listening state without acknowledging that the ExecContinue command has even
899 // finished, let alone sending a new notification about the program's running state.
900 // So let's be extra cautious about ensuring that we will wake GDB up again if required.
901 setDebuggerStateOn(s_dbgNotListening);
902 }
903
904 if (currentCmd->needsContext()) {
905 if (currentCmd->thread() == -1)
906 currentCmd->setThread(frameStackModel()->currentThread());
907
908 if (currentCmd->frame() == -1)
909 currentCmd->setFrame(frameStackModel()->currentFrame());
910 }
911
912 QString commandText = currentCmd->cmdToSend();
913 bool bad_command = false;
914 QString message;
915
916 int length = commandText.length();
917 // No i18n for message since it's mainly for debugging.
918 if (length == 0) {
919 // The command might decide it's no longer necessary to send
920 // it.
921 if (auto* sc = dynamic_cast<SentinelCommand*>(currentCmd.get())) {
922 qCDebug(DEBUGGERCOMMON) << "SEND: sentinel command, not sending";
923 sc->invokeHandler();
924 } else {
925 qCDebug(DEBUGGERCOMMON) << "SEND: command " << currentCmd->initialString()
926 << "changed its mind, not sending";
927 }
928
929 executeCmd();
930 return;

Callers

nothing calls this directly

Calls 15

haveImmediateCommandMethod · 0.80
nextCommandMethod · 0.80
needsContextMethod · 0.80
threadMethod · 0.80
setThreadMethod · 0.80
currentThreadMethod · 0.80
setFrameMethod · 0.80
currentFrameMethod · 0.80
initialStringMethod · 0.80
uiControllerMethod · 0.80
isReadyMethod · 0.45
flagsMethod · 0.45

Tested by

no test coverage detected