debugger: add model accessors to run control

Plan is to move the models themselves from DebuggerManager to
DebuggerRunControl.
This commit is contained in:
hjk
2010-06-15 08:22:02 +02:00
parent c364e5522e
commit 83e479824e
4 changed files with 177 additions and 82 deletions

View File

@@ -277,6 +277,15 @@ struct DebuggerManagerPrivate
QLabel *m_statusLabel; QLabel *m_statusLabel;
// FIXME: Move to DebuggerRunControl
BreakHandler *m_breakHandler;
ModulesHandler *m_modulesHandler;
RegisterHandler *m_registerHandler;
SnapshotHandler *m_snapshotHandler;
StackHandler *m_stackHandler;
ThreadsHandler *m_threadsHandler;
WatchHandler *m_watchHandler;
QDockWidget *m_breakDock; QDockWidget *m_breakDock;
QDockWidget *m_modulesDock; QDockWidget *m_modulesDock;
QDockWidget *m_outputDock; QDockWidget *m_outputDock;
@@ -288,14 +297,6 @@ struct DebuggerManagerPrivate
QDockWidget *m_watchDock; QDockWidget *m_watchDock;
QList<QDockWidget *> m_dockWidgets; QList<QDockWidget *> m_dockWidgets;
BreakHandler *m_breakHandler;
ModulesHandler *m_modulesHandler;
RegisterHandler *m_registerHandler;
SnapshotHandler *m_snapshotHandler;
StackHandler *m_stackHandler;
ThreadsHandler *m_threadsHandler;
WatchHandler *m_watchHandler;
DebuggerManagerActions m_actions; DebuggerManagerActions m_actions;
QWidget *m_breakWindow; QWidget *m_breakWindow;
@@ -711,41 +712,6 @@ IDebuggerEngine *DebuggerManager::currentEngine() const
return d->m_engine; return d->m_engine;
} }
ModulesHandler *DebuggerManager::modulesHandler() const
{
return d->m_modulesHandler;
}
BreakHandler *DebuggerManager::breakHandler() const
{
return d->m_breakHandler;
}
RegisterHandler *DebuggerManager::registerHandler() const
{
return d->m_registerHandler;
}
StackHandler *DebuggerManager::stackHandler() const
{
return d->m_stackHandler;
}
ThreadsHandler *DebuggerManager::threadsHandler() const
{
return d->m_threadsHandler;
}
WatchHandler *DebuggerManager::watchHandler() const
{
return d->m_watchHandler;
}
SnapshotHandler *DebuggerManager::snapshotHandler() const
{
return d->m_snapshotHandler;
}
const CPlusPlus::Snapshot &DebuggerManager::cppCodeModelSnapshot() const const CPlusPlus::Snapshot &DebuggerManager::cppCodeModelSnapshot() const
{ {
if (d->m_codeModelSnapshot.isEmpty() && theDebuggerAction(UseCodeModel)->isChecked()) if (d->m_codeModelSnapshot.isEmpty() && theDebuggerAction(UseCodeModel)->isChecked())
@@ -2010,6 +1976,40 @@ DebuggerOutputWindow *DebuggerManager::debuggerOutputWindow() const
return d->m_outputWindow; return d->m_outputWindow;
} }
ModulesHandler *DebuggerManager::modulesHandler() const
{
return d->m_modulesHandler;
}
BreakHandler *DebuggerManager::breakHandler() const
{
return d->m_breakHandler;
}
RegisterHandler *DebuggerManager::registerHandler() const
{
return d->m_registerHandler;
}
StackHandler *DebuggerManager::stackHandler() const
{
return d->m_stackHandler;
}
ThreadsHandler *DebuggerManager::threadsHandler() const
{
return d->m_threadsHandler;
}
WatchHandler *DebuggerManager::watchHandler() const
{
return d->m_watchHandler;
}
SnapshotHandler *DebuggerManager::snapshotHandler() const
{
return d->m_snapshotHandler;
}
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //

