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