centralize exec-continue calling and error handling

This commit is contained in:
Oswald Buddenhagen
2009-10-20 14:08:59 +02:00
parent a8b39c54d7
commit b2ae433a58
5 changed files with 14 additions and 32 deletions

View File

@@ -1055,7 +1055,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
QString pat = theDebuggerStringSetting(SelectedPluginBreakpointsPattern); QString pat = theDebuggerStringSetting(SelectedPluginBreakpointsPattern);
debugMessage(_("PATTERN: ") + pat); debugMessage(_("PATTERN: ") + pat);
postCommand(_("sharedlibrary ") + pat); postCommand(_("sharedlibrary ") + pat);
continueInferior(); continueInferiorInternal();
showStatusMessage(tr("Loading %1...").arg(dataStr)); showStatusMessage(tr("Loading %1...").arg(dataStr));
return; return;
} }
@@ -1070,7 +1070,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
// args=[],from="C:\\WINDOWS\\system32\\ntdll.dll"} // args=[],from="C:\\WINDOWS\\system32\\ntdll.dll"}
//if (reason == "signal-received" //if (reason == "signal-received"
// && data.findChild("signal-name").data() == "SIGTRAP") { // && data.findChild("signal-name").data() == "SIGTRAP") {
// continueInferior(); // continueInferiorInternal();
// return; // return;
//} //}
@@ -1178,8 +1178,7 @@ void GdbEngine::handleStop1(const GdbMi &data)
GdbMi frameData = data.findChild("frame"); GdbMi frameData = data.findChild("frame");
if (frameData.findChild("func").data() == "_start" if (frameData.findChild("func").data() == "_start"
&& frameData.findChild("from").data() == "/lib/ld-linux.so.2") { && frameData.findChild("from").data() == "/lib/ld-linux.so.2") {
setState(InferiorRunningRequested); continueInferiorInternal();
postCommand(_("-exec-continue"), RunRequest, CB(handleExecContinue));
return; return;
} }
} }
@@ -1314,17 +1313,16 @@ void GdbEngine::handleExecContinue(const GdbResponse &response)
QTC_ASSERT(state() == InferiorRunning, /**/); QTC_ASSERT(state() == InferiorRunning, /**/);
} else { } else {
QTC_ASSERT(state() == InferiorRunningRequested, /**/); QTC_ASSERT(state() == InferiorRunningRequested, /**/);
setState(InferiorStopped);
QByteArray msg = response.data.findChild("msg").data(); QByteArray msg = response.data.findChild("msg").data();
if (msg.startsWith("Cannot find bounds of current function")) { if (msg.startsWith("Cannot find bounds of current function")) {
setState(InferiorStopped);
showStatusMessage(tr("Stopped."), 5000); showStatusMessage(tr("Stopped."), 5000);
//showStatusMessage(tr("No debug information available. " //showStatusMessage(tr("No debug information available. "
// "Leaving function...")); // "Leaving function..."));
//stepOutExec(); //stepOutExec();
} else { } else {
showMessageBox(QMessageBox::Critical, tr("Error"), showMessageBox(QMessageBox::Critical, tr("Execution Error"),
tr("Starting executable failed:\n") + QString::fromLocal8Bit(msg)); tr("Cannot continue debugged process:\n") + QString::fromLocal8Bit(msg));
QTC_ASSERT(state() == InferiorRunning, /**/);
shutdown(); shutdown();
} }
} }
@@ -1531,8 +1529,6 @@ void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp)
void GdbEngine::continueInferiorInternal() void GdbEngine::continueInferiorInternal()
{ {
QTC_ASSERT(state() == InferiorStopped, qDebug() << state()); QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
m_manager->resetLocation();
setTokenBarrier();
setState(InferiorRunningRequested); setState(InferiorRunningRequested);
postCommand(_("-exec-continue"), RunRequest, CB(handleExecContinue)); postCommand(_("-exec-continue"), RunRequest, CB(handleExecContinue));
} }
@@ -1545,6 +1541,8 @@ void GdbEngine::autoContinueInferior()
void GdbEngine::continueInferior() void GdbEngine::continueInferior()
{ {
m_manager->resetLocation();
setTokenBarrier();
continueInferiorInternal(); continueInferiorInternal();
showStatusMessage(tr("Running requested..."), 5000); showStatusMessage(tr("Running requested..."), 5000);
} }
@@ -1627,12 +1625,10 @@ void GdbEngine::runToFunctionExec(const QString &functionName)
QTC_ASSERT(state() == InferiorStopped, qDebug() << state()); QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
setTokenBarrier(); setTokenBarrier();
postCommand(_("-break-insert -t ") + functionName); postCommand(_("-break-insert -t ") + functionName);
setState(InferiorRunningRequested); continueInferiorInternal();
showStatusMessage(tr("Run to function %1 requested...").arg(functionName), 5000); //setState(InferiorRunningRequested);
// that should be "^running". We need to handle the resulting
// "Stopped"
postCommand(_("-exec-continue"), RunRequest, CB(handleExecContinue));
//postCommand(_("-exec-continue"), handleExecRunToFunction); //postCommand(_("-exec-continue"), handleExecRunToFunction);
showStatusMessage(tr("Run to function %1 requested...").arg(functionName), 5000);
} }
void GdbEngine::jumpToLineExec(const QString &fileName, int lineNumber) void GdbEngine::jumpToLineExec(const QString &fileName, int lineNumber)

View File

@@ -209,7 +209,7 @@ void RemoteGdbAdapter::handleTargetRemote(const GdbResponse &record)
void RemoteGdbAdapter::startInferiorPhase2() void RemoteGdbAdapter::startInferiorPhase2()
{ {
m_engine->continueInferior(); m_engine->continueInferiorInternal();
} }
void RemoteGdbAdapter::interruptInferior() void RemoteGdbAdapter::interruptInferior()

View File

@@ -130,8 +130,7 @@ void TermGdbAdapter::handleStubAttached(const GdbResponse &response)
void TermGdbAdapter::startInferiorPhase2() void TermGdbAdapter::startInferiorPhase2()
{ {
setState(InferiorRunningRequested); m_engine->continueInferiorInternal();
m_engine->postCommand(_("-exec-continue"), GdbEngine::RunRequest);
} }
void TermGdbAdapter::interruptInferior() void TermGdbAdapter::interruptInferior()

View File

@@ -1649,19 +1649,7 @@ void TrkGdbAdapter::handleTargetRemote(const GdbResponse &record)
void TrkGdbAdapter::startInferiorPhase2() void TrkGdbAdapter::startInferiorPhase2()
{ {
setState(InferiorRunningRequested); m_engine->continueInferiorInternal();
m_engine->postCommand(_("-exec-continue"), GdbEngine::RunRequest, CB(handleFirstContinue));
}
void TrkGdbAdapter::handleFirstContinue(const GdbResponse &record)
{
QTC_ASSERT(state() == InferiorRunning, qDebug() << state());
if (record.resultClass == GdbResultDone) {
debugMessage(_("INFERIOR STARTED"));
showStatusMessage(msgInferiorRunning());
} else {
emit inferiorStartFailed(msgConnectRemoteServerFailed(record.toString()));
}
} }
// //

View File

@@ -180,7 +180,6 @@ private:
Q_SLOT void waitForTrkConnect(); Q_SLOT void waitForTrkConnect();
void handleTargetRemote(const GdbResponse &response); void handleTargetRemote(const GdbResponse &response);
void handleFirstContinue(const GdbResponse &response);
// //
// TRK // TRK