View File

@@ -69,16 +69,10 @@ namespace Internal {
class DebuggerOutputWindow; class DebuggerOutputWindow;
class DebuggerPlugin; class DebuggerPlugin;
class BreakHandler;
class BreakpointData; class BreakpointData;
class ModulesHandler;
class RegisterHandler;
class SourceFilesWindow; class SourceFilesWindow;
struct StackFrame; struct StackFrame;
class StackHandler;
class Symbol; class Symbol;
class SnapshotHandler;
class ThreadsHandler;
class WatchData; class WatchData;
class WatchHandler; class WatchHandler;
class IDebuggerEngine; class IDebuggerEngine;
@@ -257,8 +251,9 @@ public slots: // FIXME
void operateByInstructionTriggered(); void operateByInstructionTriggered();
void startFailed(); void startFailed();
public: friend class DebuggerRunControl;
Internal::ModulesHandler *modulesHandler() const; Internal::ModulesHandler *modulesHandler() const;
public:
Internal::BreakHandler *breakHandler() const; Internal::BreakHandler *breakHandler() const;
Internal::RegisterHandler *registerHandler() const; Internal::RegisterHandler *registerHandler() const;
Internal::StackHandler *stackHandler() const; Internal::StackHandler *stackHandler() const;

View File

@@ -52,14 +52,14 @@ using namespace ProjectExplorer;
using namespace Debugger::Internal; using namespace Debugger::Internal;
namespace Debugger {
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// DebuggerRunControlFactory // DebuggerRunControlFactory
// //
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
namespace Debugger {
// A factory to create DebuggerRunControls // A factory to create DebuggerRunControls
DebuggerRunControlFactory::DebuggerRunControlFactory(DebuggerManager *manager) DebuggerRunControlFactory::DebuggerRunControlFactory(DebuggerManager *manager)
: m_manager(manager) : m_manager(manager)
@@ -112,8 +112,8 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
return sp; return sp;
} }
RunControl *DebuggerRunControlFactory::create(RunConfiguration *runConfiguration, RunControl *DebuggerRunControlFactory::create
const QString &mode) (RunConfiguration *runConfiguration, const QString &mode)
{ {
QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0); QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0);
DebuggerStartParameters sp = localStartParameters(runConfiguration); DebuggerStartParameters sp = localStartParameters(runConfiguration);
@@ -133,6 +133,41 @@ QWidget *DebuggerRunControlFactory::createConfigurationWidget(RunConfiguration *
} }
////////////////////////////////////////////////////////////////////////
//
// DebuggerRunControl::Private
//
////////////////////////////////////////////////////////////////////////
class DebuggerRunControl::Private
{
public:
Private(DebuggerRunControl *parent);
public:
DebuggerRunControl *q;
DebuggerStartParameters m_startParameters;
DebuggerManager *m_manager;
bool m_running;
/*
// FIXME: Move from DebuggerManager
BreakHandler *m_breakHandler;
ModulesHandler *m_modulesHandler;
RegisterHandler *m_registerHandler;
SnapshotHandler *m_snapshotHandler;
StackHandler *m_stackHandler;
ThreadsHandler *m_threadsHandler;
WatchHandler *m_watchHandler;
*/
};
DebuggerRunControl::Private::Private(DebuggerRunControl *parent)
: q(parent)
{
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
@@ -143,35 +178,41 @@ QWidget *DebuggerRunControlFactory::createConfigurationWidget(RunConfiguration *
DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager, DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
const DebuggerStartParameters &startParameters) const DebuggerStartParameters &startParameters)
: RunControl(0, ProjectExplorer::Constants::DEBUGMODE), : RunControl(0, ProjectExplorer::Constants::DEBUGMODE),
m_startParameters(startParameters), d(new Private(this))
m_manager(manager),
m_running(false)
{ {
connect(m_manager, SIGNAL(debuggingFinished()), d->m_startParameters = startParameters;
d->m_manager = manager;
d->m_running = false;
connect(d->m_manager, SIGNAL(debuggingFinished()),
this, SLOT(debuggingFinished()), this, SLOT(debuggingFinished()),
Qt::QueuedConnection); Qt::QueuedConnection);
connect(m_manager, SIGNAL(messageAvailable(QString, bool)), connect(d->m_manager, SIGNAL(messageAvailable(QString, bool)),
this, SLOT(slotMessageAvailable(QString, bool))); this, SLOT(slotMessageAvailable(QString, bool)));
connect(m_manager, SIGNAL(inferiorPidChanged(qint64)), connect(d->m_manager, SIGNAL(inferiorPidChanged(qint64)),
this, SLOT(bringApplicationToForeground(qint64)), this, SLOT(bringApplicationToForeground(qint64)),
Qt::QueuedConnection); Qt::QueuedConnection);
connect(this, SIGNAL(stopRequested()), connect(this, SIGNAL(stopRequested()),
m_manager, SLOT(exitDebugger())); d->m_manager, SLOT(exitDebugger()));
if (m_startParameters.environment.empty()) if (d->m_startParameters.environment.empty())
m_startParameters.environment = ProjectExplorer::Environment().toStringList(); d->m_startParameters.environment = ProjectExplorer::Environment().toStringList();
m_startParameters.useTerminal = false; d->m_startParameters.useTerminal = false;
} }
DebuggerRunControl::~DebuggerRunControl()
{
delete d;
}
QString DebuggerRunControl::displayName() const QString DebuggerRunControl::displayName() const
{ {
return m_startParameters.displayName; return d->m_startParameters.displayName;
} }
void DebuggerRunControl::setCustomEnvironment(ProjectExplorer::Environment env) void DebuggerRunControl::setCustomEnvironment(ProjectExplorer::Environment env)
{ {
m_startParameters.environment = env.toStringList(); d->m_startParameters.environment = env.toStringList();
} }
void DebuggerRunControl::init() void DebuggerRunControl::init()
@@ -180,13 +221,13 @@ void DebuggerRunControl::init()
void DebuggerRunControl::start() void DebuggerRunControl::start()
{ {
m_running = true; d->m_running = true;
QString errorMessage; QString errorMessage;
QString settingsCategory; QString settingsCategory;
QString settingsPage; QString settingsPage;
if (m_manager->checkDebugConfiguration(m_startParameters.toolChainType, if (d->m_manager->checkDebugConfiguration(d->m_startParameters.toolChainType,
&errorMessage, &settingsCategory, &settingsPage)) { &errorMessage, &settingsCategory, &settingsPage)) {
m_manager->startNewDebugger(this); d->m_manager->startNewDebugger(this);
emit started(); emit started();
} else { } else {
appendMessage(this, errorMessage, true); appendMessage(this, errorMessage, true);
@@ -199,13 +240,13 @@ void DebuggerRunControl::start()
void DebuggerRunControl::showMessage(const QString &msg, int channel, void DebuggerRunControl::showMessage(const QString &msg, int channel,
int timeout) int timeout)
{ {
if (!m_manager) if (!d->m_manager)
return; return;
DebuggerOutputWindow *ow = m_manager->debuggerOutputWindow(); DebuggerOutputWindow *ow = d->m_manager->debuggerOutputWindow();
QTC_ASSERT(ow, return); QTC_ASSERT(ow, return);
switch (channel) { switch (channel) {
case StatusBar: case StatusBar:
m_manager->showStatusMessage(msg, timeout); d->m_manager->showStatusMessage(msg, timeout);
ow->showOutput(LogStatus, msg); ow->showOutput(LogStatus, msg);
break; break;
case AppOutput: case AppOutput:
@@ -233,22 +274,61 @@ void DebuggerRunControl::slotMessageAvailable(const QString &data, bool isError)
emit appendMessage(this, data, isError); emit appendMessage(this, data, isError);
} }
void DebuggerRunControl::stop() void DebuggerRunControl::stop()
{ {
m_running = false; d->m_running = false;
emit stopRequested(); emit stopRequested();
} }
void DebuggerRunControl::debuggingFinished() void DebuggerRunControl::debuggingFinished()
{ {
m_running = false; d->m_running = false;
emit finished(); emit finished();
} }
bool DebuggerRunControl::isRunning() const bool DebuggerRunControl::isRunning() const
{ {
return m_running; return d->m_running;
}
const DebuggerStartParameters &DebuggerRunControl::sp() const
{
return d->m_startParameters;
}
ModulesHandler *DebuggerRunControl::modulesHandler() const
{
return d->m_manager->modulesHandler();
}
BreakHandler *DebuggerRunControl::breakHandler() const
{
return d->m_manager->breakHandler();
}
RegisterHandler *DebuggerRunControl::registerHandler() const
{
return d->m_manager->registerHandler();
}
StackHandler *DebuggerRunControl::stackHandler() const
{
return d->m_manager->stackHandler();
}
ThreadsHandler *DebuggerRunControl::threadsHandler() const
{
return d->m_manager->threadsHandler();
}
WatchHandler *DebuggerRunControl::watchHandler() const
{
return d->m_manager->watchHandler();
}
SnapshotHandler *DebuggerRunControl::snapshotHandler() const
{
return d->m_manager->snapshotHandler();
} }
} // namespace Debugger } // namespace Debugger

View File

@@ -39,13 +39,24 @@
#include <QtCore/QStringList> #include <QtCore/QStringList>
namespace ProjectExplorer { namespace ProjectExplorer {
class Environment; class Environment;
} }
namespace Debugger { namespace Debugger {
class DebuggerManager; class DebuggerManager;
namespace Internal {
class BreakHandler;
class ModulesHandler;
class RegisterHandler;
class StackHandler;
class SnapshotHandler;
class ThreadsHandler;
class WatchHandler;
}
class DEBUGGER_EXPORT DebuggerStartParameters class DEBUGGER_EXPORT DebuggerStartParameters
{ {
public: public:
@@ -104,7 +115,8 @@ private:
DebuggerManager *m_manager; DebuggerManager *m_manager;
}; };
// This is a job description // This is a job description containing all data "local" to the jobs, including
// the models of the individual debugger views.
class DEBUGGER_EXPORT DebuggerRunControl class DEBUGGER_EXPORT DebuggerRunControl
: public ProjectExplorer::RunControl : public ProjectExplorer::RunControl
{ {
@@ -113,6 +125,7 @@ class DEBUGGER_EXPORT DebuggerRunControl
public: public:
DebuggerRunControl(DebuggerManager *manager, DebuggerRunControl(DebuggerManager *manager,
const DebuggerStartParameters &startParameters); const DebuggerStartParameters &startParameters);
~DebuggerRunControl();
void setCustomEnvironment(ProjectExplorer::Environment env); void setCustomEnvironment(ProjectExplorer::Environment env);
@@ -124,7 +137,15 @@ public:
Q_SLOT void debuggingFinished(); Q_SLOT void debuggingFinished();
const DebuggerStartParameters &sp() const { return m_startParameters; } const DebuggerStartParameters &sp() const;
Internal::ModulesHandler *modulesHandler() const;
Internal::BreakHandler *breakHandler() const;
Internal::RegisterHandler *registerHandler() const;
Internal::StackHandler *stackHandler() const;
Internal::ThreadsHandler *threadsHandler() const;
Internal::WatchHandler *watchHandler() const;
Internal::SnapshotHandler *snapshotHandler() const;
signals: signals:
void stopRequested(); void stopRequested();
@@ -137,9 +158,8 @@ private slots:
private: private:
void init(); void init();
DebuggerStartParameters m_startParameters; class Private;
DebuggerManager *m_manager; Private *d;
bool m_running;
}; };
} // namespace Debugger } // namespace Debugger