forked from qt-creator/qt-creator
Debugger: Fix GdbEngine state transitions for 'attach'
... to running process. Pretty much the same setup as for the terminal now, except that we are stopped in the end. Change-Id: I02c5bf52971dc97fd6393ee67349c9070dc08697 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -66,40 +66,49 @@ void GdbAttachEngine::setupEngine()
|
|||||||
void GdbAttachEngine::setupInferior()
|
void GdbAttachEngine::setupInferior()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
||||||
const qint64 pid = startParameters().attachPID;
|
|
||||||
postCommand("attach " + QByteArray::number(pid), NoFlags,
|
|
||||||
[this](const DebuggerResponse &r) { handleAttach(r); });
|
|
||||||
// Task 254674 does not want to remove them
|
// Task 254674 does not want to remove them
|
||||||
//qq->breakHandler()->removeAllBreakpoints();
|
//qq->breakHandler()->removeAllBreakpoints();
|
||||||
|
handleInferiorPrepared();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbAttachEngine::runEngine()
|
void GdbAttachEngine::runEngine()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
||||||
|
const qint64 pid = startParameters().attachPID;
|
||||||
|
postCommand("attach " + QByteArray::number(pid), NoFlags,
|
||||||
|
[this](const DebuggerResponse &r) { handleAttach(r); });
|
||||||
showStatusMessage(tr("Attached to process %1.").arg(inferiorPid()));
|
showStatusMessage(tr("Attached to process %1.").arg(inferiorPid()));
|
||||||
notifyEngineRunAndInferiorStopOk();
|
|
||||||
handleStop1(GdbMi());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbAttachEngine::handleAttach(const DebuggerResponse &response)
|
void GdbAttachEngine::handleAttach(const DebuggerResponse &response)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
QTC_ASSERT(state() == EngineRunRequested || state() == InferiorStopOk,
|
||||||
|
qDebug() << state());
|
||||||
switch (response.resultClass) {
|
switch (response.resultClass) {
|
||||||
case ResultDone:
|
case ResultDone:
|
||||||
case ResultRunning:
|
case ResultRunning:
|
||||||
showMessage(_("INFERIOR ATTACHED"));
|
showMessage(_("INFERIOR ATTACHED"));
|
||||||
showMessage(msgAttachedToStoppedInferior(), StatusBar);
|
if (state() == EngineRunRequested) {
|
||||||
handleInferiorPrepared();
|
// FIXME: Really? Looks like we are always stopped already.
|
||||||
|
// We will get a '*stopped' later that we'll interpret as 'spontaneous'
|
||||||
|
// So acknowledge the current state and put a delayed 'continue' in the pipe.
|
||||||
|
showMessage(msgAttachedToStoppedInferior(), StatusBar);
|
||||||
|
notifyEngineRunAndInferiorRunOk();
|
||||||
|
interruptInferior();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ResultError:
|
case ResultError:
|
||||||
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
|
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
|
||||||
notifyInferiorSetupFailed(msgPtraceError(startParameters().startMode));
|
showStatusMessage(tr("Failed to attach to application: %1")
|
||||||
|
.arg(msgPtraceError(startParameters().startMode)));
|
||||||
|
notifyEngineIll();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// if msg != "ptrace: ..." fall through
|
// if msg != "ptrace: ..." fall through
|
||||||
default:
|
default:
|
||||||
QString msg = QString::fromLocal8Bit(response.data["msg"].data());
|
showStatusMessage(tr("Failed to attach to application: %1")
|
||||||
notifyInferiorSetupFailed(msg);
|
.arg(QString::fromLocal8Bit(response.data["msg"].data())));
|
||||||
|
notifyEngineIll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user