forked from qt-creator/qt-creator
Debugger: Split remote and local attach handlers
Called with different timing, no real shared code currently. Change-Id: I5a8cc32c5f38f533acfa4512518fb51932d8aab2 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -4200,7 +4200,7 @@ void GdbEngine::runEngine()
|
|||||||
const qint64 pid = rp.attachPID.pid();
|
const qint64 pid = rp.attachPID.pid();
|
||||||
showStatusMessage(tr("Attaching to process %1.").arg(pid));
|
showStatusMessage(tr("Attaching to process %1.").arg(pid));
|
||||||
runCommand({"attach " + QString::number(pid),
|
runCommand({"attach " + QString::number(pid),
|
||||||
[this](const DebuggerResponse &r) { handleAttach(r); }});
|
[this](const DebuggerResponse &r) { handleLocalAttach(r); }});
|
||||||
// In some cases we get only output like
|
// In some cases we get only output like
|
||||||
// "Could not attach to process. If your uid matches the uid of the target\n"
|
// "Could not attach to process. If your uid matches the uid of the target\n"
|
||||||
// "process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try\n"
|
// "process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try\n"
|
||||||
@@ -4241,74 +4241,71 @@ void GdbEngine::runEngine()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::handleAttach(const DebuggerResponse &response)
|
void GdbEngine::handleLocalAttach(const DebuggerResponse &response)
|
||||||
{
|
{
|
||||||
if (isLocalAttachEngine()) {
|
QTC_ASSERT(state() == EngineRunRequested || state() == InferiorStopOk, qDebug() << state());
|
||||||
|
switch (response.resultClass) {
|
||||||
QTC_ASSERT(state() == EngineRunRequested || state() == InferiorStopOk, qDebug() << state());
|
case ResultDone:
|
||||||
switch (response.resultClass) {
|
case ResultRunning:
|
||||||
case ResultDone:
|
showMessage("INFERIOR ATTACHED");
|
||||||
case ResultRunning:
|
if (state() == EngineRunRequested) {
|
||||||
showMessage("INFERIOR ATTACHED");
|
// Happens e.g. for "Attach to unstarted application"
|
||||||
if (state() == EngineRunRequested) {
|
// We will get a '*stopped' later that we'll interpret as 'spontaneous'
|
||||||
// Happens e.g. for "Attach to unstarted application"
|
// So acknowledge the current state and put a delayed 'continue' in the pipe.
|
||||||
// We will get a '*stopped' later that we'll interpret as 'spontaneous'
|
showMessage(tr("Attached to running application."), StatusBar);
|
||||||
// So acknowledge the current state and put a delayed 'continue' in the pipe.
|
notifyEngineRunAndInferiorRunOk();
|
||||||
showMessage(tr("Attached to running application."), StatusBar);
|
} else {
|
||||||
notifyEngineRunAndInferiorRunOk();
|
// InferiorStopOk, e.g. for "Attach to running application".
|
||||||
} else {
|
// The *stopped came in between sending the 'attach' and
|
||||||
// InferiorStopOk, e.g. for "Attach to running application".
|
// receiving its '^done'.
|
||||||
// The *stopped came in between sending the 'attach' and
|
notifyEngineRunAndInferiorStopOk();
|
||||||
// receiving its '^done'.
|
if (runParameters().continueAfterAttach)
|
||||||
notifyEngineRunAndInferiorStopOk();
|
continueInferiorInternal();
|
||||||
if (runParameters().continueAfterAttach)
|
else
|
||||||
continueInferiorInternal();
|
updateAll();
|
||||||
else
|
}
|
||||||
updateAll();
|
break;
|
||||||
}
|
case ResultError:
|
||||||
break;
|
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
|
||||||
case ResultError:
|
QString msg = msgPtraceError(runParameters().startMode);
|
||||||
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
|
showStatusMessage(tr("Failed to attach to application: %1").arg(msg));
|
||||||
QString msg = msgPtraceError(runParameters().startMode);
|
AsynchronousMessageBox::warning(tr("Debugger Error"), msg);
|
||||||
showStatusMessage(tr("Failed to attach to application: %1").arg(msg));
|
|
||||||
AsynchronousMessageBox::warning(tr("Debugger Error"), msg);
|
|
||||||
notifyEngineIll();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
showStatusMessage(tr("Failed to attach to application: %1")
|
|
||||||
.arg(QString(response.data["msg"].data())));
|
|
||||||
notifyEngineIll();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
showStatusMessage(tr("Failed to attach to application: %1")
|
|
||||||
.arg(QString(response.data["msg"].data())));
|
|
||||||
notifyEngineIll();
|
notifyEngineIll();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
showStatusMessage(tr("Failed to attach to application: %1")
|
||||||
|
.arg(QString(response.data["msg"].data())));
|
||||||
|
notifyEngineIll();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
showStatusMessage(tr("Failed to attach to application: %1")
|
||||||
|
.arg(QString(response.data["msg"].data())));
|
||||||
|
notifyEngineIll();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (isRemoteEngine()) {
|
void GdbEngine::handleRemoteAttach(const DebuggerResponse &response)
|
||||||
|
{
|
||||||
CHECK_STATE(EngineSetupRequested);
|
CHECK_STATE(EngineSetupRequested);
|
||||||
switch (response.resultClass) {
|
switch (response.resultClass) {
|
||||||
case ResultDone:
|
case ResultDone:
|
||||||
case ResultRunning: {
|
case ResultRunning: {
|
||||||
showMessage("INFERIOR ATTACHED");
|
showMessage("INFERIOR ATTACHED");
|
||||||
showMessage(msgAttachedToStoppedInferior(), StatusBar);
|
showMessage(msgAttachedToStoppedInferior(), StatusBar);
|
||||||
handleInferiorPrepared();
|
handleInferiorPrepared();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ResultError:
|
||||||
|
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
|
||||||
|
notifyInferiorSetupFailedHelper(msgPtraceError(runParameters().startMode));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ResultError:
|
notifyInferiorSetupFailedHelper(response.data["msg"].data());
|
||||||
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
|
break;
|
||||||
notifyInferiorSetupFailedHelper(msgPtraceError(runParameters().startMode));
|
default:
|
||||||
break;
|
notifyInferiorSetupFailedHelper(response.data["msg"].data());
|
||||||
}
|
break;
|
||||||
notifyInferiorSetupFailedHelper(response.data["msg"].data());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
notifyInferiorSetupFailedHelper(response.data["msg"].data());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4548,7 +4545,7 @@ void GdbEngine::handleTargetQnx(const DebuggerResponse &response)
|
|||||||
|
|
||||||
const DebuggerRunParameters &rp = runParameters();
|
const DebuggerRunParameters &rp = runParameters();
|
||||||
if (rp.attachPID.isValid())
|
if (rp.attachPID.isValid())
|
||||||
runCommand({"attach " + QString::number(rp.attachPID.pid()), CB(handleAttach)});
|
runCommand({"attach " + QString::number(rp.attachPID.pid()), CB(handleRemoteAttach)});
|
||||||
else if (!rp.inferior.executable.isEmpty())
|
else if (!rp.inferior.executable.isEmpty())
|
||||||
runCommand({"set nto-executable " + rp.inferior.executable.toString(),
|
runCommand({"set nto-executable " + rp.inferior.executable.toString(),
|
||||||
CB(handleSetNtoExecutable)});
|
CB(handleSetNtoExecutable)});
|
||||||
|
|||||||
@@ -395,7 +395,8 @@ private: ////////// General Interface //////////
|
|||||||
void handleFileExecAndSymbols(const DebuggerResponse &response);
|
void handleFileExecAndSymbols(const DebuggerResponse &response);
|
||||||
|
|
||||||
// Attach
|
// Attach
|
||||||
void handleAttach(const DebuggerResponse &response);
|
void handleLocalAttach(const DebuggerResponse &response);
|
||||||
|
void handleRemoteAttach(const DebuggerResponse &response);
|
||||||
|
|
||||||
// Remote
|
// Remote
|
||||||
void callTargetRemote();
|
void callTargetRemote();
|
||||||
|
|||||||
Reference in New Issue
Block a user