Commit 96561a38 authored by hjk's avatar hjk

debugger: enable debugging of multiple projects at the same time

parent 990dba75
......@@ -96,6 +96,7 @@
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/session.h>
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
#include <texteditor/basetexteditor.h>
......@@ -940,6 +941,7 @@ public slots:
DebuggerState state() const { return m_state; }
void updateState(DebuggerEngine *engine);
void onCurrentProjectChanged(ProjectExplorer::Project *project);
void resetLocation();
void gotoLocation(const QString &file, int line, bool setMarker);
......@@ -1617,9 +1619,35 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er
setInitialState();
connectEngine(m_sessionEngine, false);
connect(sessionManager(),
SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
SLOT(onCurrentProjectChanged(ProjectExplorer::Project*)));
return true;
}
void DebuggerPluginPrivate::onCurrentProjectChanged(ProjectExplorer::Project *project)
{
QTC_ASSERT(project, return);
ProjectExplorer::Target *target = project->activeTarget();
QTC_ASSERT(target, return);
ProjectExplorer::RunConfiguration *activeRc = target->activeRunConfiguration();
QTC_ASSERT(activeRc, return);
for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) {
DebuggerRunControl *runControl = m_snapshotHandler->at(i);
RunConfiguration *rc = runControl->runConfiguration();
if (rc == activeRc) {
m_snapshotHandler->setCurrentIndex(i);
DebuggerEngine *engine = runControl->engine();
updateState(engine);
return;
}
}
// No corresponding debugger found. So we are ready to start one.
ICore *core = ICore::instance();
core->updateAdditionalContexts(m_gdbRunningContext, Core::Context());
}
void DebuggerPluginPrivate::onAction()
{
QAction *act = qobject_cast<QAction *>(sender());
......@@ -2163,7 +2191,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
cleanupViews();
}
const bool startIsContinue = (m_state == InferiorStopOk);
const bool startIsContinue = (engine->state() == InferiorStopOk);
ICore *core = ICore::instance();
if (startIsContinue)
core->updateAdditionalContexts(Core::Context(), m_gdbRunningContext);
......
......@@ -208,7 +208,8 @@ QWidget *DebuggerRunControlFactory::createConfigurationWidget
DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfiguration,
DebuggerEngineType enabledEngines, const DebuggerStartParameters &sp)
: RunControl(runConfiguration, ProjectExplorer::Constants::DEBUGMODE)
: RunControl(runConfiguration, ProjectExplorer::Constants::DEBUGMODE),
m_myRunConfiguration(runConfiguration)
{
m_running = false;
m_enabledEngines = enabledEngines;
......
......@@ -86,7 +86,8 @@ class DEBUGGER_EXPORT DebuggerRunControl
Q_OBJECT
public:
DebuggerRunControl(ProjectExplorer::RunConfiguration *runConfiguration,
typedef ProjectExplorer::RunConfiguration RunConfiguration;
DebuggerRunControl(RunConfiguration *runConfiguration,
DebuggerEngineType enabledEngines, const DebuggerStartParameters &sp);
~DebuggerRunControl();
......@@ -104,6 +105,7 @@ public:
void startFailed();
void startSuccessful();
void debuggingFinished();
RunConfiguration *runConfiguration() const { return m_myRunConfiguration.data(); }
DebuggerState state() const;
Internal::DebuggerEngine *engine();
......@@ -124,6 +126,7 @@ private:
DebuggerEngineType engineForMode(DebuggerStartMode mode);
Internal::DebuggerEngine *m_engine;
const QWeakPointer<RunConfiguration> m_myRunConfiguration;
bool m_running;
DebuggerEngineType m_enabledEngines;
QString m_errorMessage;
......
......@@ -286,5 +286,10 @@ void SnapshotHandler::setCurrentIndex(int index)
reset();
}
DebuggerRunControl *SnapshotHandler::at(int i)
{
return m_snapshots.at(i).data();
}
} // namespace Internal
} // namespace Debugger
......@@ -67,6 +67,7 @@ public:
void removeSnapshot(DebuggerRunControl *rc);
void setCurrentIndex(int index);
int size() const { return m_snapshots.size(); }
DebuggerRunControl *at(int i);
private:
// QAbstractTableModel
......
......@@ -186,7 +186,6 @@ struct ProjectExplorerPluginPrivate {
QString m_lastOpenDirectory;
RunConfiguration *m_delayedRunConfiguration; // TODO this is not right
RunControl *m_debuggingRunControl;
QString m_runMode;
QString m_projectFilterString;
Internal::MiniProjectTargetSelector * m_targetSelector;
......@@ -200,7 +199,6 @@ ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() :
m_currentProject(0),
m_currentNode(0),
m_delayedRunConfiguration(0),
m_debuggingRunControl(0),
m_projectsMode(0)
{
}
......@@ -1319,9 +1317,6 @@ void ProjectExplorerPlugin::startRunControl(RunControl *runControl, const QStrin
connect(runControl, SIGNAL(finished()),
this, SLOT(runControlFinished()));
if (runMode == ProjectExplorer::Constants::DEBUGMODE)
d->m_debuggingRunControl = runControl;
runControl->start();
updateRunActions();
}
......@@ -1788,7 +1783,7 @@ void ProjectExplorerPlugin::runProjectImpl(Project *pro, QString mode)
void ProjectExplorerPlugin::debugProject()
{
Project *pro = startupProject();
if (!pro || d->m_debuggingRunControl )
if (!pro)
return;
runProjectImpl(pro, ProjectExplorer::Constants::DEBUGMODE);
......@@ -1821,9 +1816,6 @@ bool ProjectExplorerPlugin::showBuildConfigDialog()
void ProjectExplorerPlugin::runControlFinished()
{
if (sender() == d->m_debuggingRunControl)
d->m_debuggingRunControl = 0;
updateRunActions();
}
......@@ -1934,7 +1926,7 @@ void ProjectExplorerPlugin::updateRunActions()
bool canRun = findRunControlFactory(activeRC, ProjectExplorer::Constants::RUNMODE)
&& activeRC->isEnabled();
const bool canDebug = !d->m_debuggingRunControl && findRunControlFactory(activeRC, ProjectExplorer::Constants::DEBUGMODE)
const bool canDebug = findRunControlFactory(activeRC, ProjectExplorer::Constants::DEBUGMODE)
&& activeRC->isEnabled();
const bool building = d->m_buildManager->isBuilding();
......
......@@ -65,11 +65,11 @@ public:
// Running
QList<RunConfiguration *> runConfigurations() const;
void addRunConfiguration(RunConfiguration* runConfiguration);
void removeRunConfiguration(RunConfiguration* runConfiguration);
void addRunConfiguration(RunConfiguration *runConfiguration);
void removeRunConfiguration(RunConfiguration *runConfiguration);
RunConfiguration* activeRunConfiguration() const;
void setActiveRunConfiguration(RunConfiguration* runConfiguration);
RunConfiguration *activeRunConfiguration() const;
void setActiveRunConfiguration(RunConfiguration *runConfiguration);
// Returns whether this target is actually available at he time
// of the call. A target may become unavailable e.g. when a Qt version
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment