forked from qt-creator/qt-creator
debugger: introduce an explicit detach action
This commit is contained in:
@@ -1245,15 +1245,6 @@ void DebuggerManager::setStatus(int status)
|
||||
const bool ready = status == DebuggerInferiorStopped
|
||||
&& startMode() != AttachCore;
|
||||
|
||||
// FIXME
|
||||
// m_startExternalAction->setEnabled(!started && !starting);
|
||||
// m_attachExternalAction->setEnabled(!started && !starting);
|
||||
//#ifdef Q_OS_WIN
|
||||
// m_attachCoreAction->setEnabled(false);
|
||||
//#else
|
||||
// m_attachCoreAction->setEnabled(!started && !starting);
|
||||
//#endif
|
||||
// m_attachRemoteAction->setEnabled(!started && !starting);
|
||||
m_watchAction->setEnabled(ready);
|
||||
m_breakAction->setEnabled(true);
|
||||
|
||||
@@ -1316,6 +1307,12 @@ void DebuggerManager::continueExec()
|
||||
m_engine->continueInferior();
|
||||
}
|
||||
|
||||
void DebuggerManager::detachDebugger()
|
||||
{
|
||||
if (m_engine)
|
||||
m_engine->detachDebugger();
|
||||
}
|
||||
|
||||
void DebuggerManager::interruptDebuggingRequest()
|
||||
{
|
||||
if (Debugger::Constants::Internal::debug)
|
||||
|
||||
@@ -242,6 +242,7 @@ public slots:
|
||||
void stepIExec();
|
||||
void nextIExec();
|
||||
void continueExec();
|
||||
void detachDebugger();
|
||||
|
||||
void addToWatchWindow();
|
||||
void updateWatchModel();
|
||||
|
||||
@@ -100,6 +100,7 @@ const char * const STARTEXTERNAL = "Debugger.StartExternal";
|
||||
const char * const ATTACHEXTERNAL = "Debugger.AttachExternal";
|
||||
const char * const ATTACHCORE = "Debugger.AttachCore";
|
||||
const char * const ATTACHREMOTE = "Debugger.AttachRemote";
|
||||
const char * const DETACH = "Debugger.Detach";
|
||||
|
||||
const char * const RUN_TO_LINE = "Debugger.RunToLine";
|
||||
const char * const RUN_TO_FUNCTION = "Debugger.RunToFunction";
|
||||
@@ -486,6 +487,11 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
||||
this, SLOT(startRemoteApplication()));
|
||||
|
||||
|
||||
m_detachAction = new QAction(this);
|
||||
m_detachAction->setText(tr("Detach debugger"));
|
||||
connect(m_detachAction, SIGNAL(triggered()),
|
||||
m_manager, SLOT(detachDebugger()));
|
||||
|
||||
Core::ActionContainer *mdebug =
|
||||
am->actionContainer(ProjectExplorer::Constants::M_DEBUG);
|
||||
|
||||
@@ -508,6 +514,11 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
||||
|
||||
cmd = am->registerAction(m_manager->m_continueAction,
|
||||
ProjectExplorer::Constants::DEBUG, QList<int>() << m_gdbRunningContext);
|
||||
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
|
||||
|
||||
cmd = am->registerAction(m_detachAction,
|
||||
Constants::DETACH, globalcontext);
|
||||
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
|
||||
|
||||
cmd = am->registerAction(m_manager->m_stopAction,
|
||||
Constants::INTERRUPT, globalcontext);
|
||||
@@ -783,6 +794,9 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
||||
this, SLOT(activatePreviousMode()));
|
||||
connect(m_manager, SIGNAL(debugModeRequested()),
|
||||
this, SLOT(activateDebugMode()));
|
||||
connect(m_manager, SIGNAL(statusChanged(int)),
|
||||
this, SLOT(updateActions(int)));
|
||||
|
||||
|
||||
connect(theDebuggerAction(SettingsDialog), SIGNAL(triggered()),
|
||||
this, SLOT(showSettingsDialog()));
|
||||
@@ -1095,6 +1109,28 @@ void DebuggerPlugin::startRemoteApplication()
|
||||
runControl->start();
|
||||
}
|
||||
|
||||
void DebuggerPlugin::updateActions(int status)
|
||||
{
|
||||
const bool started = status == DebuggerInferiorRunning
|
||||
|| status == DebuggerInferiorRunningRequested
|
||||
|| status == DebuggerInferiorStopRequested
|
||||
|| status == DebuggerInferiorStopped;
|
||||
|
||||
const bool starting = status == DebuggerProcessStartingUp;
|
||||
//const bool running = status == DebuggerInferiorRunning;
|
||||
|
||||
const bool ready = status == DebuggerInferiorStopped
|
||||
&& m_manager->startMode() != AttachCore;
|
||||
m_startExternalAction->setEnabled(!started && !starting);
|
||||
m_attachExternalAction->setEnabled(!started && !starting);
|
||||
#ifdef Q_OS_WIN
|
||||
m_attachCoreAction->setEnabled(false);
|
||||
#else
|
||||
m_attachCoreAction->setEnabled(!started && !starting);
|
||||
#endif
|
||||
m_startRemoteAction->setEnabled(!started && !starting);
|
||||
m_detachAction->setEnabled(ready);
|
||||
}
|
||||
|
||||
#include "debuggerplugin.moc"
|
||||
|
||||
|
||||
@@ -88,6 +88,8 @@ private slots:
|
||||
void setConfigValue(const QString &name, const QVariant &value);
|
||||
void requestContextMenu(TextEditor::ITextEditor *editor,
|
||||
int lineNumber, QMenu *menu);
|
||||
void updateActions(int status);
|
||||
|
||||
|
||||
void resetLocation();
|
||||
void gotoLocation(const QString &fileName, int line, bool setMarker);
|
||||
@@ -125,6 +127,7 @@ private:
|
||||
QAction *m_startRemoteAction;
|
||||
QAction *m_attachExternalAction;
|
||||
QAction *m_attachCoreAction;
|
||||
QAction *m_detachAction;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -1254,7 +1254,6 @@ void GdbEngine::handleExecRun(const GdbResultRecord &response, const QVariant &)
|
||||
{
|
||||
if (response.resultClass == GdbResultRunning) {
|
||||
qq->notifyInferiorRunning();
|
||||
q->showStatusMessage(tr("Running..."));
|
||||
} else if (response.resultClass == GdbResultError) {
|
||||
const QByteArray &msg = response.data.findChild("msg").data();
|
||||
if (msg == "Cannot find bounds of current function") {
|
||||
@@ -1323,6 +1322,12 @@ void GdbEngine::shutdown()
|
||||
exitDebugger();
|
||||
}
|
||||
|
||||
void GdbEngine::detachDebugger()
|
||||
{
|
||||
postCommand(_("detach"));
|
||||
postCommand(_("-gdb-exit"), CB(handleExit));
|
||||
}
|
||||
|
||||
void GdbEngine::exitDebugger()
|
||||
{
|
||||
debugMessage(_("GDBENGINE EXITDEBUFFER: %1").arg(m_gdbProc.state()));
|
||||
@@ -1340,7 +1345,7 @@ void GdbEngine::exitDebugger()
|
||||
qDebug() << "STATUS ON EXITDEBUGGER:" << q->status());
|
||||
interruptInferior();
|
||||
}
|
||||
if (q->startMode() == AttachExternal || q->startMode() == StartRemote)
|
||||
if (q->startMode() == AttachExternal)
|
||||
postCommand(_("detach"));
|
||||
else
|
||||
postCommand(_("kill"));
|
||||
|
||||
@@ -99,6 +99,7 @@ private:
|
||||
void setToolTipExpression(const QPoint &pos, const QString &exp);
|
||||
bool startDebugger();
|
||||
void exitDebugger();
|
||||
void detachDebugger();
|
||||
|
||||
void continueInferior();
|
||||
void interruptInferior();
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
virtual void setToolTipExpression(const QPoint &pos, const QString &exp) = 0;
|
||||
virtual bool startDebugger() = 0;
|
||||
virtual void exitDebugger() = 0;
|
||||
virtual void detachDebugger() {}
|
||||
virtual void updateWatchModel() = 0;
|
||||
|
||||
virtual void stepExec() = 0;
|
||||
|
||||
Reference in New Issue
Block a user