debugger: re-enable setting breakpoints while inferior is running

This commit is contained in:
hjk
2010-07-20 12:14:59 +02:00
parent 40bb503219
commit af57dc4170
9 changed files with 44 additions and 32 deletions

View File

@@ -432,7 +432,7 @@ void DebuggerEngine::handleCommand(int role, const QVariant &value)
break; break;
case RequestExecInterruptRole: case RequestExecInterruptRole:
d->doInterruptInferior(); requestInterruptInferior();
break; break;
case RequestExecResetRole: case RequestExecResetRole:
@@ -1412,6 +1412,11 @@ void DebuggerEngine::quitDebugger()
shutdownInferior(); shutdownInferior();
} }
void DebuggerEngine::requestInterruptInferior()
{
d->doInterruptInferior();
}
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger

View File

@@ -173,6 +173,8 @@ protected:
virtual void continueInferior() {} virtual void continueInferior() {}
virtual void interruptInferior() {} virtual void interruptInferior() {}
virtual void requestInterruptInferior();
virtual void executeRunToLine(const QString &fileName, int lineNumber) virtual void executeRunToLine(const QString &fileName, int lineNumber)
{ Q_UNUSED(fileName); Q_UNUSED(lineNumber); } { Q_UNUSED(fileName); Q_UNUSED(lineNumber); }
virtual void executeRunToFunction(const QString &functionName) virtual void executeRunToFunction(const QString &functionName)

View File

