From af57dc417086eb78e30856972d739a6e8d06a596 Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Tue, 20 Jul 2010 12:14:59 +0200 Subject: [PATCH] debugger: re-enable setting breakpoints while inferior is running --- src/plugins/debugger/debuggerengine.cpp | 7 ++- src/plugins/debugger/debuggerengine.h | 2 + .../debugger/gdb/abstractgdbadapter.cpp | 1 + src/plugins/debugger/gdb/attachgdbadapter.cpp | 1 - src/plugins/debugger/gdb/gdbengine.cpp | 12 ++--- .../debugger/gdb/remotegdbserveradapter.cpp | 2 +- src/plugins/debugger/gdb/tcftrkgdbadapter.cpp | 48 +++++++++++-------- src/plugins/debugger/gdb/termgdbadapter.cpp | 1 - src/plugins/debugger/gdb/trkgdbadapter.cpp | 2 + 9 files changed, 44 insertions(+), 32 deletions(-) diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index fdabaca597d..e55aff1d07e 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -432,7 +432,7 @@ void DebuggerEngine::handleCommand(int role, const QVariant &value) break; case RequestExecInterruptRole: - d->doInterruptInferior(); + requestInterruptInferior(); break; case RequestExecResetRole: @@ -1412,6 +1412,11 @@ void DebuggerEngine::quitDebugger() shutdownInferior(); } +void DebuggerEngine::requestInterruptInferior() +{ + d->doInterruptInferior(); +} + } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 592474476b6..1d4845b1692 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -173,6 +173,8 @@ protected: virtual void continueInferior() {} virtual void interruptInferior() {} + virtual void requestInterruptInferior(); + virtual void executeRunToLine(const QString &fileName, int lineNumber) { Q_UNUSED(fileName); Q_UNUSED(lineNumber); } virtual void executeRunToFunction(const QString &functionName) diff --git a/src/plugins/debugger/gdb/abstractgdbadapter.cpp b/src/plugins/debugger/gdb/abstractgdbadapter.cpp index b3723f1005e..e663126ae36 100644 --- a/src/plugins/debugger/gdb/abstractgdbadapter.cpp +++ b/src/plugins/debugger/gdb/abstractgdbadapter.cpp @@ -54,6 +54,7 @@ AbstractGdbAdapter::~AbstractGdbAdapter() //void AbstractGdbAdapter::runEngine() //{ +// QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); //} /* diff --git a/src/plugins/debugger/gdb/attachgdbadapter.cpp b/src/plugins/debugger/gdb/attachgdbadapter.cpp index 935f30e4962..ed4edc6b0e3 100644 --- a/src/plugins/debugger/gdb/attachgdbadapter.cpp +++ b/src/plugins/debugger/gdb/attachgdbadapter.cpp @@ -78,7 +78,6 @@ void AttachGdbAdapter::runEngine() { QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); m_engine->notifyEngineRunAndInferiorStopOk(); - m_engine->notifyInferiorRunRequested(); m_engine->continueInferiorInternal(); m_engine->showStatusMessage(tr("Attached to process %1.") .arg(m_engine->inferiorPid())); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index d0a363d3934..1ad8e5f77e3 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -654,13 +654,13 @@ void GdbEngine::interruptInferior() void GdbEngine::interruptInferiorTemporarily() { - interruptInferior(); foreach (const GdbCommand &cmd, m_commandsToRunOnTemporaryBreak) { if (cmd.flags & LosesChild) { notifyInferiorIll(); - break; + return; } } + requestInterruptInferior(); } void GdbEngine::maybeHandleInferiorPidChanged(const QString &pid0) @@ -1798,9 +1798,10 @@ unsigned GdbEngine::debuggerCapabilities() const void GdbEngine::continueInferiorInternal() { + QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + notifyInferiorRunRequested(); + showStatusMessage(tr("Running requested..."), 5000); QTC_ASSERT(state() == InferiorRunRequested, qDebug() << state()); - //QTC_ASSERT(state() == InferiorStopOk || state() == InferiorSetupRequested, - // qDebug() << state()); postCommand("-exec-continue", RunRequest, CB(handleExecuteContinue)); } @@ -1815,9 +1816,7 @@ void GdbEngine::continueInferior() QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); resetLocation(); setTokenBarrier(); - notifyInferiorRunRequested(); continueInferiorInternal(); - showStatusMessage(tr("Running requested..."), 5000); } void GdbEngine::executeStep() @@ -1953,7 +1952,6 @@ void GdbEngine::executeRunToFunction(const QString &functionName) setTokenBarrier(); postCommand("-break-insert -t " + functionName.toLatin1()); showStatusMessage(tr("Run to function %1 requested...").arg(functionName), 5000); - notifyInferiorRunRequested(); continueInferiorInternal(); //postCommand("-exec-continue", handleExecuteRunToFunction); } diff --git a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp index fd1b564929f..abcd5622450 100644 --- a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp +++ b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp @@ -225,8 +225,8 @@ void RemoteGdbServerAdapter::handleTargetRemote(const GdbResponse &record) void RemoteGdbServerAdapter::runEngine() { + QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); m_engine->notifyEngineRunAndInferiorStopOk(); - m_engine->notifyInferiorRunRequested(); m_engine->continueInferiorInternal(); } diff --git a/src/plugins/debugger/gdb/tcftrkgdbadapter.cpp b/src/plugins/debugger/gdb/tcftrkgdbadapter.cpp index c4863ebffa2..059f8f86fe0 100644 --- a/src/plugins/debugger/gdb/tcftrkgdbadapter.cpp +++ b/src/plugins/debugger/gdb/tcftrkgdbadapter.cpp @@ -237,7 +237,7 @@ void TcfTrkGdbAdapter::handleTcfTrkRunControlModuleLoadContextSuspendedEvent(con // + QByteArray::number(m_session.codeseg)); m_engine->postCommand("symbol-file \"" + symbolFile + "\""); } - foreach(const QByteArray &s, Symbian::gdbStartupSequence()) + foreach (const QByteArray &s, Symbian::gdbStartupSequence()) m_engine->postCommand(s); m_engine->postCommand("target remote " + gdbServerName().toLatin1(), CB(handleTargetRemote)); @@ -299,7 +299,7 @@ void TcfTrkGdbAdapter::tcftrkEvent(const TcfTrkEvent &e) const TcfTrkRunControlContextSuspendedEvent &se = static_cast<const TcfTrkRunControlContextSuspendedEvent &>(e); const unsigned threadId = RunControlContext::threadIdFromTcdfId(se.id()); const QString reason = QString::fromUtf8(se.reasonID()); - showMessage(QString::fromLatin1("Reset snapshot (Thread 0x%1 stopped: '%2')"). + showMessage(_("Reset snapshot (Thread 0x%1 stopped: '%2')"). arg(threadId, 0, 16).arg(reason)); // Stopped in a new thread: Add. m_snapshot.reset(); @@ -544,7 +544,7 @@ void TcfTrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd) const uint signalNumber = cmd.mid(1).toUInt(&ok, 16); //TODO: Meaning of the message is not clear. sendGdbServerAck(); - logMessage(QString::fromLatin1("Not implemented 'Continue with signal' %1: ").arg(signalNumber), LogWarning); + logMessage(_("Not implemented 'Continue with signal' %1: ").arg(signalNumber), LogWarning); sendGdbServerMessage("O" + QByteArray("Console output").toHex()); sendGdbServerMessage("W81"); // "Process exited with result 1 sendTrkContinue(); @@ -646,7 +646,7 @@ void TcfTrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd) sendGdbServerMessage("E20", "Data length mismatch " + cmd); return; } - logMessage(QString::fromLatin1("Writing %1 bytes from 0x%2: %3"). + logMessage(_("Writing %1 bytes from 0x%2: %3"). arg(addrLength.second).arg(addrLength.first, 0, 16). arg(QString::fromAscii(data.toHex()))); m_trkDevice->sendMemorySetCommand(TcfTrkCallback(this, &TcfTrkGdbAdapter::handleWriteMemory), @@ -680,7 +680,7 @@ void TcfTrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd) const QPair<uint, uint> regnumValue = parseGdbWriteRegisterWriteRequest(cmd); // FIXME: Assume all goes well. m_snapshot.setRegisterValue(m_session.tid, regnumValue.first, regnumValue.second); - logMessage(QString::fromLatin1("Setting register #%1 to 0x%2").arg(regnumValue.first).arg(regnumValue.second, 0, 16)); + logMessage(_("Setting register #%1 to 0x%2").arg(regnumValue.first).arg(regnumValue.second, 0, 16)); m_trkDevice->sendRegistersSetCommand(TcfTrkCallback(this, &TcfTrkGdbAdapter::handleWriteRegister), currentThreadContextId(), regnumValue.first, regnumValue.second, QVariant(regnumValue.first)); @@ -803,7 +803,7 @@ void TcfTrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd) else if (cmd == "s" || cmd.startsWith("vCont;s")) { const uint pc = m_snapshot.registerValue(m_session.tid, RegisterPC); - logMessage(msgGdbPacket(QString::fromLatin1("Step range from 0x%1"). + logMessage(msgGdbPacket(_("Step range from 0x%1"). arg(pc, 0, 16))); sendGdbServerAck(); m_running = true; @@ -905,7 +905,7 @@ void TcfTrkGdbAdapter::gdbSetCurrentThread(const QByteArray &cmd, const char *wh const QByteArray id = cmd.mid(2); const int threadId = id == "-1" ? -1 : id.toInt(0, 16); const QByteArray message = QByteArray(why) + QByteArray::number(threadId); - logMessage(msgGdbPacket(QString::fromLatin1(message))); + logMessage(msgGdbPacket(_(message))); // Set thread for subsequent operations (`m', `M', `g', `G', et.al.). // for 'other operations. 0 - any thread //$Hg0#df @@ -977,7 +977,7 @@ void TcfTrkGdbAdapter::startAdapter() connect(m_gdbServer, SIGNAL(newConnection()), this, SLOT(handleGdbConnection())); - logMessage(QString::fromLatin1("Connecting to TCF TRK on %1:%2") + logMessage(_("Connecting to TCF TRK on %1:%2") .arg(tcfTrkAddress).arg(tcfTrkPort)); tcfTrkSocket->connectToHost(tcfTrkAddress, tcfTrkPort); } @@ -985,9 +985,10 @@ void TcfTrkGdbAdapter::startAdapter() void TcfTrkGdbAdapter::setupInferior() { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); - m_trkDevice->sendProcessStartCommand(TcfTrkCallback(this, &TcfTrkGdbAdapter::handleCreateProcess), - m_remoteExecutable, m_uid, m_remoteArguments, - QString(), true); + m_trkDevice->sendProcessStartCommand( + TcfTrkCallback(this, &TcfTrkGdbAdapter::handleCreateProcess), + m_remoteExecutable, m_uid, m_remoteArguments, + QString(), true); } void TcfTrkGdbAdapter::addThread(unsigned id) @@ -1009,7 +1010,7 @@ void TcfTrkGdbAdapter::handleCreateProcess(const TcfTrkCommandResult &result) qDebug() << "ProcessCreated: " << result.toString(); if (!result) { const QString errorMessage = result.errorString(); - logMessage(QString::fromLatin1("Failed to start process: %1").arg(errorMessage), LogError); + logMessage(_("Failed to start process: %1").arg(errorMessage), LogError); m_engine->notifyInferiorSetupFailed(result.errorString()); return; } @@ -1030,7 +1031,8 @@ void TcfTrkGdbAdapter::handleCreateProcess(const TcfTrkCommandResult &result) void TcfTrkGdbAdapter::runEngine() { - m_engine->notifyInferiorStopOk(); + QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); + m_engine->notifyEngineRunAndInferiorStopOk(); // Trigger the initial "continue" manually. m_engine->continueInferiorInternal(); } @@ -1052,7 +1054,8 @@ void TcfTrkGdbAdapter::write(const QByteArray &data) data1.chop(1); bool ok; const uint addr = data1.toUInt(&ok, 0); - logMessage(QString::fromLatin1("Direct step (@#) 0x%1: not implemented").arg(addr, 0, 16), LogError); + logMessage(_("Direct step (@#) 0x%1: not implemented").arg(addr, 0, 16), + LogError); // directStep(addr); return; } @@ -1115,7 +1118,8 @@ void TcfTrkGdbAdapter::handleWriteRegister(const TcfTrkCommandResult &result) if (result) { sendGdbServerMessage("OK"); } else { - logMessage(QString::fromLatin1("ERROR writing register #%1: %2").arg(registerNumber).arg(result.errorString()), LogError); + logMessage(_("ERROR writing register #%1: %2") + .arg(registerNumber).arg(result.errorString()), LogError); sendGdbServerMessage("E01"); } } @@ -1353,7 +1357,7 @@ void TcfTrkGdbAdapter::sendTrkStepRange() uint to = m_snapshot.lineToAddress; const uint pc = m_snapshot.registerValue(m_session.tid, RegisterPC); if (from <= pc && pc <= to) { - const QString msg = QString::fromLatin1("Step in 0x%1 .. 0x%2 instead of 0x%3..."). + const QString msg = _("Step in 0x%1 .. 0x%2 instead of 0x%3..."). arg(from, 0, 16).arg(to, 0, 16).arg(pc, 0, 16); showMessage(msg); } else { @@ -1365,18 +1369,20 @@ void TcfTrkGdbAdapter::sendTrkStepRange() (m_snapshot.stepOver ? RM_STEP_OVER : RM_STEP_INTO) : (m_snapshot.stepOver ? RM_STEP_OVER_RANGE : RM_STEP_INTO_RANGE); - logMessage(QString::fromLatin1("Stepping from 0x%1 to 0x%2 (current PC=0x%3), mode %4"). + logMessage(_("Stepping from 0x%1 to 0x%2 (current PC=0x%3), mode %4"). arg(from, 0, 16).arg(to, 0, 16).arg(pc).arg(int(mode))); - m_trkDevice->sendRunControlResumeCommand(TcfTrkCallback(this, &TcfTrkGdbAdapter::handleStep), - currentThreadContextId(), - mode, 1, from, to); + m_trkDevice->sendRunControlResumeCommand( + TcfTrkCallback(this, &TcfTrkGdbAdapter::handleStep), + currentThreadContextId(), + mode, 1, from, to); } void TcfTrkGdbAdapter::handleStep(const TcfTrkCommandResult &result) { if (!result) { // Try fallback with Continue. - logMessage(QString::fromLatin1("Error while stepping: %1 (fallback to 'continue')").arg(result.errorString()), LogWarning); + logMessage(_("Error while stepping: %1 (fallback to 'continue')"). + arg(result.errorString()), LogWarning); sendTrkContinue(); // Doing nothing as below does not work as gdb seems to insist on // making some progress through a 'step'. diff --git a/src/plugins/debugger/gdb/termgdbadapter.cpp b/src/plugins/debugger/gdb/termgdbadapter.cpp index 66fae71c6d7..a74f16b96e7 100644 --- a/src/plugins/debugger/gdb/termgdbadapter.cpp +++ b/src/plugins/debugger/gdb/termgdbadapter.cpp @@ -143,7 +143,6 @@ void TermGdbAdapter::runEngine() { QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); m_engine->notifyEngineRunAndInferiorStopOk(); - m_engine->notifyInferiorRunRequested(); m_engine->continueInferiorInternal(); } diff --git a/src/plugins/debugger/gdb/trkgdbadapter.cpp b/src/plugins/debugger/gdb/trkgdbadapter.cpp index 3a9bf11f57e..d332e429d37 100644 --- a/src/plugins/debugger/gdb/trkgdbadapter.cpp +++ b/src/plugins/debugger/gdb/trkgdbadapter.cpp @@ -1615,6 +1615,8 @@ void TrkGdbAdapter::handleTargetRemote(const GdbResponse &record) void TrkGdbAdapter::runEngine() { + QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); + m_engine->notifyEngineRunAndInferiorStopOk(); m_engine->continueInferiorInternal(); } -- GitLab