forked from qt-creator/qt-creator
Debugger: Merge GDB/LLDB process error handling
This also removes some of the "illegal" state transitions, partially addressing QTCREATORBUG-14089. Change-Id: I817d87a0b5e0a40285bc9b0880fef5bceaee3f16 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -1178,6 +1178,38 @@ void DebuggerEngine::notifyInferiorExited()
|
||||
d->queueShutdownEngine();
|
||||
}
|
||||
|
||||
void DebuggerEngine::notifyDebuggerProcessFinished(int exitCode,
|
||||
QProcess::ExitStatus exitStatus, const QString &backendName)
|
||||
{
|
||||
showMessage(_("%1 PROCESS FINISHED, status %2, exit code %3")
|
||||
.arg(backendName).arg(exitStatus).arg(exitCode));
|
||||
|
||||
switch (state()) {
|
||||
case DebuggerFinished:
|
||||
// Nothing to do.
|
||||
break;
|
||||
case EngineShutdownRequested:
|
||||
notifyEngineShutdownOk();
|
||||
break;
|
||||
case InferiorRunOk:
|
||||
// This could either be a real gdb/lldb crash or a quickly exited inferior
|
||||
// in the terminal adapter. In this case the stub proc will die soon,
|
||||
// too, so there's no need to act here.
|
||||
showMessage(_("The %1 process exited somewhat unexpectedly.").arg(backendName));
|
||||
notifyEngineSpontaneousShutdown();
|
||||
break;
|
||||
default: {
|
||||
notifyEngineIll(); // Initiate shutdown sequence
|
||||
const QString msg = exitStatus == QProcess::CrashExit ?
|
||||
tr("The %1 process terminated.") :
|
||||
tr("The %2 process terminated unexpectedly (exitCode %1)").arg(exitCode);
|
||||
AsynchronousMessageBox::critical(tr("Unexpected %1 Exit").arg(backendName),
|
||||
msg.arg(backendName));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerEngine::slaveEngineStateChanged(DebuggerEngine *slaveEngine,
|
||||
DebuggerState state)
|
||||
{
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "debuggerconstants.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QDebug;
|
||||
@@ -313,6 +314,8 @@ protected:
|
||||
|
||||
public:
|
||||
virtual void notifyInferiorExited();
|
||||
void notifyDebuggerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus,
|
||||
const QString &backendName);
|
||||
|
||||
protected:
|
||||
virtual void notifyInferiorShutdownOk();
|
||||
|
||||
@@ -4366,33 +4366,12 @@ void GdbEngine::handleGdbError(QProcess::ProcessError error)
|
||||
}
|
||||
}
|
||||
|
||||
void GdbEngine::handleGdbFinished(int code, QProcess::ExitStatus type)
|
||||
void GdbEngine::handleGdbFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
if (m_commandTimer.isActive())
|
||||
m_commandTimer.stop();
|
||||
|
||||
showMessage(_("GDB PROCESS FINISHED, status %1, code %2").arg(type).arg(code));
|
||||
|
||||
switch (state()) {
|
||||
case EngineShutdownRequested:
|
||||
notifyEngineShutdownOk();
|
||||
break;
|
||||
case InferiorRunOk:
|
||||
// This could either be a real gdb crash or a quickly exited inferior
|
||||
// in the terminal adapter. In this case the stub proc will die soon,
|
||||
// too, so there's no need to act here.
|
||||
showMessage(_("The gdb process exited somewhat unexpectedly."));
|
||||
notifyEngineSpontaneousShutdown();
|
||||
break;
|
||||
default: {
|
||||
notifyEngineIll(); // Initiate shutdown sequence
|
||||
const QString msg = type == QProcess::CrashExit ?
|
||||
tr("The gdb process terminated.") :
|
||||
tr("The gdb process terminated unexpectedly (code %1)").arg(code);
|
||||
AsynchronousMessageBox::critical(tr("Unexpected GDB Exit"), msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
notifyDebuggerProcessFinished(exitCode, exitStatus, QLatin1String("GDB"));
|
||||
}
|
||||
|
||||
void GdbEngine::abortDebugger()
|
||||
|
||||
@@ -132,7 +132,7 @@ protected: ////////// Gdb Process Management //////////
|
||||
private slots:
|
||||
friend class GdbPlainEngine;
|
||||
void handleInterruptDeviceInferior(const QString &error);
|
||||
void handleGdbFinished(int, QProcess::ExitStatus status);
|
||||
void handleGdbFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void handleGdbError(QProcess::ProcessError error);
|
||||
void readDebugeeOutput(const QByteArray &data);
|
||||
void readGdbStandardOutput();
|
||||
|
||||
@@ -903,8 +903,7 @@ void LldbEngine::doUpdateLocals(UpdateParameters params)
|
||||
|
||||
void LldbEngine::handleLldbError(QProcess::ProcessError error)
|
||||
{
|
||||
qDebug() << "HANDLE LLDB ERROR";
|
||||
showMessage(_("HANDLE LLDB ERROR"));
|
||||
showMessage(_("LLDB PROCESS ERROR: %1").arg(error));
|
||||
switch (error) {
|
||||
case QProcess::Crashed:
|
||||
break; // will get a processExited() as well
|
||||
@@ -947,11 +946,9 @@ QString LldbEngine::errorMessage(QProcess::ProcessError error) const
|
||||
}
|
||||
}
|
||||
|
||||
void LldbEngine::handleLldbFinished(int code, QProcess::ExitStatus type)
|
||||
void LldbEngine::handleLldbFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
qDebug() << "LLDB FINISHED";
|
||||
showMessage(_("LLDB PROCESS FINISHED, status %1, code %2").arg(type).arg(code));
|
||||
notifyEngineSpontaneousShutdown();
|
||||
notifyDebuggerProcessFinished(exitCode, exitStatus, QLatin1String("LLDB"));
|
||||
}
|
||||
|
||||
void LldbEngine::readLldbStandardError()
|
||||
|
||||
@@ -134,7 +134,7 @@ private:
|
||||
QString errorMessage(QProcess::ProcessError error) const;
|
||||
bool hasCapability(unsigned cap) const;
|
||||
|
||||
void handleLldbFinished(int, QProcess::ExitStatus status);
|
||||
void handleLldbFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void handleLldbError(QProcess::ProcessError error);
|
||||
void readLldbStandardOutput();
|
||||
void readLldbStandardError();
|
||||
|
||||
Reference in New Issue
Block a user