void GdbAttachEngine::handleAttach(const GdbResponse &response) { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); switch (response.resultClass) { case GdbResultDone: case GdbResultRunning: showMessage(_("INFERIOR ATTACHED")); showMessage(msgAttachedToStoppedInferior(), StatusBar); handleInferiorPrepared(); break; case GdbResultError: if (response.data.findChild("msg").data() == "ptrace: Operation not permitted.") { notifyInferiorSetupFailed(DumperHelper::msgPtraceError(startParameters().startMode)); break; } // if msg != "ptrace: ..." fall through default: QString msg = QString::fromLocal8Bit(response.data.findChild("msg").data()); notifyInferiorSetupFailed(msg); } }
void GdbPlainEngine::handleFileExecAndSymbols(const DebuggerResponse &response) { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); if (response.resultClass == ResultDone) { handleInferiorPrepared(); } else { QString msg = response.data["msg"].data(); // Extend the message a bit in unknown cases. if (!msg.endsWith("File format not recognized")) msg = tr("Starting executable failed:") + '\n' + msg; notifyInferiorSetupFailed(msg); } }
void PdbEngine::setupInferior() { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); QString fileName = QFileInfo(startParameters().executable).absoluteFilePath(); QFile scriptFile(fileName); if (!scriptFile.open(QIODevice::ReadOnly|QIODevice::Text)) { showMessageBox(QMessageBox::Critical, tr("Python Error"), _("Cannot open script file %1:\n%2"). arg(fileName, scriptFile.errorString())); notifyInferiorSetupFailed(); return; } notifyInferiorSetupOk(); }
void GdbRemoteServerEngine::handleTargetRemote(const GdbResponse &record) { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); if (record.resultClass == GdbResultDone) { // gdb server will stop the remote application itself. showMessage(_("INFERIOR STARTED")); showMessage(msgAttachedToStoppedInferior(), StatusBar); handleInferiorPrepared(); } else { // 16^error,msg="hd:5555: Connection timed out." QString msg = msgConnectRemoteServerFailed( QString::fromLocal8Bit(record.data.findChild("msg").data())); notifyInferiorSetupFailed(msg); } }
void GdbTermEngine::handleStubAttached(const GdbResponse &response) { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); #ifdef Q_OS_WIN QString errorMessage; #endif // Q_OS_WIN switch (response.resultClass) { case GdbResultDone: case GdbResultRunning: #ifdef Q_OS_WIN // Resume thread that was suspended by console stub process (see stub code). if (winResumeThread(m_stubProc.applicationMainThreadID(), &errorMessage)) { showMessage(QString::fromLatin1("Inferior attached, thread %1 resumed"). arg(m_stubProc.applicationMainThreadID()), LogMisc); } else { showMessage(QString::fromLatin1("Inferior attached, unable to resume thread %1: %2"). arg(m_stubProc.applicationMainThreadID()).arg(errorMessage), LogWarning); } #else showMessage(_("INFERIOR ATTACHED")); #endif // Q_OS_WIN handleInferiorPrepared(); break; case GdbResultError: if (response.data.findChild("msg").data() == "ptrace: Operation not permitted.") { notifyInferiorSetupFailed(DumperHelper::msgPtraceError(startParameters().startMode)); break; } notifyInferiorSetupFailed(QString::fromLocal8Bit(response.data.findChild("msg").data())); break; default: notifyInferiorSetupFailed(QString::fromLatin1("Invalid response %1").arg(response.resultClass)); break; } }
void GdbCoreEngine::handleFileExecAndSymbols(const DebuggerResponse &response) { CHECK_STATE(InferiorSetupRequested); QString core = coreFileName(); if (response.resultClass == ResultDone) { showMessage(tr("Symbols found."), StatusBar); handleInferiorPrepared(); } else { QString msg = tr("No symbols found in core file <i>%1</i>.").arg(core) + _(" ") + tr("This can be caused by a path length limitation " "in the core file.") + _(" ") + tr("Try to specify the binary using the " "<i>Debug->Start Debugging->Attach to Core</i> dialog."); notifyInferiorSetupFailed(msg); } }
void GdbRemoteServerEngine::handleFileExecAndSymbols(const GdbResponse &response) { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); if (response.resultClass == GdbResultDone) { callTargetRemote(); } else { QByteArray reason = response.data["msg"].data(); QString msg = tr("Reading debug information failed:\n"); msg += QString::fromLocal8Bit(reason); if (reason.endsWith("No such file or directory.")) { showMessage(_("INFERIOR STARTUP: BINARY NOT FOUND")); showMessage(msg, StatusBar); callTargetRemote(); // Proceed nevertheless. } else { notifyInferiorSetupFailed(msg); } } }
void ScriptEngine::setupInferior() { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); m_scriptFileName = QFileInfo(startParameters().executable).absoluteFilePath(); showMessage(_("SCRIPT FILE: ") + m_scriptFileName); QFile scriptFile(m_scriptFileName); if (!scriptFile.open(QIODevice::ReadOnly|QIODevice::Text)) { showMessageBox(QMessageBox::Critical, tr("Error:"), _("Cannot open script file %1:\n%2"). arg(m_scriptFileName, scriptFile.errorString())); notifyInferiorSetupFailed(); return; } QTextStream stream(&scriptFile); m_scriptContents = stream.readAll(); scriptFile.close(); attemptBreakpointSynchronization(); notifyInferiorSetupOk(); }
void GdbCoreEngine::handleTargetCore(const GdbResponse &response) { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); if (response.resultClass == GdbResultDone) { showMessage(tr("Attached to core."), StatusBar); handleInferiorPrepared(); // Due to the auto-solib-add off setting, we don't have any // symbols yet. Load them in order of importance. reloadStack(true); reloadModulesInternal(); postCommand("p 5", CB(handleRoundTrip)); return; } QString msg = tr("Attach to core \"%1\" failed:") .arg(startParameters().coreFile) + QLatin1Char('\n') + QString::fromLocal8Bit(response.data["msg"].data()); notifyInferiorSetupFailed(msg); }
void GdbCoreEngine::handleFileExecAndSymbols(const GdbResponse &response) { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); QString core = coreFileName(); if (response.resultClass == GdbResultDone) { showMessage(tr("Symbols found."), StatusBar); postCommand("target core " + core.toLocal8Bit(), CB(handleTargetCore)); return; } QString msg = tr("No symbols found in core file <i>%1</i>.") .arg(core); msg += _(" "); msg += tr("This can be caused by a path length limitation in the " "core file."); msg += _(" "); msg += tr("Try to specify the binary using the " "<i>Debug->Start Debugging->Attach to Core</i> dialog."); notifyInferiorSetupFailed(msg); }
void GdbRemoteServerEngine::handleTargetQnx(const GdbResponse &response) { QTC_ASSERT(m_isQnxGdb, qDebug() << m_isQnxGdb); QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); if (response.resultClass == GdbResultDone) { // gdb server will stop the remote application itself. showMessage(_("INFERIOR STARTED")); showMessage(msgAttachedToStoppedInferior(), StatusBar); const qint64 pid = isMasterEngine() ? startParameters().attachPID : masterEngine()->startParameters().attachPID; if (pid > -1) { postCommand("attach " + QByteArray::number(pid), CB(handleAttach)); } else { handleInferiorPrepared(); } } else { // 16^error,msg="hd:5555: Connection timed out." QString msg = msgConnectRemoteServerFailed( QString::fromLocal8Bit(response.data.findChild("msg").data())); notifyInferiorSetupFailed(msg); } }
void IPCEngineHost::rpcCallback(quint64 f, QByteArray payload) { switch (f) { default: { showMessage(QLatin1String("IPC Error: unhandled id in guest to host call")); const QString logMessage = tr("Fatal engine shutdown. Incompatible binary or IPC error."); showMessage(logMessage, LogError); showStatusMessage(logMessage); } nuke(); break; case IPCEngineGuest::NotifyEngineSetupOk: notifyEngineSetupOk(); break; case IPCEngineGuest::NotifyEngineSetupFailed: notifyEngineSetupFailed(); break; case IPCEngineGuest::NotifyEngineRunFailed: notifyEngineRunFailed(); break; case IPCEngineGuest::NotifyInferiorSetupOk: attemptBreakpointSynchronization(); notifyInferiorSetupOk(); break; case IPCEngineGuest::NotifyInferiorSetupFailed: notifyInferiorSetupFailed(); break; case IPCEngineGuest::NotifyEngineRunAndInferiorRunOk: notifyEngineRunAndInferiorRunOk(); break; case IPCEngineGuest::NotifyEngineRunAndInferiorStopOk: notifyEngineRunAndInferiorStopOk(); break; case IPCEngineGuest::NotifyInferiorRunRequested: notifyInferiorRunRequested(); break; case IPCEngineGuest::NotifyInferiorRunOk: notifyInferiorRunOk(); break; case IPCEngineGuest::NotifyInferiorRunFailed: notifyInferiorRunFailed(); break; case IPCEngineGuest::NotifyInferiorStopOk: notifyInferiorStopOk(); break; case IPCEngineGuest::NotifyInferiorSpontaneousStop: notifyInferiorSpontaneousStop(); break; case IPCEngineGuest::NotifyInferiorStopFailed: notifyInferiorStopFailed(); break; case IPCEngineGuest::NotifyInferiorExited: notifyInferiorExited(); break; case IPCEngineGuest::NotifyInferiorShutdownOk: notifyInferiorShutdownOk(); break; case IPCEngineGuest::NotifyInferiorShutdownFailed: notifyInferiorShutdownFailed(); break; case IPCEngineGuest::NotifyEngineSpontaneousShutdown: notifyEngineSpontaneousShutdown(); break; case IPCEngineGuest::NotifyEngineShutdownOk: notifyEngineShutdownOk(); break; case IPCEngineGuest::NotifyEngineShutdownFailed: notifyEngineShutdownFailed(); break; case IPCEngineGuest::NotifyInferiorIll: notifyInferiorIll(); break; case IPCEngineGuest::NotifyEngineIll: notifyEngineIll(); break; case IPCEngineGuest::NotifyInferiorPid: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); quint64 pid; s >> pid; notifyInferiorPid(pid); } break; case IPCEngineGuest::ShowStatusMessage: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); QString msg; qint64 timeout; s >> msg; s >> timeout; showStatusMessage(msg, timeout); } break; case IPCEngineGuest::ShowMessage: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); QString msg; qint16 channel; qint64 timeout; s >> msg; s >> channel; s >> timeout; showMessage(msg, channel, timeout); } break; case IPCEngineGuest::CurrentFrameChanged: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); quint64 token; s >> token; resetLocation(); StackHandler *sh = stackHandler(); sh->setCurrentIndex(token); if (!sh->currentFrame().isUsable() || QFileInfo(sh->currentFrame().file).exists()) gotoLocation(Location(sh->currentFrame(), true)); else if (!m_sourceAgents.contains(sh->currentFrame().file)) fetchFrameSource(token); foreach(SourceAgent *agent, m_sourceAgents.values()) agent->updateLocationMarker(); } break; case IPCEngineGuest::CurrentThreadChanged: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); quint64 token; s >> token; threadsHandler()->setCurrentThreadId(token); } break; case IPCEngineGuest::ListFrames: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); StackFrames frames; s >> frames; stackHandler()->setFrames(frames); } break; case IPCEngineGuest::ListThreads: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); Threads threads; s >> threads; threadsHandler()->setThreads(threads); } break; case IPCEngineGuest::Disassembled: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); quint64 pc; DisassemblerLines lines; s >> pc; s >> lines; DisassemblerAgent *view = m_frameToDisassemblerAgent.take(pc); if (view) view->setContents(lines); } break; case IPCEngineGuest::UpdateWatchData: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); bool fullCycle; qint64 count; QList<WatchData> wd; s >> fullCycle; s >> count; for (qint64 i = 0; i < count; ++i) { WatchData d; s >> d; wd.append(d); } WatchHandler *wh = watchHandler(); if (!wh) break; wh->beginCycle(fullCycle); wh->insertBulkData(wd); wh->endCycle(fullCycle); } break; case IPCEngineGuest::NotifyAddBreakpointOk: { attemptBreakpointSynchronization(); QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); BreakpointId id; s >> id; breakHandler()->notifyBreakpointInsertOk(id); } break; case IPCEngineGuest::NotifyAddBreakpointFailed: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); BreakpointId id; s >> id; breakHandler()->notifyBreakpointInsertFailed(id); } break; case IPCEngineGuest::NotifyRemoveBreakpointOk: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); BreakpointId id; s >> id; breakHandler()->notifyBreakpointRemoveOk(id); } break; case IPCEngineGuest::NotifyRemoveBreakpointFailed: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); BreakpointId id; s >> id; breakHandler()->notifyBreakpointRemoveFailed(id); } break; case IPCEngineGuest::NotifyChangeBreakpointOk: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); BreakpointId id; s >> id; breakHandler()->notifyBreakpointChangeOk(id); } break; case IPCEngineGuest::NotifyChangeBreakpointFailed: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); BreakpointId id; s >> id; breakHandler()->notifyBreakpointChangeFailed(id); } break; case IPCEngineGuest::NotifyBreakpointAdjusted: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); BreakpointId id; BreakpointParameters d; s >> id >> d; breakHandler()->notifyBreakpointAdjusted(id, d); } break; case IPCEngineGuest::FrameSourceFetched: { QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); qint64 token; QString path; QString source; s >> token >> path >> source; SourceAgent *agent = new SourceAgent(this); agent->setSourceProducerName(startParameters().connParams.host); agent->setContent(path, source); m_sourceAgents.insert(path, agent); agent->updateLocationMarker(); } break; } }
void QmlCppEngine::slaveEngineStateChanged (DebuggerEngine *slaveEngine, const DebuggerState newState) { DebuggerEngine *otherEngine = (slaveEngine == m_cppEngine) ? m_qmlEngine : m_cppEngine; QTC_CHECK(otherEngine != slaveEngine); if (debug) { EDEBUG("GOT SLAVE STATE: " << slaveEngine << newState); EDEBUG(" OTHER ENGINE: " << otherEngine << otherEngine->state()); EDEBUG(" COMBINED ENGINE: " << this << state() << isDying()); } // Idea is to follow the state of the cpp engine, except where we are stepping in QML. // That is, when the QmlEngine moves between InferiorStopOk, and InferiorRunOk, InferiorStopOk ... // // Accordingly, the 'active engine' is the cpp engine until the qml engine enters the // InferiorStopOk state. The cpp engine becomes the active one again as soon as it itself enters // the InferiorStopOk state. if (slaveEngine == m_cppEngine) { switch (newState) { case DebuggerNotReady: { // Can this ever happen? break; } case EngineSetupRequested: { // set by queueSetupEngine() QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); break; } case EngineSetupFailed: { qmlEngine()->quitDebugger(); notifyEngineSetupFailed(); break; } case EngineSetupOk: { notifyEngineSetupOk(); break; } case InferiorSetupRequested: { // set by queueSetupInferior() QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); break; } case InferiorSetupFailed: { qmlEngine()->quitDebugger(); notifyInferiorSetupFailed(); break; } case InferiorSetupOk: { notifyInferiorSetupOk(); break; } case EngineRunRequested: { // set by queueRunEngine() break; } case EngineRunFailed: { qmlEngine()->quitDebugger(); notifyEngineRunFailed(); break; } case InferiorUnrunnable: { qmlEngine()->quitDebugger(); notifyInferiorUnrunnable(); break; } case InferiorRunRequested: { // might be set already by notifyInferiorRunRequested() QTC_ASSERT(state() == InferiorRunRequested || state() == InferiorStopOk, qDebug() << state()); if (state() != InferiorRunRequested) notifyInferiorRunRequested(); break; } case InferiorRunOk: { QTC_ASSERT(state() == EngineRunRequested || state() == InferiorRunRequested, qDebug() << state()); if (state() == EngineRunRequested) notifyEngineRunAndInferiorRunOk(); else if (state() == InferiorRunRequested) notifyInferiorRunOk(); if (qmlEngine()->state() == InferiorStopOk) { // track qml engine again setState(InferiorStopRequested); notifyInferiorStopOk(); setActiveEngine(m_qmlEngine); } break; } case InferiorRunFailed: { qmlEngine()->quitDebugger(); notifyInferiorRunFailed(); break; } case InferiorStopRequested: { if (m_activeEngine == cppEngine()) { // might be set by doInterruptInferior() QTC_ASSERT(state() == InferiorStopRequested || state() == InferiorRunOk, qDebug() << state()); if (state() == InferiorRunOk) setState(InferiorStopRequested); } else { // we're debugging qml, but got an interrupt, or abort QTC_ASSERT(state() == InferiorRunOk || state() == InferiorStopOk || state() == InferiorRunRequested, qDebug() << state()); if (state() == InferiorRunOk) { setState(InferiorStopRequested); } else if (state() == InferiorStopOk) { notifyInferiorRunRequested(); notifyInferiorRunOk(); setState(InferiorStopRequested); } else if (state() == InferiorRunRequested) { notifyInferiorRunOk(); setState(InferiorStopRequested); } // now track cpp engine setActiveEngine(m_cppEngine); } break; } case InferiorStopOk: { if (isDying()) { EDEBUG("... CPP ENGINE STOPPED DURING SHUTDOWN "); QTC_ASSERT(state() == InferiorStopRequested || state() == InferiorRunOk || state() == InferiorStopOk, qDebug() << state()); // Just to make sure, we're shutting down anyway ... setActiveEngine(m_cppEngine); if (state() == InferiorStopRequested) setState(InferiorStopOk); // otherwise we're probably inside notifyInferiorStopOk already } else { if (m_activeEngine != cppEngine()) { showStatusMessage(tr("C++ debugger activated")); setActiveEngine(m_cppEngine); } QTC_ASSERT(state() == InferiorStopRequested || state() == InferiorRunRequested || state() == EngineRunRequested || state() == InferiorRunOk || state() == InferiorStopOk, qDebug() << state()); switch (state()) { case InferiorStopRequested: EDEBUG("... CPP ENGINE STOPPED EXPECTEDLY"); notifyInferiorStopOk(); break; case EngineRunRequested: EDEBUG("... CPP ENGINE STOPPED ON STARTUP"); notifyEngineRunAndInferiorStopOk(); break; case InferiorRunOk: EDEBUG("... CPP ENGINE STOPPED SPONTANEOUSLY"); notifyInferiorSpontaneousStop(); break; case InferiorRunRequested: // can happen if qml engine was active notifyInferiorRunFailed(); default: break; } } break; } case InferiorStopFailed: { QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state()); notifyInferiorStopFailed(); break; } case InferiorExitOk: { // InferiorExitOk will be called through notifyInferiorExited // when InferiorShutDownOk is reached qmlEngine()->quitDebugger(); break; } case InferiorShutdownRequested: { // might be set by queueShutdownInferior() already QTC_ASSERT(state() == InferiorShutdownRequested || state() == InferiorStopOk, qDebug() << state()); if (state() == InferiorStopOk) setState(InferiorShutdownRequested); qmlEngine()->quitDebugger(); break; } case InferiorShutdownFailed: { QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state()); notifyInferiorShutdownFailed(); break; } case InferiorShutdownOk: { if (state() == InferiorShutdownRequested) { notifyInferiorShutdownOk(); } else { // we got InferiorExitOk before, but ignored it ... notifyInferiorExited(); } break; } case EngineShutdownRequested: { // set by queueShutdownEngine() QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state()); break; } case EngineShutdownFailed: { QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state()); notifyEngineShutdownFailed(); break; } case EngineShutdownOk: { QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state()); notifyEngineShutdownOk(); break; } case DebuggerFinished: { // set by queueFinishDebugger() QTC_ASSERT(state() == DebuggerFinished, qDebug() << state()); break; } } } else { // QML engine state change if (newState == InferiorStopOk) { if (isDying()) { EDEBUG("... QML ENGINE STOPPED DURING SHUTDOWN "); // Just to make sure, we're shutting down anyway ... setActiveEngine(m_cppEngine); if (state() == InferiorStopRequested) notifyInferiorStopOk(); // otherwise we're probably inside notifyInferiorStopOk already } else { if (m_activeEngine != qmlEngine()) { showStatusMessage(tr("QML debugger activated")); setActiveEngine(m_qmlEngine); } QTC_ASSERT(state() == InferiorRunOk || state() == InferiorStopRequested || state() == InferiorShutdownRequested, qDebug() << state()); if (state() == InferiorRunOk) notifyInferiorSpontaneousStop(); else if (state() == InferiorStopRequested) notifyInferiorStopOk(); } } else if (newState == InferiorRunOk) { if (m_activeEngine == qmlEngine()) { QTC_ASSERT(state() == InferiorRunRequested, qDebug() << state()); notifyInferiorRunOk(); } } } }