forked from qt-creator/qt-creator
debugger: find better separation between runcontrol and engine
This commit is contained in:
@@ -54,7 +54,6 @@ class SavedAction;
|
|||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
|
||||||
class DebuggerEngine;
|
class DebuggerEngine;
|
||||||
class DebuggerRunControl;
|
|
||||||
class DebuggerStartParameters;
|
class DebuggerStartParameters;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -101,8 +100,8 @@ public:
|
|||||||
virtual void removeLocationMark() = 0;
|
virtual void removeLocationMark() = 0;
|
||||||
|
|
||||||
virtual bool isReverseDebugging() const = 0;
|
virtual bool isReverseDebugging() const = 0;
|
||||||
virtual void runControlStarted(DebuggerRunControl *runControl) = 0;
|
virtual void runControlStarted(DebuggerEngine *engine) = 0;
|
||||||
virtual void runControlFinished(DebuggerRunControl *runControl) = 0;
|
virtual void runControlFinished(DebuggerEngine *engine) = 0;
|
||||||
virtual void displayDebugger(DebuggerEngine *engine, bool updateEngine) = 0;
|
virtual void displayDebugger(DebuggerEngine *engine, bool updateEngine) = 0;
|
||||||
virtual DebuggerLanguages activeLanguages() const = 0;
|
virtual DebuggerLanguages activeLanguages() const = 0;
|
||||||
virtual void synchronizeBreakpoints() = 0;
|
virtual void synchronizeBreakpoints() = 0;
|
||||||
|
@@ -333,9 +333,9 @@ protected:
|
|||||||
virtual void shutdownInferior() = 0;
|
virtual void shutdownInferior() = 0;
|
||||||
virtual void shutdownEngine() = 0;
|
virtual void shutdownEngine() = 0;
|
||||||
|
|
||||||
protected:
|
DebuggerRunControl *runControl() const; // FIXME: Protect.
|
||||||
DebuggerRunControl *runControl() const;
|
|
||||||
|
|
||||||
|
protected:
|
||||||
static QString msgWatchpointTriggered(BreakpointId id,
|
static QString msgWatchpointTriggered(BreakpointId id,
|
||||||
int number, quint64 address);
|
int number, quint64 address);
|
||||||
static QString msgWatchpointTriggered(BreakpointId id,
|
static QString msgWatchpointTriggered(BreakpointId id,
|
||||||
|
@@ -980,22 +980,18 @@ public slots:
|
|||||||
{
|
{
|
||||||
showMessage("ATTEMPT SYNC", LogDebug);
|
showMessage("ATTEMPT SYNC", LogDebug);
|
||||||
for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) {
|
for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) {
|
||||||
if (DebuggerRunControl *runControl = m_snapshotHandler->at(i)) {
|
if (DebuggerEngine *engine = m_snapshotHandler->at(i))
|
||||||
DebuggerEngine *engine = runControl->engine();
|
|
||||||
engine->attemptBreakpointSynchronization();
|
engine->attemptBreakpointSynchronization();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void synchronizeWatchers()
|
void synchronizeWatchers()
|
||||||
{
|
{
|
||||||
for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) {
|
for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) {
|
||||||
if (DebuggerRunControl *runControl = m_snapshotHandler->at(i)) {
|
if (DebuggerEngine *engine = m_snapshotHandler->at(i))
|
||||||
DebuggerEngine *engine = runControl->engine();
|
|
||||||
engine->watchHandler()->updateWatchers();
|
engine->watchHandler()->updateWatchers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void editorOpened(Core::IEditor *editor);
|
void editorOpened(Core::IEditor *editor);
|
||||||
void editorAboutToClose(Core::IEditor *editor);
|
void editorAboutToClose(Core::IEditor *editor);
|
||||||
@@ -1043,8 +1039,8 @@ public slots:
|
|||||||
bool hasSnapshots() const { return m_snapshotHandler->size(); }
|
bool hasSnapshots() const { return m_snapshotHandler->size(); }
|
||||||
void createNewDock(QWidget *widget);
|
void createNewDock(QWidget *widget);
|
||||||
|
|
||||||
void runControlStarted(DebuggerRunControl *runControl);
|
void runControlStarted(DebuggerEngine *engine);
|
||||||
void runControlFinished(DebuggerRunControl *runControl);
|
void runControlFinished(DebuggerEngine *engine);
|
||||||
DebuggerLanguages activeLanguages() const;
|
DebuggerLanguages activeLanguages() const;
|
||||||
QString gdbBinaryForToolChain(int toolChain) const;
|
QString gdbBinaryForToolChain(int toolChain) const;
|
||||||
void remoteCommand(const QStringList &options, const QStringList &);
|
void remoteCommand(const QStringList &options, const QStringList &);
|
||||||
@@ -1477,11 +1473,11 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project)
|
|||||||
}
|
}
|
||||||
for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) {
|
for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) {
|
||||||
// Run controls might be deleted during exit.
|
// Run controls might be deleted during exit.
|
||||||
if (DebuggerRunControl *runControl = m_snapshotHandler->at(i)) {
|
if (DebuggerEngine *engine = m_snapshotHandler->at(i)) {
|
||||||
|
DebuggerRunControl *runControl = engine->runControl();
|
||||||
RunConfiguration *rc = runControl->runConfiguration();
|
RunConfiguration *rc = runControl->runConfiguration();
|
||||||
if (rc == activeRc) {
|
if (rc == activeRc) {
|
||||||
m_snapshotHandler->setCurrentIndex(i);
|
m_snapshotHandler->setCurrentIndex(i);
|
||||||
DebuggerEngine *engine = runControl->engine();
|
|
||||||
updateState(engine);
|
updateState(engine);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2387,7 +2383,7 @@ void DebuggerPluginPrivate::aboutToUnloadSession()
|
|||||||
// with command-line debugging startup.
|
// with command-line debugging startup.
|
||||||
// FIXME ABC: Still wanted? Iterate?
|
// FIXME ABC: Still wanted? Iterate?
|
||||||
//if (d->m_engine && state() != DebuggerNotReady
|
//if (d->m_engine && state() != DebuggerNotReady
|
||||||
// && runControl()->sp().startMode == StartInternal)
|
// && engine()->sp().startMode == StartInternal)
|
||||||
// d->m_engine->shutdown();
|
// d->m_engine->shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2578,22 +2574,21 @@ void DebuggerPluginPrivate::createNewDock(QWidget *widget)
|
|||||||
dockWidget->show();
|
dockWidget->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPluginPrivate::runControlStarted(DebuggerRunControl *runControl)
|
void DebuggerPluginPrivate::runControlStarted(DebuggerEngine *engine)
|
||||||
{
|
{
|
||||||
activateDebugMode();
|
activateDebugMode();
|
||||||
DebuggerEngine *engine = runControl->engine();
|
|
||||||
const QString message = tr("Starting debugger '%1' for tool chain '%2'...")
|
const QString message = tr("Starting debugger '%1' for tool chain '%2'...")
|
||||||
.arg(engine->objectName())
|
.arg(engine->objectName())
|
||||||
.arg(engine->startParameters().toolChainName());
|
.arg(engine->startParameters().toolChainName());
|
||||||
showMessage(message, StatusBar);
|
showMessage(message, StatusBar);
|
||||||
showMessage(m_debuggerSettings->dump(), LogDebug);
|
showMessage(m_debuggerSettings->dump(), LogDebug);
|
||||||
m_snapshotHandler->appendSnapshot(runControl);
|
m_snapshotHandler->appendSnapshot(engine);
|
||||||
connectEngine(engine);
|
connectEngine(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPluginPrivate::runControlFinished(DebuggerRunControl *runControl)
|
void DebuggerPluginPrivate::runControlFinished(DebuggerEngine *engine)
|
||||||
{
|
{
|
||||||
m_snapshotHandler->removeSnapshot(runControl);
|
m_snapshotHandler->removeSnapshot(engine);
|
||||||
if (m_snapshotHandler->size() == 0) {
|
if (m_snapshotHandler->size() == 0) {
|
||||||
// Last engine quits.
|
// Last engine quits.
|
||||||
disconnectEngine();
|
disconnectEngine();
|
||||||
|
@@ -656,7 +656,7 @@ void DebuggerRunControl::start()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
debuggerCore()->runControlStarted(this);
|
debuggerCore()->runControlStarted(engine());
|
||||||
|
|
||||||
// We might get a synchronous startFailed() notification on Windows,
|
// We might get a synchronous startFailed() notification on Windows,
|
||||||
// when launching the process fails. Emit a proper finished() sequence.
|
// when launching the process fails. Emit a proper finished() sequence.
|
||||||
@@ -684,7 +684,7 @@ void DebuggerRunControl::handleFinished()
|
|||||||
emit addToOutputWindowInline(this, tr("Debugging has finished"), false);
|
emit addToOutputWindowInline(this, tr("Debugging has finished"), false);
|
||||||
if (engine())
|
if (engine())
|
||||||
engine()->handleFinished();
|
engine()->handleFinished();
|
||||||
debuggerCore()->runControlFinished(this);
|
debuggerCore()->runControlFinished(engine());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerRunControl::showMessage(const QString &msg, int channel)
|
void DebuggerRunControl::showMessage(const QString &msg, int channel)
|
||||||
|
@@ -123,21 +123,14 @@ SnapshotHandler::SnapshotHandler()
|
|||||||
SnapshotHandler::~SnapshotHandler()
|
SnapshotHandler::~SnapshotHandler()
|
||||||
{
|
{
|
||||||
for (int i = m_snapshots.size(); --i >= 0; ) {
|
for (int i = m_snapshots.size(); --i >= 0; ) {
|
||||||
if (DebuggerEngine *engine = engineAt(i)) {
|
if (DebuggerEngine *engine = at(i)) {
|
||||||
const DebuggerStartParameters & sp = engine->startParameters();
|
const DebuggerStartParameters &sp = engine->startParameters();
|
||||||
if (sp.isSnapshot && !sp.coreFile.isEmpty())
|
if (sp.isSnapshot && !sp.coreFile.isEmpty())
|
||||||
QFile::remove(sp.coreFile);
|
QFile::remove(sp.coreFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DebuggerEngine *SnapshotHandler::engineAt(int i) const
|
|
||||||
{
|
|
||||||
DebuggerEngine *engine = m_snapshots.at(i)->engine();
|
|
||||||
QTC_ASSERT(engine, qDebug() << "ENGINE AT " << i << "DELETED");
|
|
||||||
return engine;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SnapshotHandler::rowCount(const QModelIndex &parent) const
|
int SnapshotHandler::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
// Since the stack is not a tree, row count is 0 for any valid parent
|
// Since the stack is not a tree, row count is 0 for any valid parent
|
||||||
@@ -154,7 +147,7 @@ QVariant SnapshotHandler::data(const QModelIndex &index, int role) const
|
|||||||
if (!index.isValid() || index.row() >= m_snapshots.size())
|
if (!index.isValid() || index.row() >= m_snapshots.size())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
const DebuggerEngine *engine = engineAt(index.row());
|
const DebuggerEngine *engine = at(index.row());
|
||||||
|
|
||||||
if (role == SnapshotCapabilityRole)
|
if (role == SnapshotCapabilityRole)
|
||||||
return engine && (engine->debuggerCapabilities() & SnapshotCapability);
|
return engine && (engine->debuggerCapabilities() & SnapshotCapability);
|
||||||
@@ -213,20 +206,20 @@ void SnapshotHandler::activateSnapshot(int index)
|
|||||||
{
|
{
|
||||||
m_currentIndex = index;
|
m_currentIndex = index;
|
||||||
//qDebug() << "ACTIVATING INDEX: " << m_currentIndex << " OF " << size();
|
//qDebug() << "ACTIVATING INDEX: " << m_currentIndex << " OF " << size();
|
||||||
debuggerCore()->displayDebugger(engineAt(index), true);
|
debuggerCore()->displayDebugger(at(index), true);
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapshotHandler::createSnapshot(int index)
|
void SnapshotHandler::createSnapshot(int index)
|
||||||
{
|
{
|
||||||
DebuggerEngine *engine = engineAt(index);
|
DebuggerEngine *engine = at(index);
|
||||||
QTC_ASSERT(engine, return);
|
QTC_ASSERT(engine, return);
|
||||||
engine->createSnapshot();
|
engine->createSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapshotHandler::removeSnapshot(int index)
|
void SnapshotHandler::removeSnapshot(int index)
|
||||||
{
|
{
|
||||||
DebuggerEngine *engine = engineAt(index);
|
DebuggerEngine *engine = at(index);
|
||||||
//qDebug() << "REMOVING " << engine;
|
//qDebug() << "REMOVING " << engine;
|
||||||
QTC_ASSERT(engine, return);
|
QTC_ASSERT(engine, return);
|
||||||
#if 0
|
#if 0
|
||||||
@@ -254,17 +247,17 @@ void SnapshotHandler::removeAll()
|
|||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapshotHandler::appendSnapshot(DebuggerRunControl *rc)
|
void SnapshotHandler::appendSnapshot(DebuggerEngine *engine)
|
||||||
{
|
{
|
||||||
m_snapshots.append(rc);
|
m_snapshots.append(engine);
|
||||||
m_currentIndex = size() - 1;
|
m_currentIndex = size() - 1;
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapshotHandler::removeSnapshot(DebuggerRunControl *rc)
|
void SnapshotHandler::removeSnapshot(DebuggerEngine *engine)
|
||||||
{
|
{
|
||||||
// Could be that the run controls died before it was appended.
|
// Could be that the run controls died before it was appended.
|
||||||
int index = m_snapshots.indexOf(rc);
|
int index = m_snapshots.indexOf(engine);
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
removeSnapshot(index);
|
removeSnapshot(index);
|
||||||
}
|
}
|
||||||
@@ -275,22 +268,10 @@ void SnapshotHandler::setCurrentIndex(int index)
|
|||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
DebuggerRunControl *SnapshotHandler::at(int i) const
|
DebuggerEngine *SnapshotHandler::at(int i) const
|
||||||
{
|
{
|
||||||
return m_snapshots.at(i).data();
|
return m_snapshots.at(i).data();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<DebuggerRunControl*> SnapshotHandler::runControls() const
|
|
||||||
{
|
|
||||||
// Return unique list of run controls
|
|
||||||
QList<DebuggerRunControl*> rc;
|
|
||||||
rc.reserve(m_snapshots.size());
|
|
||||||
foreach(const QPointer<DebuggerRunControl> &runControlPtr, m_snapshots)
|
|
||||||
if (DebuggerRunControl *runControl = runControlPtr)
|
|
||||||
if (!rc.contains(runControl))
|
|
||||||
rc.push_back(runControl);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
@@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
|
||||||
class DebuggerRunControl;
|
|
||||||
class DebuggerEngine;
|
class DebuggerEngine;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -59,12 +58,11 @@ public:
|
|||||||
void removeAll();
|
void removeAll();
|
||||||
QAbstractItemModel *model() { return this; }
|
QAbstractItemModel *model() { return this; }
|
||||||
int currentIndex() const { return m_currentIndex; }
|
int currentIndex() const { return m_currentIndex; }
|
||||||
void appendSnapshot(DebuggerRunControl *rc);
|
void appendSnapshot(DebuggerEngine *engine);
|
||||||
void removeSnapshot(DebuggerRunControl *rc);
|
void removeSnapshot(DebuggerEngine *engine);
|
||||||
void setCurrentIndex(int index);
|
void setCurrentIndex(int index);
|
||||||
int size() const { return m_snapshots.size(); }
|
int size() const { return m_snapshots.size(); }
|
||||||
DebuggerRunControl *at(int index) const;
|
DebuggerEngine *at(int index) const;
|
||||||
QList<DebuggerRunControl *> runControls() const;
|
|
||||||
|
|
||||||
void createSnapshot(int index);
|
void createSnapshot(int index);
|
||||||
void activateSnapshot(int index);
|
void activateSnapshot(int index);
|
||||||
@@ -78,10 +76,9 @@ private:
|
|||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
Q_SLOT void resetModel() { reset(); }
|
Q_SLOT void resetModel() { reset(); }
|
||||||
DebuggerEngine *engineAt(int i) const;
|
|
||||||
|
|
||||||
int m_currentIndex;
|
int m_currentIndex;
|
||||||
QList< QPointer<DebuggerRunControl> > m_snapshots;
|
QList< QPointer<DebuggerEngine> > m_snapshots;
|
||||||
const QVariant m_positionIcon;
|
const QVariant m_positionIcon;
|
||||||
const QVariant m_emptyIcon;
|
const QVariant m_emptyIcon;
|
||||||
};
|
};
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "debuggeractions.h"
|
#include "debuggeractions.h"
|
||||||
#include "debuggercore.h"
|
#include "debuggercore.h"
|
||||||
#include "debuggerrunner.h"
|
#include "debuggerengine.h"
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/savedaction.h>
|
#include <utils/savedaction.h>
|
||||||
@@ -136,7 +136,7 @@ void SnapshotWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
|
|
||||||
void SnapshotWindow::removeSnapshot(int i)
|
void SnapshotWindow::removeSnapshot(int i)
|
||||||
{
|
{
|
||||||
m_snapshotHandler->at(i)->stop();
|
m_snapshotHandler->at(i)->quitDebugger();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapshotWindow::resizeColumnsToContents()
|
void SnapshotWindow::resizeColumnsToContents()
|
||||||
|
Reference in New Issue
Block a user