@@ -54,6 +54,7 @@ AbstractGdbAdapter::~AbstractGdbAdapter()
//void AbstractGdbAdapter::runEngine() //void AbstractGdbAdapter::runEngine()
//{ //{
// QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
//} //}
/* /*

View File

@@ -78,7 +78,6 @@ void AttachGdbAdapter::runEngine()
{ {
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
m_engine->notifyEngineRunAndInferiorStopOk(); m_engine->notifyEngineRunAndInferiorStopOk();
m_engine->notifyInferiorRunRequested();
m_engine->continueInferiorInternal(); m_engine->continueInferiorInternal();
m_engine->showStatusMessage(tr("Attached to process %1.") m_engine->showStatusMessage(tr("Attached to process %1.")
.arg(m_engine->inferiorPid())); .arg(m_engine->inferiorPid()));

View File

@@ -654,13 +654,13 @@ void GdbEngine::interruptInferior()
void GdbEngine::interruptInferiorTemporarily() void GdbEngine::interruptInferiorTemporarily()
{ {
interruptInferior();
foreach (const GdbCommand &cmd, m_commandsToRunOnTemporaryBreak) { foreach (const GdbCommand &cmd, m_commandsToRunOnTemporaryBreak) {
if (cmd.flags & LosesChild) { if (cmd.flags & LosesChild) {
notifyInferiorIll(); notifyInferiorIll();
break; return;
} }
} }
requestInterruptInferior();
} }
void GdbEngine::maybeHandleInferiorPidChanged(const QString &pid0) void GdbEngine::maybeHandleInferiorPidChanged(const QString &pid0)
@@ -1798,9 +1798,10 @@ unsigned GdbEngine::debuggerCapabilities() const
void GdbEngine::continueInferiorInternal() void GdbEngine::continueInferiorInternal()
{ {
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
notifyInferiorRunRequested();
showStatusMessage(tr("Running requested..."), 5000);
QTC_ASSERT(state() == InferiorRunRequested, qDebug() << state()); QTC_ASSERT(state() == InferiorRunRequested, qDebug() << state());
//QTC_ASSERT(state() == InferiorStopOk || state() == InferiorSetupRequested,
// qDebug() << state());
postCommand("-exec-continue", RunRequest, CB(handleExecuteContinue)); postCommand("-exec-continue", RunRequest, CB(handleExecuteContinue));
} }
@@ -1815,9 +1816,7 @@ void GdbEngine::continueInferior()
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
resetLocation(); resetLocation();
setTokenBarrier(); setTokenBarrier();
notifyInferiorRunRequested();
continueInferiorInternal(); continueInferiorInternal();
showStatusMessage(tr("Running requested..."), 5000);
} }
void GdbEngine::executeStep() void GdbEngine::executeStep()
@@ -1953,7 +1952,6 @@ void GdbEngine::executeRunToFunction(const QString &functionName)
setTokenBarrier(); setTokenBarrier();
postCommand("-break-insert -t " + functionName.toLatin1()); postCommand("-break-insert -t " + functionName.toLatin1());
showStatusMessage(tr("Run to function %1 requested...").arg(functionName), 5000); showStatusMessage(tr("Run to function %1 requested...").arg(functionName), 5000);
notifyInferiorRunRequested();
continueInferiorInternal(); continueInferiorInternal();
//postCommand("-exec-continue", handleExecuteRunToFunction); //postCommand("-exec-continue", handleExecuteRunToFunction);
} }

View File

@@ -225,8 +225,8 @@ void RemoteGdbServerAdapter::handleTargetRemote(const GdbResponse &record)
void RemoteGdbServerAdapter::runEngine() void RemoteGdbServerAdapter::runEngine()
{ {
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
m_engine->notifyEngineRunAndInferiorStopOk(); m_engine->notifyEngineRunAndInferiorStopOk();
m_engine->notifyInferiorRunRequested();
m_engine->continueInferiorInternal(); m_engine->continueInferiorInternal();
} }

View File

@@ -237,7 +237,7 @@ void TcfTrkGdbAdapter::handleTcfTrkRunControlModuleLoadContextSuspendedEvent(con
// + QByteArray::number(m_session.codeseg)); // + QByteArray::number(m_session.codeseg));
m_engine->postCommand("symbol-file \"" + symbolFile + "\""); 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(s);
m_engine->postCommand("target remote " + gdbServerName().toLatin1(), m_engine->postCommand("target remote " + gdbServerName().toLatin1(),
CB(handleTargetRemote)); CB(handleTargetRemote));
@@ -299,7 +299,7 @@ void TcfTrkGdbAdapter::tcftrkEvent(const TcfTrkEvent &e)
const TcfTrkRunControlContextSuspendedEvent &se = static_cast<const TcfTrkRunControlContextSuspendedEvent &>(e); const TcfTrkRunControlContextSuspendedEvent &se = static_cast<const TcfTrkRunControlContextSuspendedEvent &>(e);
const unsigned threadId = RunControlContext::threadIdFromTcdfId(se.id()); const unsigned threadId = RunControlContext::threadIdFromTcdfId(se.id());
const QString reason = QString::fromUtf8(se.reasonID()); 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)); arg(threadId, 0, 16).arg(reason));
// Stopped in a new thread: Add. // Stopped in a new thread: Add.
m_snapshot.reset(); m_snapshot.reset();
@@ -544,7 +544,7 @@ void TcfTrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
const uint signalNumber = cmd.mid(1).toUInt(&ok, 16); const uint signalNumber = cmd.mid(1).toUInt(&ok, 16);
//TODO: Meaning of the message is not clear. //TODO: Meaning of the message is not clear.
sendGdbServerAck(); 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("O" + QByteArray("Console output").toHex());
sendGdbServerMessage("W81"); // "Process exited with result 1 sendGdbServerMessage("W81"); // "Process exited with result 1
sendTrkContinue(); sendTrkContinue();
@@ -646,7 +646,7 @@ void TcfTrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
sendGdbServerMessage("E20", "Data length mismatch " + cmd); sendGdbServerMessage("E20", "Data length mismatch " + cmd);
return; 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(addrLength.second).arg(addrLength.first, 0, 16).
arg(QString::fromAscii(data.toHex()))); arg(QString::fromAscii(data.toHex())));
m_trkDevice->sendMemorySetCommand(TcfTrkCallback(this, &TcfTrkGdbAdapter::handleWriteMemory), m_trkDevice->sendMemorySetCommand(TcfTrkCallback(this, &TcfTrkGdbAdapter::handleWriteMemory),
@@ -680,7 +680,7 @@ void TcfTrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
const QPair<uint, uint> regnumValue = parseGdbWriteRegisterWriteRequest(cmd); const QPair<uint, uint> regnumValue = parseGdbWriteRegisterWriteRequest(cmd);
// FIXME: Assume all goes well. // FIXME: Assume all goes well.
m_snapshot.setRegisterValue(m_session.tid, regnumValue.first, regnumValue.second); 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), m_trkDevice->sendRegistersSetCommand(TcfTrkCallback(this, &TcfTrkGdbAdapter::handleWriteRegister),
currentThreadContextId(), regnumValue.first, regnumValue.second, currentThreadContextId(), regnumValue.first, regnumValue.second,
QVariant(regnumValue.first)); QVariant(regnumValue.first));
@@ -803,7 +803,7 @@ void TcfTrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
else if (cmd == "s" || cmd.startsWith("vCont;s")) { else if (cmd == "s" || cmd.startsWith("vCont;s")) {
const uint pc = m_snapshot.registerValue(m_session.tid, RegisterPC); 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))); arg(pc, 0, 16)));
sendGdbServerAck(); sendGdbServerAck();
m_running = true; m_running = true;
@@ -905,7 +905,7 @@ void TcfTrkGdbAdapter::gdbSetCurrentThread(const QByteArray &cmd, const char *wh
const QByteArray id = cmd.mid(2); const QByteArray id = cmd.mid(2);
const int threadId = id == "-1" ? -1 : id.toInt(0, 16); const int threadId = id == "-1" ? -1 : id.toInt(0, 16);
const QByteArray message = QByteArray(why) + QByteArray::number(threadId); 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.). // Set thread for subsequent operations (`m', `M', `g', `G', et.al.).
// for 'other operations. 0 - any thread // for 'other operations. 0 - any thread
//$Hg0#df //$Hg0#df
@@ -977,7 +977,7 @@ void TcfTrkGdbAdapter::startAdapter()
connect(m_gdbServer, SIGNAL(newConnection()), connect(m_gdbServer, SIGNAL(newConnection()),
this, SLOT(handleGdbConnection())); 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)); .arg(tcfTrkAddress).arg(tcfTrkPort));
tcfTrkSocket->connectToHost(tcfTrkAddress, tcfTrkPort); tcfTrkSocket->connectToHost(tcfTrkAddress, tcfTrkPort);
} }
@@ -985,7 +985,8 @@ void TcfTrkGdbAdapter::startAdapter()
void TcfTrkGdbAdapter::setupInferior() void TcfTrkGdbAdapter::setupInferior()
{ {
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
m_trkDevice->sendProcessStartCommand(TcfTrkCallback(this, &TcfTrkGdbAdapter::handleCreateProcess), m_trkDevice->sendProcessStartCommand(
TcfTrkCallback(this, &TcfTrkGdbAdapter::handleCreateProcess),
m_remoteExecutable, m_uid, m_remoteArguments, m_remoteExecutable, m_uid, m_remoteArguments,
QString(), true); QString(), true);
} }
@@ -1009,7 +1010,7 @@ void TcfTrkGdbAdapter::handleCreateProcess(const TcfTrkCommandResult &result)
qDebug() << "ProcessCreated: " << result.toString(); qDebug() << "ProcessCreated: " << result.toString();
if (!result) { if (!result) {
const QString errorMessage = result.errorString(); 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()); m_engine->notifyInferiorSetupFailed(result.errorString());
return; return;
} }
@@ -1030,7 +1031,8 @@ void TcfTrkGdbAdapter::handleCreateProcess(const TcfTrkCommandResult &result)
void TcfTrkGdbAdapter::runEngine() void TcfTrkGdbAdapter::runEngine()
{ {
m_engine->notifyInferiorStopOk(); QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
m_engine->notifyEngineRunAndInferiorStopOk();
// Trigger the initial "continue" manually. // Trigger the initial "continue" manually.
m_engine->continueInferiorInternal(); m_engine->continueInferiorInternal();
} }
@@ -1052,7 +1054,8 @@ void TcfTrkGdbAdapter::write(const QByteArray &data)
data1.chop(1); data1.chop(1);
bool ok; bool ok;
const uint addr = data1.toUInt(&ok, 0); 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); // directStep(addr);
return; return;
} }
@@ -1115,7 +1118,8 @@ void TcfTrkGdbAdapter::handleWriteRegister(const TcfTrkCommandResult &result)
if (result) { if (result) {
sendGdbServerMessage("OK"); sendGdbServerMessage("OK");
} else { } 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"); sendGdbServerMessage("E01");
} }
} }
@@ -1353,7 +1357,7 @@ void TcfTrkGdbAdapter::sendTrkStepRange()
uint to = m_snapshot.lineToAddress; uint to = m_snapshot.lineToAddress;
const uint pc = m_snapshot.registerValue(m_session.tid, RegisterPC); const uint pc = m_snapshot.registerValue(m_session.tid, RegisterPC);
if (from <= pc && pc <= to) { 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); arg(from, 0, 16).arg(to, 0, 16).arg(pc, 0, 16);
showMessage(msg); showMessage(msg);
} else { } else {
@@ -1365,9 +1369,10 @@ void TcfTrkGdbAdapter::sendTrkStepRange()
(m_snapshot.stepOver ? RM_STEP_OVER : RM_STEP_INTO) : (m_snapshot.stepOver ? RM_STEP_OVER : RM_STEP_INTO) :
(m_snapshot.stepOver ? RM_STEP_OVER_RANGE : RM_STEP_INTO_RANGE); (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))); arg(from, 0, 16).arg(to, 0, 16).arg(pc).arg(int(mode)));
m_trkDevice->sendRunControlResumeCommand(TcfTrkCallback(this, &TcfTrkGdbAdapter::handleStep), m_trkDevice->sendRunControlResumeCommand(
TcfTrkCallback(this, &TcfTrkGdbAdapter::handleStep),
currentThreadContextId(), currentThreadContextId(),
mode, 1, from, to); mode, 1, from, to);
} }
@@ -1376,7 +1381,8 @@ void TcfTrkGdbAdapter::handleStep(const TcfTrkCommandResult &result)
{ {
if (!result) { // Try fallback with Continue. 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(); sendTrkContinue();
// Doing nothing as below does not work as gdb seems to insist on // Doing nothing as below does not work as gdb seems to insist on
// making some progress through a 'step'. // making some progress through a 'step'.

View File

@@ -143,7 +143,6 @@ void TermGdbAdapter::runEngine()
{ {
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
m_engine->notifyEngineRunAndInferiorStopOk(); m_engine->notifyEngineRunAndInferiorStopOk();
m_engine->notifyInferiorRunRequested();
m_engine->continueInferiorInternal(); m_engine->continueInferiorInternal();
} }

View File

@@ -1615,6 +1615,8 @@ void TrkGdbAdapter::handleTargetRemote(const GdbResponse &record)
void TrkGdbAdapter::runEngine() void TrkGdbAdapter::runEngine()
{ {
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
m_engine->notifyEngineRunAndInferiorStopOk();
m_engine->continueInferiorInternal(); m_engine->continueInferiorInternal();
} }