forked from qt-creator/qt-creator
debugger: make startGdb response handling asyncronous
This allows adapters to take all responses from the startup commands into account. Change-Id: I295cb211a4b69cfb8c59b34030aaee8120ffe98e Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -72,6 +72,8 @@ public:
|
|||||||
virtual void write(const QByteArray &data);
|
virtual void write(const QByteArray &data);
|
||||||
|
|
||||||
virtual void startAdapter() = 0;
|
virtual void startAdapter() = 0;
|
||||||
|
virtual void handleGdbStartDone() = 0;
|
||||||
|
virtual void handleGdbStartFailed() = 0;
|
||||||
virtual void setupInferior() = 0;
|
virtual void setupInferior() = 0;
|
||||||
virtual void runEngine() = 0;
|
virtual void runEngine() = 0;
|
||||||
virtual void interruptInferior() = 0;
|
virtual void interruptInferior() = 0;
|
||||||
|
|||||||
@@ -63,13 +63,18 @@ void AttachGdbAdapter::startAdapter()
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
|
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
|
||||||
showMessage(_("TRYING TO START ADAPTER"));
|
showMessage(_("TRYING TO START ADAPTER"));
|
||||||
|
m_engine->startGdb();
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_engine->startGdb())
|
void AttachGdbAdapter::handleGdbStartDone()
|
||||||
return;
|
{
|
||||||
|
|
||||||
m_engine->handleAdapterStarted();
|
m_engine->handleAdapterStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AttachGdbAdapter::handleGdbStartFailed()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void AttachGdbAdapter::setupInferior()
|
void AttachGdbAdapter::setupInferior()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ private:
|
|||||||
DumperHandling dumperHandling() const { return DumperLoadedByGdb; }
|
DumperHandling dumperHandling() const { return DumperLoadedByGdb; }
|
||||||
|
|
||||||
void startAdapter();
|
void startAdapter();
|
||||||
|
void handleGdbStartDone();
|
||||||
|
void handleGdbStartFailed();
|
||||||
void setupInferior();
|
void setupInferior();
|
||||||
void runEngine();
|
void runEngine();
|
||||||
void interruptInferior();
|
void interruptInferior();
|
||||||
|
|||||||
@@ -386,13 +386,19 @@ void CodaGdbAdapter::startGdb()
|
|||||||
{
|
{
|
||||||
QStringList gdbArgs;
|
QStringList gdbArgs;
|
||||||
gdbArgs.append(_("--nx")); // Do not read .gdbinit file
|
gdbArgs.append(_("--nx")); // Do not read .gdbinit file
|
||||||
if (!m_engine->startGdb(gdbArgs)) {
|
m_engine->startGdb(gdbArgs);
|
||||||
cleanup();
|
}
|
||||||
return;
|
|
||||||
}
|
void CodaGdbAdapter::handleGdbStartDone()
|
||||||
|
{
|
||||||
m_engine->handleAdapterStarted();
|
m_engine->handleAdapterStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CodaGdbAdapter::handleGdbStartFailed()
|
||||||
|
{
|
||||||
|
cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
void CodaGdbAdapter::codaDeviceError(const QString &errorString)
|
void CodaGdbAdapter::codaDeviceError(const QString &errorString)
|
||||||
{
|
{
|
||||||
logMessage(errorString);
|
logMessage(errorString);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public:
|
|||||||
typedef Coda::Callback<const GdbResponse &> GdbCallback;
|
typedef Coda::Callback<const GdbResponse &> GdbCallback;
|
||||||
|
|
||||||
explicit CodaGdbAdapter(GdbEngine *engine);
|
explicit CodaGdbAdapter(GdbEngine *engine);
|
||||||
virtual ~CodaGdbAdapter();
|
~CodaGdbAdapter();
|
||||||
void setGdbServerName(const QString &name);
|
void setGdbServerName(const QString &name);
|
||||||
QString gdbServerName() const { return m_gdbServerName; }
|
QString gdbServerName() const { return m_gdbServerName; }
|
||||||
|
|
||||||
@@ -111,6 +111,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
void setupDeviceSignals();
|
void setupDeviceSignals();
|
||||||
void startAdapter();
|
void startAdapter();
|
||||||
|
void handleGdbStartDone();
|
||||||
|
void handleGdbStartFailed();
|
||||||
void setupInferior();
|
void setupInferior();
|
||||||
void runEngine();
|
void runEngine();
|
||||||
void interruptInferior();
|
void interruptInferior();
|
||||||
|
|||||||
@@ -78,9 +78,15 @@ void CoreGdbAdapter::startAdapter()
|
|||||||
QStringList args;
|
QStringList args;
|
||||||
args.append(_("-ex"));
|
args.append(_("-ex"));
|
||||||
args.append(_("set auto-solib-add off"));
|
args.append(_("set auto-solib-add off"));
|
||||||
if (!m_engine->startGdb(args, QString()))
|
m_engine->startGdb(args);
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
void CoreGdbAdapter::handleGdbStartFailed()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoreGdbAdapter::handleGdbStartDone()
|
||||||
|
{
|
||||||
//if (m_executable.isEmpty()) {
|
//if (m_executable.isEmpty()) {
|
||||||
// showMessageBox(QMessageBox::Warning,
|
// showMessageBox(QMessageBox::Warning,
|
||||||
// tr("Error Loading Symbols"),
|
// tr("Error Loading Symbols"),
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ private:
|
|||||||
DumperHandling dumperHandling() const { return DumperNotAvailable; }
|
DumperHandling dumperHandling() const { return DumperNotAvailable; }
|
||||||
|
|
||||||
void startAdapter();
|
void startAdapter();
|
||||||
|
void handleGdbStartDone();
|
||||||
|
void handleGdbStartFailed();
|
||||||
void setupInferior();
|
void setupInferior();
|
||||||
void runEngine();
|
void runEngine();
|
||||||
void interruptInferior();
|
void interruptInferior();
|
||||||
|
|||||||
@@ -4747,7 +4747,7 @@ bool checkGdbConfiguration(const DebuggerStartParameters &sp, ConfigurationCheck
|
|||||||
// Starting up & shutting down
|
// Starting up & shutting down
|
||||||
//
|
//
|
||||||
|
|
||||||
bool GdbEngine::startGdb(const QStringList &args, const QString &settingsIdHint)
|
void GdbEngine::startGdb(const QStringList &args, const QString &settingsIdHint)
|
||||||
{
|
{
|
||||||
const QByteArray tests = qgetenv("QTC_DEBUGGER_TESTS");
|
const QByteArray tests = qgetenv("QTC_DEBUGGER_TESTS");
|
||||||
foreach (const QByteArray &test, tests.split(','))
|
foreach (const QByteArray &test, tests.split(','))
|
||||||
@@ -4760,10 +4760,11 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &settingsIdHint)
|
|||||||
const DebuggerStartParameters &sp = startParameters();
|
const DebuggerStartParameters &sp = startParameters();
|
||||||
m_gdb = gdbBinary(sp);
|
m_gdb = gdbBinary(sp);
|
||||||
if (m_gdb.isEmpty()) {
|
if (m_gdb.isEmpty()) {
|
||||||
|
m_gdbAdapter->handleGdbStartFailed();
|
||||||
handleAdapterStartFailed(
|
handleAdapterStartFailed(
|
||||||
msgNoGdbBinaryForToolChain(sp.toolChainAbi),
|
msgNoGdbBinaryForToolChain(sp.toolChainAbi),
|
||||||
_(Constants::DEBUGGER_COMMON_SETTINGS_ID));
|
_(Constants::DEBUGGER_COMMON_SETTINGS_ID));
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
QStringList gdbArgs;
|
QStringList gdbArgs;
|
||||||
gdbArgs << _("-i");
|
gdbArgs << _("-i");
|
||||||
@@ -4785,9 +4786,10 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &settingsIdHint)
|
|||||||
gdbProc()->start(m_gdb, gdbArgs);
|
gdbProc()->start(m_gdb, gdbArgs);
|
||||||
|
|
||||||
if (!gdbProc()->waitForStarted()) {
|
if (!gdbProc()->waitForStarted()) {
|
||||||
|
m_gdbAdapter->handleGdbStartFailed();
|
||||||
const QString msg = errorMessage(QProcess::FailedToStart);
|
const QString msg = errorMessage(QProcess::FailedToStart);
|
||||||
handleAdapterStartFailed(msg, settingsIdHint);
|
handleAdapterStartFailed(msg, settingsIdHint);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
showMessage(_("GDB STARTED, INITIALIZING IT"));
|
showMessage(_("GDB STARTED, INITIALIZING IT"));
|
||||||
@@ -4845,7 +4847,6 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &settingsIdHint)
|
|||||||
//postCommand(_("handle SIGTERM pass nostop print"));
|
//postCommand(_("handle SIGTERM pass nostop print"));
|
||||||
|
|
||||||
postCommand("set unwindonsignal on");
|
postCommand("set unwindonsignal on");
|
||||||
postCommand("pwd");
|
|
||||||
postCommand("set width 0");
|
postCommand("set width 0");
|
||||||
postCommand("set height 0");
|
postCommand("set height 0");
|
||||||
|
|
||||||
@@ -4861,6 +4862,8 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &settingsIdHint)
|
|||||||
postCommand("maintenance set internal-warning quit no", ConsoleCommand);
|
postCommand("maintenance set internal-warning quit no", ConsoleCommand);
|
||||||
postCommand("maintenance set internal-error quit no", ConsoleCommand);
|
postCommand("maintenance set internal-error quit no", ConsoleCommand);
|
||||||
|
|
||||||
|
showMessage(_("THE FOLLOWING COMMAND CHECKS AVAILABLE FEATURES. "
|
||||||
|
"AN ERROR IS EXPECTED."));
|
||||||
postCommand("disassemble 0 0", ConsoleCommand, CB(handleDisassemblerCheck));
|
postCommand("disassemble 0 0", ConsoleCommand, CB(handleDisassemblerCheck));
|
||||||
|
|
||||||
if (attemptQuickStart()) {
|
if (attemptQuickStart()) {
|
||||||
@@ -4871,7 +4874,14 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &settingsIdHint)
|
|||||||
loadPythonDumpers();
|
loadPythonDumpers();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
// Dummy command to guarantee a roundtrip before the adapter proceed.
|
||||||
|
postCommand("pwd", ConsoleCommand, CB(handleGdbStart));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GdbEngine::handleGdbStart(const GdbResponse &response)
|
||||||
|
{
|
||||||
|
Q_UNUSED(response);
|
||||||
|
m_gdbAdapter->handleGdbStartDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::loadInitScript()
|
void GdbEngine::loadInitScript()
|
||||||
|
|||||||
@@ -249,8 +249,9 @@ private: ////////// General State //////////
|
|||||||
private: ////////// Gdb Process Management //////////
|
private: ////////// Gdb Process Management //////////
|
||||||
|
|
||||||
AbstractGdbAdapter *createAdapter();
|
AbstractGdbAdapter *createAdapter();
|
||||||
bool startGdb(const QStringList &args = QStringList(),
|
void startGdb(const QStringList &args = QStringList(),
|
||||||
const QString &settingsIdHint = QString());
|
const QString &settingsIdHint = QString());
|
||||||
|
void handleGdbStart(const GdbResponse &response);
|
||||||
void handleInferiorShutdown(const GdbResponse &response);
|
void handleInferiorShutdown(const GdbResponse &response);
|
||||||
void handleGdbExit(const GdbResponse &response);
|
void handleGdbExit(const GdbResponse &response);
|
||||||
void handleRemoteSetupDone(int gdbServerPort, int qmlPort);
|
void handleRemoteSetupDone(int gdbServerPort, int qmlPort);
|
||||||
|
|||||||
@@ -93,14 +93,19 @@ void LocalPlainGdbAdapter::startAdapter()
|
|||||||
if (startParameters().environment.size())
|
if (startParameters().environment.size())
|
||||||
m_gdbProc.setEnvironment(startParameters().environment.toStringList());
|
m_gdbProc.setEnvironment(startParameters().environment.toStringList());
|
||||||
|
|
||||||
if (!m_engine->startGdb(gdbArgs)) {
|
m_engine->startGdb(gdbArgs);
|
||||||
m_outputCollector.shutdown();
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void LocalPlainGdbAdapter::handleGdbStartDone()
|
||||||
|
{
|
||||||
m_engine->handleAdapterStarted();
|
m_engine->handleAdapterStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalPlainGdbAdapter::handleGdbStartFailed()
|
||||||
|
{
|
||||||
|
m_outputCollector.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
void LocalPlainGdbAdapter::setupInferior()
|
void LocalPlainGdbAdapter::setupInferior()
|
||||||
{
|
{
|
||||||
AbstractPlainGdbAdapter::setupInferior();
|
AbstractPlainGdbAdapter::setupInferior();
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void startAdapter();
|
void startAdapter();
|
||||||
|
void handleGdbStartDone();
|
||||||
|
void handleGdbStartFailed();
|
||||||
void setupInferior();
|
void setupInferior();
|
||||||
void runEngine();
|
void runEngine();
|
||||||
void interruptInferior();
|
void interruptInferior();
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ void RemoteGdbServerAdapter::startAdapter()
|
|||||||
if (startParameters().requestRemoteSetup)
|
if (startParameters().requestRemoteSetup)
|
||||||
m_engine->notifyEngineRequestRemoteSetup();
|
m_engine->notifyEngineRequestRemoteSetup();
|
||||||
else
|
else
|
||||||
handleSetupDone();
|
m_engine->startGdb();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteGdbServerAdapter::uploadProcError(QProcess::ProcessError error)
|
void RemoteGdbServerAdapter::uploadProcError(QProcess::ProcessError error)
|
||||||
@@ -155,7 +155,7 @@ void RemoteGdbServerAdapter::uploadProcFinished()
|
|||||||
{
|
{
|
||||||
if (m_uploadProc.exitStatus() == QProcess::NormalExit
|
if (m_uploadProc.exitStatus() == QProcess::NormalExit
|
||||||
&& m_uploadProc.exitCode() == 0)
|
&& m_uploadProc.exitCode() == 0)
|
||||||
handleSetupDone();
|
m_engine->startGdb();
|
||||||
else
|
else
|
||||||
handleRemoteSetupFailed(m_uploadProc.errorString());
|
handleRemoteSetupFailed(m_uploadProc.errorString());
|
||||||
}
|
}
|
||||||
@@ -401,13 +401,16 @@ void RemoteGdbServerAdapter::handleRemoteSetupDone(int gdbServerPort, int qmlPor
|
|||||||
QString::number(gdbServerPort));
|
QString::number(gdbServerPort));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleSetupDone();
|
m_engine->startGdb();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteGdbServerAdapter::handleSetupDone()
|
void RemoteGdbServerAdapter::handleGdbStartDone()
|
||||||
|
{
|
||||||
|
m_engine->handleAdapterStarted();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoteGdbServerAdapter::handleGdbStartFailed()
|
||||||
{
|
{
|
||||||
if (m_engine->startGdb())
|
|
||||||
m_engine->handleAdapterStarted();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteGdbServerAdapter::handleRemoteSetupFailed(const QString &reason)
|
void RemoteGdbServerAdapter::handleRemoteSetupFailed(const QString &reason)
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ private:
|
|||||||
DumperHandling dumperHandling() const;
|
DumperHandling dumperHandling() const;
|
||||||
|
|
||||||
void startAdapter();
|
void startAdapter();
|
||||||
|
void handleGdbStartDone();
|
||||||
|
void handleGdbStartFailed();
|
||||||
void setupInferior();
|
void setupInferior();
|
||||||
void runEngine();
|
void runEngine();
|
||||||
void interruptInferior();
|
void interruptInferior();
|
||||||
@@ -63,8 +65,6 @@ private:
|
|||||||
|
|
||||||
AbstractGdbProcess *gdbProc() { return &m_gdbProc; }
|
AbstractGdbProcess *gdbProc() { return &m_gdbProc; }
|
||||||
|
|
||||||
void handleSetupDone();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/*
|
/*
|
||||||
* For "external" clients of a debugger run control that need to do
|
* For "external" clients of a debugger run control that need to do
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ RemotePlainGdbAdapter::RemotePlainGdbAdapter(GdbEngine *engine)
|
|||||||
{
|
{
|
||||||
connect(&m_gdbProc, SIGNAL(started()), this, SLOT(handleGdbStarted()));
|
connect(&m_gdbProc, SIGNAL(started()), this, SLOT(handleGdbStarted()));
|
||||||
connect(&m_gdbProc, SIGNAL(startFailed()), this,
|
connect(&m_gdbProc, SIGNAL(startFailed()), this,
|
||||||
SLOT(handleGdbStartFailed()));
|
SLOT(handleGdbStartFailed1()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemotePlainGdbAdapter::startAdapter()
|
void RemotePlainGdbAdapter::startAdapter()
|
||||||
@@ -117,11 +117,19 @@ void RemotePlainGdbAdapter::handleRemoteSetupDone(int gdbServerPort, int qmlPort
|
|||||||
|
|
||||||
void RemotePlainGdbAdapter::handleGdbStarted()
|
void RemotePlainGdbAdapter::handleGdbStarted()
|
||||||
{
|
{
|
||||||
if (m_engine->startGdb())
|
m_engine->startGdb();
|
||||||
m_engine->handleAdapterStarted();
|
}
|
||||||
|
|
||||||
|
void RemotePlainGdbAdapter::handleGdbStartDone()
|
||||||
|
{
|
||||||
|
m_engine->handleAdapterStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemotePlainGdbAdapter::handleGdbStartFailed()
|
void RemotePlainGdbAdapter::handleGdbStartFailed()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemotePlainGdbAdapter::handleGdbStartFailed1()
|
||||||
{
|
{
|
||||||
m_engine->handleAdapterStartFailed(m_gdbProc.errorString());
|
m_engine->handleAdapterStartFailed(m_gdbProc.errorString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,10 +49,12 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleGdbStarted();
|
void handleGdbStarted();
|
||||||
void handleGdbStartFailed();
|
void handleGdbStartFailed1();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void startAdapter();
|
void startAdapter();
|
||||||
|
void handleGdbStartDone();
|
||||||
|
void handleGdbStartFailed();
|
||||||
void setupInferior();
|
void setupInferior();
|
||||||
void interruptInferior();
|
void interruptInferior();
|
||||||
void shutdownAdapter();
|
void shutdownAdapter();
|
||||||
|
|||||||
@@ -119,10 +119,16 @@ void TermGdbAdapter::startAdapter()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_engine->startGdb()) {
|
m_engine->startGdb();
|
||||||
m_stubProc.stop();
|
}
|
||||||
return;
|
|
||||||
}
|
void TermGdbAdapter::handleGdbStartDone()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TermGdbAdapter::handleGdbStartFailed()
|
||||||
|
{
|
||||||
|
m_stubProc.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TermGdbAdapter::handleInferiorSetupOk()
|
void TermGdbAdapter::handleInferiorSetupOk()
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ private:
|
|||||||
DumperHandling dumperHandling() const;
|
DumperHandling dumperHandling() const;
|
||||||
|
|
||||||
void startAdapter();
|
void startAdapter();
|
||||||
|
void handleGdbStartDone();
|
||||||
|
void handleGdbStartFailed();
|
||||||
void setupInferior();
|
void setupInferior();
|
||||||
void runEngine();
|
void runEngine();
|
||||||
void interruptInferior();
|
void interruptInferior();
|
||||||
|
|||||||
Reference in New Issue
Block a user