forked from qt-creator/qt-creator
fix initial breakpoint setting
as it turns out, it is not possible to set pending breakpoints until gdb has loaded as image. so add some hooks to enable adapters to trigger the initial breakpoint syncing at the right time. do not add additional states (say, InferiorPreparing), as it would just complicate things.
This commit is contained in:
@@ -51,6 +51,10 @@ void AbstractGdbAdapter::shutdown()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AbstractGdbAdapter::startInferiorPhase2()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
const char *AbstractGdbAdapter::inferiorShutdownCommand() const
|
const char *AbstractGdbAdapter::inferiorShutdownCommand() const
|
||||||
{
|
{
|
||||||
return "kill";
|
return "kill";
|
||||||
|
@@ -56,6 +56,7 @@ public:
|
|||||||
|
|
||||||
virtual void startAdapter() = 0;
|
virtual void startAdapter() = 0;
|
||||||
virtual void startInferior() = 0;
|
virtual void startInferior() = 0;
|
||||||
|
virtual void startInferiorPhase2();
|
||||||
virtual void interruptInferior() = 0;
|
virtual void interruptInferior() = 0;
|
||||||
virtual void shutdown();
|
virtual void shutdown();
|
||||||
virtual const char *inferiorShutdownCommand() const;
|
virtual const char *inferiorShutdownCommand() const;
|
||||||
@@ -80,6 +81,10 @@ signals:
|
|||||||
// Make sure to clean up everything before emitting this signal.
|
// Make sure to clean up everything before emitting this signal.
|
||||||
void adapterCrashed(const QString &msg);
|
void adapterCrashed(const QString &msg);
|
||||||
|
|
||||||
|
// This triggers the initial breakpoint synchronization and causes
|
||||||
|
// startInferiorPhase2() being called once done.
|
||||||
|
void inferiorPrepared();
|
||||||
|
|
||||||
// The adapter is still running just fine, but it failed to acquire a debuggee.
|
// The adapter is still running just fine, but it failed to acquire a debuggee.
|
||||||
void inferiorStartFailed(const QString &msg);
|
void inferiorStartFailed(const QString &msg);
|
||||||
|
|
||||||
|
@@ -82,6 +82,7 @@ void AttachGdbAdapter::handleAttach(const GdbResponse &response)
|
|||||||
QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
|
QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
|
||||||
debugMessage(_("INFERIOR ATTACHED"));
|
debugMessage(_("INFERIOR ATTACHED"));
|
||||||
showStatusMessage(msgAttachedToStoppedInferior());
|
showStatusMessage(msgAttachedToStoppedInferior());
|
||||||
|
emit inferiorPrepared();
|
||||||
m_engine->updateAll();
|
m_engine->updateAll();
|
||||||
} else {
|
} else {
|
||||||
QString msg = __(response.data.findChild("msg").data());
|
QString msg = __(response.data.findChild("msg").data());
|
||||||
|
@@ -234,6 +234,9 @@ void GdbEngine::connectAdapter()
|
|||||||
connect(m_gdbAdapter, SIGNAL(adapterStartFailed(QString,QString)),
|
connect(m_gdbAdapter, SIGNAL(adapterStartFailed(QString,QString)),
|
||||||
this, SLOT(handleAdapterStartFailed(QString,QString)));
|
this, SLOT(handleAdapterStartFailed(QString,QString)));
|
||||||
|
|
||||||
|
connect(m_gdbAdapter, SIGNAL(inferiorPrepared()),
|
||||||
|
this, SLOT(handleInferiorPrepared()));
|
||||||
|
|
||||||
connect(m_gdbAdapter, SIGNAL(inferiorStartFailed(QString)),
|
connect(m_gdbAdapter, SIGNAL(inferiorStartFailed(QString)),
|
||||||
this, SLOT(handleInferiorStartFailed(QString)));
|
this, SLOT(handleInferiorStartFailed(QString)));
|
||||||
|
|
||||||
@@ -692,7 +695,8 @@ void GdbEngine::postCommandHelper(const GdbCommand &cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cmd.flags & NeedsStop) {
|
if (cmd.flags & NeedsStop) {
|
||||||
if (state() == InferiorStopped || state() == AdapterStarted) {
|
if (state() == InferiorStopped
|
||||||
|
|| state() == InferiorStarting || state() == AdapterStarted) {
|
||||||
// Can be safely sent now.
|
// Can be safely sent now.
|
||||||
flushCommand(cmd);
|
flushCommand(cmd);
|
||||||
} else {
|
} else {
|
||||||
@@ -4318,24 +4322,29 @@ void GdbEngine::handleAdapterStarted()
|
|||||||
setState(AdapterStarted);
|
setState(AdapterStarted);
|
||||||
debugMessage(_("ADAPTER SUCCESSFULLY STARTED"));
|
debugMessage(_("ADAPTER SUCCESSFULLY STARTED"));
|
||||||
|
|
||||||
|
showStatusMessage(tr("Starting inferior..."));
|
||||||
|
setState(InferiorStarting);
|
||||||
|
m_gdbAdapter->startInferior();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GdbEngine::handleInferiorPrepared()
|
||||||
|
{
|
||||||
// Initial attempt to set breakpoints
|
// Initial attempt to set breakpoints
|
||||||
showStatusMessage(tr("Setting breakpoints..."));
|
showStatusMessage(tr("Setting breakpoints..."));
|
||||||
attemptBreakpointSynchronization();
|
attemptBreakpointSynchronization();
|
||||||
|
|
||||||
if (m_cookieForToken.isEmpty()) {
|
if (m_cookieForToken.isEmpty()) {
|
||||||
startInferior();
|
startInferiorPhase2();
|
||||||
} else {
|
} else {
|
||||||
QTC_ASSERT(m_commandsDoneCallback == 0, /**/);
|
QTC_ASSERT(m_commandsDoneCallback == 0, /**/);
|
||||||
m_commandsDoneCallback = &GdbEngine::startInferior;
|
m_commandsDoneCallback = &GdbEngine::startInferiorPhase2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::startInferior()
|
void GdbEngine::startInferiorPhase2()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
|
debugMessage(_("BREAKPOINTS SET, CONTINUING INFERIOR STARTUP"));
|
||||||
showStatusMessage(tr("Starting inferior..."));
|
m_gdbAdapter->startInferiorPhase2();
|
||||||
setState(InferiorStarting);
|
|
||||||
m_gdbAdapter->startInferior();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::handleInferiorStartFailed(const QString &msg)
|
void GdbEngine::handleInferiorStartFailed(const QString &msg)
|
||||||
|
@@ -126,7 +126,7 @@ private: ////////// Gdb Process Management //////////
|
|||||||
AbstractGdbAdapter *createAdapter(const DebuggerStartParametersPtr &dp);
|
AbstractGdbAdapter *createAdapter(const DebuggerStartParametersPtr &dp);
|
||||||
void connectAdapter();
|
void connectAdapter();
|
||||||
bool startGdb(const QStringList &args = QStringList(), const QString &gdb = QString());
|
bool startGdb(const QStringList &args = QStringList(), const QString &gdb = QString());
|
||||||
void startInferior();
|
void startInferiorPhase2();
|
||||||
|
|
||||||
void handleInferiorShutdown(const GdbResponse &response);
|
void handleInferiorShutdown(const GdbResponse &response);
|
||||||
void handleGdbExit(const GdbResponse &response);
|
void handleGdbExit(const GdbResponse &response);
|
||||||
@@ -146,6 +146,8 @@ private slots:
|
|||||||
void handleAdapterStarted();
|
void handleAdapterStarted();
|
||||||
void handleAdapterStartFailed(const QString &msg, const QString &settingsIdHint = QString());
|
void handleAdapterStartFailed(const QString &msg, const QString &settingsIdHint = QString());
|
||||||
|
|
||||||
|
void handleInferiorPrepared();
|
||||||
|
|
||||||
void handleInferiorStartFailed(const QString &msg);
|
void handleInferiorStartFailed(const QString &msg);
|
||||||
|
|
||||||
void handleAdapterCrashed(const QString &msg);
|
void handleAdapterCrashed(const QString &msg);
|
||||||
|
@@ -106,9 +106,7 @@ void PlainGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
//m_breakHandler->clearBreakMarkers();
|
emit inferiorPrepared();
|
||||||
setState(InferiorRunningRequested);
|
|
||||||
m_engine->postCommand(_("-exec-run"), GdbEngine::RunRequest, CB(handleExecRun));
|
|
||||||
} else {
|
} else {
|
||||||
QString msg = tr("Starting executable failed:\n") +
|
QString msg = tr("Starting executable failed:\n") +
|
||||||
__(response.data.findChild("msg").data());
|
__(response.data.findChild("msg").data());
|
||||||
@@ -116,6 +114,12 @@ void PlainGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlainGdbAdapter::startInferiorPhase2()
|
||||||
|
{
|
||||||
|
setState(InferiorRunningRequested);
|
||||||
|
m_engine->postCommand(_("-exec-run"), GdbEngine::RunRequest, CB(handleExecRun));
|
||||||
|
}
|
||||||
|
|
||||||
void PlainGdbAdapter::handleExecRun(const GdbResponse &response)
|
void PlainGdbAdapter::handleExecRun(const GdbResponse &response)
|
||||||
{
|
{
|
||||||
if (response.resultClass == GdbResultRunning) {
|
if (response.resultClass == GdbResultRunning) {
|
||||||
|
@@ -57,6 +57,7 @@ public:
|
|||||||
|
|
||||||
void startAdapter();
|
void startAdapter();
|
||||||
void startInferior();
|
void startInferior();
|
||||||
|
void startInferiorPhase2();
|
||||||
void interruptInferior();
|
void interruptInferior();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
const char *inferiorShutdownCommand() const { return "kill"; }
|
const char *inferiorShutdownCommand() const { return "kill"; }
|
||||||
|
@@ -199,7 +199,7 @@ void RemoteGdbAdapter::handleTargetRemote(const GdbResponse &record)
|
|||||||
// gdb server will stop the remote application itself.
|
// gdb server will stop the remote application itself.
|
||||||
debugMessage(_("INFERIOR STARTED"));
|
debugMessage(_("INFERIOR STARTED"));
|
||||||
showStatusMessage(msgAttachedToStoppedInferior());
|
showStatusMessage(msgAttachedToStoppedInferior());
|
||||||
m_engine->continueInferior();
|
emit inferiorPrepared();
|
||||||
} else {
|
} else {
|
||||||
// 16^error,msg="hd:5555: Connection timed out."
|
// 16^error,msg="hd:5555: Connection timed out."
|
||||||
QString msg = msgConnectRemoteServerFailed(__(record.data.findChild("msg").data()));
|
QString msg = msgConnectRemoteServerFailed(__(record.data.findChild("msg").data()));
|
||||||
@@ -207,6 +207,11 @@ void RemoteGdbAdapter::handleTargetRemote(const GdbResponse &record)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoteGdbAdapter::startInferiorPhase2()
|
||||||
|
{
|
||||||
|
m_engine->continueInferior();
|
||||||
|
}
|
||||||
|
|
||||||
void RemoteGdbAdapter::interruptInferior()
|
void RemoteGdbAdapter::interruptInferior()
|
||||||
{
|
{
|
||||||
m_engine->postCommand(_("-exec-interrupt"));
|
m_engine->postCommand(_("-exec-interrupt"));
|
||||||
|
@@ -56,6 +56,7 @@ public:
|
|||||||
|
|
||||||
void startAdapter();
|
void startAdapter();
|
||||||
void startInferior();
|
void startInferior();
|
||||||
|
void startInferiorPhase2();
|
||||||
void interruptInferior();
|
void interruptInferior();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
@@ -1639,8 +1639,7 @@ void TrkGdbAdapter::handleTargetRemote(const GdbResponse &record)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||||
if (record.resultClass == GdbResultDone) {
|
if (record.resultClass == GdbResultDone) {
|
||||||
setState(InferiorRunningRequested);
|
emit inferiorPrepared();
|
||||||
m_engine->postCommand(_("-exec-continue"), GdbEngine::RunRequest, CB(handleFirstContinue));
|
|
||||||
} else {
|
} else {
|
||||||
QString msg = tr("Connecting to trk server adapter failed:\n")
|
QString msg = tr("Connecting to trk server adapter failed:\n")
|
||||||
+ _(record.data.findChild("msg").data());
|
+ _(record.data.findChild("msg").data());
|
||||||
@@ -1648,6 +1647,12 @@ void TrkGdbAdapter::handleTargetRemote(const GdbResponse &record)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrkGdbAdapter::startInferiorPhase2()
|
||||||
|
{
|
||||||
|
setState(InferiorRunningRequested);
|
||||||
|
m_engine->postCommand(_("-exec-continue"), GdbEngine::RunRequest, CB(handleFirstContinue));
|
||||||
|
}
|
||||||
|
|
||||||
void TrkGdbAdapter::handleFirstContinue(const GdbResponse &record)
|
void TrkGdbAdapter::handleFirstContinue(const GdbResponse &record)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state() == InferiorRunning, qDebug() << state());
|
QTC_ASSERT(state() == InferiorRunning, qDebug() << state());
|
||||||
|
@@ -170,6 +170,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void startAdapter();
|
void startAdapter();
|
||||||
void startInferior();
|
void startInferior();
|
||||||
|
void startInferiorPhase2();
|
||||||
void interruptInferior();
|
void interruptInferior();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user