Debugger: Replace debuggerCore() by equivalent free functions

One indirection less on the user code side, and easier to export
if needed (partially addressing QTCREATORBUG-13187)

Change-Id: I13ab9f471a3a34da7a6331aefc83f6d02413bfab
Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
hjk
2014-10-22 13:04:47 +02:00
parent 6b4c254bf3
commit 9ba17acc80
20 changed files with 255 additions and 244 deletions

View File

@@ -297,7 +297,6 @@ void BreakHandler::saveBreakpoints()
{
const QString one = _("1");
//qDebug() << "SAVING BREAKPOINTS...";
QTC_ASSERT(debuggerCore(), return);
QList<QVariant> list;
ConstIterator it = m_storage.constBegin(), et = m_storage.constEnd();
for ( ; it != et; ++it) {
@@ -1210,7 +1209,7 @@ void BreakHandler::timerEvent(QTimerEvent *event)
killTimer(m_syncTimerId);
m_syncTimerId = -1;
saveBreakpoints(); // FIXME: remove?
debuggerCore()->synchronizeBreakpoints();
Internal::synchronizeBreakpoints();
}
void BreakHandler::gotoLocation(BreakpointModelId id) const

View File

@@ -789,7 +789,7 @@ void BreakTreeView::contextMenuEvent(QContextMenuEvent *ev)
QAction *synchronizeAction =
new QAction(tr("Synchronize Breakpoints"), &menu);
synchronizeAction->setEnabled(debuggerCore()->hasSnapshots());
synchronizeAction->setEnabled(Internal::hasSnapshots());
bool enabled = selectedIds.isEmpty() || handler->isEnabled(selectedIds.at(0));

View File

@@ -387,7 +387,7 @@ void CdbEngine::init()
// Create local list of mappings in native separators
m_sourcePathMappings.clear();
const QSharedPointer<GlobalDebuggerOptions> globalOptions = debuggerCore()->globalDebuggerOptions();
const QSharedPointer<GlobalDebuggerOptions> globalOptions = Internal::globalDebuggerOptions();
SourcePathMap sourcePathMap = globalOptions->sourcePathMap;
if (!sourcePathMap.isEmpty()) {
m_sourcePathMappings.reserve(sourcePathMap.size());
@@ -583,7 +583,7 @@ void CdbEngine::createFullBacktrace()
void CdbEngine::handleCreateFullBackTrace(const CdbEngine::CdbBuiltinCommandPtr &cmd)
{
debuggerCore()->openTextEditor(QLatin1String("Backtrace $"), QLatin1String(cmd->joinedReply()));
Internal::openTextEditor(QLatin1String("Backtrace $"), QLatin1String(cmd->joinedReply()));
}
void CdbEngine::setupEngine()
@@ -1529,7 +1529,7 @@ void CdbEngine::updateLocals(bool forNewStackFrame)
// variables in case of errors in uninitializedVariables().
if (boolSetting(UseCodeModel)) {
QStringList uninitializedVariables;
getUninitializedVariables(debuggerCore()->cppCodeModelSnapshot(),
getUninitializedVariables(Internal::cppCodeModelSnapshot(),
frame.function, frame.file, frame.line, &uninitializedVariables);
if (!uninitializedVariables.isEmpty()) {
str << blankSeparator << "-u \"";
@@ -2296,9 +2296,9 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
// Fire off remaining commands asynchronously
if (!m_pendingBreakpointMap.isEmpty() && !m_pendingSubBreakpointMap.isEmpty())
postCommandSequence(CommandListBreakPoints);
if (debuggerCore()->isDockVisible(QLatin1String(DOCKWIDGET_REGISTER)))
if (Internal::isDockVisible(QLatin1String(DOCKWIDGET_REGISTER)))
postCommandSequence(CommandListRegisters);
if (debuggerCore()->isDockVisible(QLatin1String(DOCKWIDGET_MODULES)))
if (Internal::isDockVisible(QLatin1String(DOCKWIDGET_MODULES)))
postCommandSequence(CommandListModules);
}
// After the sequence has been sent off and CDB is pondering the commands,
@@ -2920,7 +2920,7 @@ void CdbEngine::attemptBreakpointSynchronization()
&& parameters.type == BreakpointByFileAndLine
&& boolSetting(CdbBreakPointCorrection)) {
if (lineCorrection.isNull())
lineCorrection.reset(new BreakpointCorrectionContext(debuggerCore()->cppCodeModelSnapshot(),
lineCorrection.reset(new BreakpointCorrectionContext(Internal::cppCodeModelSnapshot(),
CppTools::CppModelManager::instance()->workingCopy()));
response.lineNumber = lineCorrection->fixLineNumber(parameters.fileName, parameters.lineNumber);
postBuiltinCommand(

View File

@@ -49,8 +49,6 @@ namespace CPlusPlus { class Snapshot; }
namespace Utils { class SavedAction; }
namespace ProjectExplorer { class RunControl; }
namespace Debugger {
class DebuggerEngine;
@@ -68,52 +66,36 @@ enum TestCases
TestNoBoundsOfCurrentFunction = 1
};
class DebuggerCore : public QObject
{
Q_OBJECT
public:
DebuggerCore() {}
virtual void updateState(DebuggerEngine *engine) = 0;
virtual void updateWatchersWindow(bool showWatch, bool showReturn) = 0;
virtual QIcon locationMarkIcon() const = 0;
virtual const CPlusPlus::Snapshot &cppCodeModelSnapshot() const = 0;
virtual bool hasSnapshots() const = 0;
virtual void openTextEditor(const QString &titlePattern, const QString &contents) = 0;
virtual bool isActiveDebugLanguage(int language) const = 0;
// Some convenience.
void updateState(DebuggerEngine *engine);
void updateWatchersWindow(bool showWatch, bool showReturn);
QIcon locationMarkIcon();
const CPlusPlus::Snapshot &cppCodeModelSnapshot();
bool hasSnapshots();
void openTextEditor(const QString &titlePattern, const QString &contents);
bool isActiveDebugLanguage(int language);
// void runTest(const QString &fileName);
virtual void showMessage(const QString &msg, int channel, int timeout = -1) = 0;
void showMessage(const QString &msg, int channel, int timeout = -1);
virtual bool isReverseDebugging() const = 0;
virtual void runControlStarted(DebuggerEngine *engine) = 0;
virtual void runControlFinished(DebuggerEngine *engine) = 0;
virtual void displayDebugger(DebuggerEngine *engine, bool updateEngine) = 0;
virtual DebuggerLanguages activeLanguages() const = 0;
virtual void synchronizeBreakpoints() = 0;
bool isReverseDebugging();
void runControlStarted(DebuggerEngine *engine);
void runControlFinished(DebuggerEngine *engine);
void displayDebugger(DebuggerEngine *engine, bool updateEngine);
DebuggerLanguages activeLanguages();
void synchronizeBreakpoints();
virtual bool initialize(const QStringList &arguments, QString *errorMessage) = 0;
virtual QWidget *mainWindow() const = 0;
virtual bool isDockVisible(const QString &objectName) const = 0;
virtual void showModuleSymbols(const QString &moduleName,
const QVector<Symbol> &symbols) = 0;
virtual void showModuleSections(const QString &moduleName,
const QVector<Section> &sections) = 0;
virtual void openMemoryEditor() = 0;
virtual void languagesChanged() = 0;
QWidget *mainWindow();
bool isDockVisible(const QString &objectName);
void showModuleSymbols(const QString &moduleName, const QVector<Internal::Symbol> &symbols);
void showModuleSections(const QString &moduleName, const QVector<Internal::Section> &sections);
void openMemoryEditor();
virtual void setThreads(const QStringList &list, int index) = 0;
void setThreads(const QStringList &list, int index);
virtual QSharedPointer<GlobalDebuggerOptions> globalDebuggerOptions() const = 0;
QSharedPointer<Internal::GlobalDebuggerOptions> globalDebuggerOptions();
static QTreeView *inspectorView();
public slots:
virtual void attachExternalApplication(ProjectExplorer::RunControl *rc) = 0;
};
// Some convenience.
QTreeView *inspectorView();
QVariant sessionValue(const QByteArray &name);
void setSessionValue(const QByteArray &name, const QVariant &value);
QVariant configValue(const QByteArray &name);
@@ -127,9 +109,6 @@ QStringList stringListSetting(int code);
BreakHandler *breakHandler();
DebuggerEngine *currentEngine();
// This is the only way to access the global object.
DebuggerCore *debuggerCore();
QMessageBox *showMessageBox(int icon, const QString &title,
const QString &text, int buttons = 0);

View File

@@ -493,7 +493,7 @@ void DebuggerEngine::showMessage(const QString &msg, int channel, int timeout) c
if (channel == ConsoleOutput && consoleManager)
consoleManager->printToConsolePane(QmlJS::ConsoleItem::UndefinedType, msg);
debuggerCore()->showMessage(msg, channel, timeout);
Internal::showMessage(msg, channel, timeout);
if (d->m_runControl) {
switch (channel) {
case AppOutput:
@@ -577,7 +577,7 @@ void DebuggerEngine::gotoLocation(const Location &loc)
if (loc.needsMarker()) {
d->m_locationMark.reset(new TextEditor::TextMark(file, line));
d->m_locationMark->setIcon(debuggerCore()->locationMarkIcon());
d->m_locationMark->setIcon(Internal::locationMarkIcon());
d->m_locationMark->setPriority(TextEditor::TextMark::HighPriority);
}
@@ -971,7 +971,7 @@ void DebuggerEngine::notifyInferiorSpontaneousStop()
showStatusMessage(tr("Stopped."));
setState(InferiorStopOk);
if (boolSetting(RaiseOnInterrupt))
ICore::raiseWindow(debuggerCore()->mainWindow());
ICore::raiseWindow(Internal::mainWindow());
}
void DebuggerEngine::notifyInferiorStopFailed()
@@ -1219,7 +1219,7 @@ void DebuggerEngine::updateViews()
// The slave engines are not entitled to change the view. Their wishes
// should be coordinated by their master engine.
if (isMasterEngine())
debuggerCore()->updateState(this);
Internal::updateState(this);
}
bool DebuggerEngine::isSlaveEngine() const
@@ -1312,7 +1312,7 @@ qint64 DebuggerEngine::inferiorPid() const
bool DebuggerEngine::isReverseDebugging() const
{
return debuggerCore()->isReverseDebugging();
return Internal::isReverseDebugging();
}
// Called by DebuggerRunControl.
@@ -1799,7 +1799,7 @@ void DebuggerEngine::validateExecutable(DebuggerStartParameters *sp)
Utils::ElfData elfData = reader.readHeaders();
QString error = reader.errorString();
debuggerCore()->showMessage(_("EXAMINING ") + binary, LogDebug);
Internal::showMessage(_("EXAMINING ") + binary, LogDebug);
QByteArray msg = "ELF SECTIONS: ";
static QList<QByteArray> interesting;
@@ -1823,16 +1823,16 @@ void DebuggerEngine::validateExecutable(DebuggerStartParameters *sp)
if (interesting.contains(header.name))
seen.insert(header.name);
}
debuggerCore()->showMessage(_(msg), LogDebug);
Internal::showMessage(_(msg), LogDebug);
if (!error.isEmpty()) {
debuggerCore()->showMessage(_("ERROR WHILE READING ELF SECTIONS: ") + error,
Internal::showMessage(_("ERROR WHILE READING ELF SECTIONS: ") + error,
LogDebug);
return;
}
if (elfData.sectionHeaders.isEmpty()) {
debuggerCore()->showMessage(_("NO SECTION HEADERS FOUND. IS THIS AN EXECUTABLE?"),
Internal::showMessage(_("NO SECTION HEADERS FOUND. IS THIS AN EXECUTABLE?"),
LogDebug);
return;
}
@@ -1842,7 +1842,7 @@ void DebuggerEngine::validateExecutable(DebuggerStartParameters *sp)
bool hasEmbeddedInfo = elfData.indexOf(".debug_info") >= 0;
bool hasLink = elfData.indexOf(".gnu_debuglink") >= 0;
if (hasEmbeddedInfo) {
QSharedPointer<GlobalDebuggerOptions> options = debuggerCore()->globalDebuggerOptions();
QSharedPointer<GlobalDebuggerOptions> options = Internal::globalDebuggerOptions();
SourcePathRegExpMap globalRegExpSourceMap;
globalRegExpSourceMap.reserve(options->sourcePathRegExpMap.size());
foreach (auto entry, options->sourcePathRegExpMap) {

View File

@@ -102,7 +102,7 @@ public slots:
void updateUiForCurrentRunConfiguration();
void updateActiveLanguages();
void updateDockWidgetSettings();
void openMemoryEditor() { debuggerCore()->openMemoryEditor(); }
void openMemoryEditor() { Internal::openMemoryEditor(); }
public:
DebuggerMainWindow *q;
@@ -231,10 +231,8 @@ void DebuggerMainWindowPrivate::updateActiveLanguages()
newLanguages |= QmlLanguage;
}
if (newLanguages != m_activeDebugLanguages) {
if (newLanguages != m_activeDebugLanguages)
m_activeDebugLanguages = newLanguages;
debuggerCore()->languagesChanged();
}
if (m_changingUI || !m_inDebugMode)
return;

View File

@@ -374,6 +374,7 @@ sg1: }
using namespace Core;
using namespace Debugger::Constants;
using namespace Debugger::Internal;
using namespace ExtensionSystem;
using namespace ProjectExplorer;
using namespace TextEditor;
@@ -535,8 +536,8 @@ static QWidget *addSearch(BaseTreeView *treeView, const QString &title,
{
QAction *act = action(UseAlternatingRowColors);
treeView->setAlternatingRowColors(act->isChecked());
QObject::connect(act, SIGNAL(toggled(bool)),
treeView, SLOT(setAlternatingRowColorsHelper(bool)));
QObject::connect(act, &QAction::toggled,
treeView, &BaseTreeView::setAlternatingRowColorsHelper);
QWidget *widget = ItemViewFind::createSearchableWrapper(treeView);
widget->setObjectName(QLatin1String(objectName));
@@ -595,7 +596,7 @@ static bool currentTextEditorPosition(ContextData *data)
//
///////////////////////////////////////////////////////////////////////
static DebuggerPluginPrivate *theDebuggerCore = 0;
static DebuggerPluginPrivate *dd = 0;
/*!
\class Debugger::Internal::DebuggerCore
@@ -611,7 +612,7 @@ static DebuggerPluginPrivate *theDebuggerCore = 0;
Implementation of DebuggerCore.
*/
class DebuggerPluginPrivate : public DebuggerCore
class DebuggerPluginPrivate : public QObject
{
Q_OBJECT
@@ -774,17 +775,12 @@ public slots:
void attachToUnstartedApplicationDialog();
void attachToFoundProcess();
void continueOnAttach(Debugger::DebuggerState state);
void attachExternalApplication(ProjectExplorer::RunControl *rc);
void attachToQmlPort();
void runScheduled();
void attachCore();
void enableReverseDebuggingTriggered(const QVariant &value);
void languagesChanged();
void showStatusMessage(const QString &msg, int timeout = -1);
void openMemoryEditor();
const CPlusPlus::Snapshot &cppCodeModelSnapshot() const;
DebuggerMainWindow *mainWindow() const { return m_mainWindow; }
@@ -794,16 +790,10 @@ public slots:
return dock && dock->toggleViewAction()->isChecked();
}
bool hasSnapshots() const { return m_snapshotHandler->size(); }
void createNewDock(QWidget *widget);
void runControlStarted(DebuggerEngine *engine);
void runControlFinished(DebuggerEngine *engine);
DebuggerLanguages activeLanguages() const;
void remoteCommand(const QStringList &options, const QStringList &);
bool isReverseDebugging() const;
void displayDebugger(DebuggerEngine *engine, bool updateEngine = true);
void dumpLog();
@@ -1049,26 +1039,13 @@ public slots:
}
}
bool isActiveDebugLanguage(int lang) const
{
return m_mainWindow->activeDebugLanguages() & lang;
}
QIcon locationMarkIcon() const { return m_locationMarkIcon; }
void openTextEditor(const QString &titlePattern0, const QString &contents);
void showMessage(const QString &msg, int channel, int timeout = -1);
void showModuleSymbols(const QString &moduleName, const Symbols &symbols);
void showModuleSections(const QString &moduleName, const Sections &sections);
bool parseArgument(QStringList::const_iterator &it,
const QStringList::const_iterator &cend, QString *errorMessage);
bool parseArguments(const QStringList &args, QString *errorMessage);
void parseCommandLineArguments();
QSharedPointer<GlobalDebuggerOptions> globalDebuggerOptions() const { return m_globalDebuggerOptions; }
void updateQmlActions() {
action(QmlUpdateOnSave)->setEnabled(boolSetting(ShowQmlObjectTree));
}
@@ -1179,8 +1156,8 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) :
qRegisterMetaType<ContextData>("ContextData");
qRegisterMetaType<DebuggerStartParameters>("DebuggerStartParameters");
QTC_CHECK(!theDebuggerCore);
theDebuggerCore = this;
QTC_CHECK(!dd);
dd = this;
m_plugin = plugin;
@@ -1248,11 +1225,6 @@ DebuggerEngine *DebuggerPluginPrivate::dummyEngine()
return m_dummyEngine;
}
DebuggerCore *debuggerCore()
{
return theDebuggerCore;
}
static QString msgParameterMissing(const QString &a)
{
return DebuggerPlugin::tr("Option \"%1\" is missing the parameter.").arg(a);
@@ -1381,7 +1353,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
Q_UNUSED(errorMessage);
m_arguments = arguments;
if (!m_arguments.isEmpty())
connect(KitManager::instance(), SIGNAL(kitsLoaded()), this, SLOT(parseCommandLineArguments()));
connect(KitManager::instance(), &KitManager::kitsLoaded,
this, &DebuggerPluginPrivate::parseCommandLineArguments);
// Cpp/Qml ui setup
m_mainWindow = new DebuggerMainWindow;
@@ -1442,10 +1415,6 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project)
setProxyAction(m_visibleStartAction, Core::Id(Constants::DEBUG));
}
void DebuggerPluginPrivate::languagesChanged()
{
}
void DebuggerPluginPrivate::debugProject()
{
ProjectExplorerPlugin::runProject(SessionManager::startupProject(), DebugRunMode);
@@ -1575,13 +1544,12 @@ void DebuggerPluginPrivate::attachToProcess(bool startServerOnly)
}
}
void DebuggerPluginPrivate::attachToUnstartedApplicationDialog()
{
UnstartedAppWatcherDialog *dlg = new UnstartedAppWatcherDialog(ICore::dialogParent());
connect(dlg, SIGNAL(finished(int)), dlg, SLOT(deleteLater()));
connect(dlg, SIGNAL(processFound()), this, SLOT(attachToFoundProcess()));
connect(dlg, &QDialog::finished, dlg, &QObject::deleteLater);
connect(dlg, &UnstartedAppWatcherDialog::processFound, this, &DebuggerPluginPrivate::attachToFoundProcess);
dlg->show();
}
@@ -1596,11 +1564,11 @@ void DebuggerPluginPrivate::attachToFoundProcess()
return;
if (dlg->hideOnAttach())
connect(rc, SIGNAL(finished()), dlg, SLOT(startWatching()));
connect(rc, &RunControl::finished, dlg, &UnstartedAppWatcherDialog::startWatching);
if (dlg->continueOnAttach()) {
connect(currentEngine(), SIGNAL(stateChanged(Debugger::DebuggerState)),
this, SLOT(continueOnAttach(Debugger::DebuggerState)));
connect(currentEngine(), &DebuggerEngine::stateChanged,
this, &DebuggerPluginPrivate::continueOnAttach);
}
}
@@ -1654,7 +1622,7 @@ DebuggerRunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit,
return DebuggerRunControlFactory::createAndScheduleRun(sp);
}
void DebuggerPluginPrivate::attachExternalApplication(RunControl *rc)
void DebuggerPlugin::attachExternalApplication(RunControl *rc)
{
DebuggerStartParameters sp;
sp.attachPID = rc->applicationProcessHandle().pid();
@@ -2385,23 +2353,16 @@ void DebuggerPluginPrivate::showStatusMessage(const QString &msg0, int timeout)
m_statusLabel->showStatusMessage(msg, timeout);
}
void DebuggerPluginPrivate::openMemoryEditor()
{
AddressDialog dialog;
if (dialog.exec() == QDialog::Accepted)
currentEngine()->openMemoryView(dialog.address(), 0, QList<MemoryMarkup>(), QPoint());
}
void DebuggerPluginPrivate::coreShutdown()
{
m_shuttingDown = true;
}
const CPlusPlus::Snapshot &DebuggerPluginPrivate::cppCodeModelSnapshot() const
const CPlusPlus::Snapshot &cppCodeModelSnapshot()
{
if (m_codeModelSnapshot.isEmpty() && action(UseCodeModel)->isChecked())
m_codeModelSnapshot = CppTools::CppModelManager::instance()->snapshot();
return m_codeModelSnapshot;
if (dd->m_codeModelSnapshot.isEmpty() && action(UseCodeModel)->isChecked())
dd->m_codeModelSnapshot = CppTools::CppModelManager::instance()->snapshot();
return dd->m_codeModelSnapshot;
}
void setSessionValue(const QByteArray &key, const QVariant &value)
@@ -2414,21 +2375,9 @@ QVariant sessionValue(const QByteArray &key)
return SessionManager::value(QString::fromUtf8(key));
}
QTreeView *DebuggerCore::inspectorView()
QTreeView *inspectorView()
{
return theDebuggerCore->m_inspectorView;
}
void DebuggerPluginPrivate::openTextEditor(const QString &titlePattern0,
const QString &contents)
{
if (m_shuttingDown)
return;
QString titlePattern = titlePattern0;
IEditor *editor = EditorManager::openEditorWithContents(
CC::K_DEFAULT_TEXT_EDITOR_ID, &titlePattern, contents.toUtf8(),
EditorManager::IgnoreNavigationHistory);
QTC_ASSERT(editor, return);
return dd->m_inspectorView;
}
void DebuggerPluginPrivate::showMessage(const QString &msg, int channel, int timeout)
@@ -2459,10 +2408,9 @@ void DebuggerPluginPrivate::showMessage(const QString &msg, int channel, int tim
}
}
void DebuggerPluginPrivate::createNewDock(QWidget *widget)
void createNewDock(QWidget *widget)
{
QDockWidget *dockWidget =
m_mainWindow->createDockWidget(CppLanguage, widget);
QDockWidget *dockWidget = dd->m_mainWindow->createDockWidget(CppLanguage, widget);
dockWidget->setWindowTitle(widget->windowTitle());
dockWidget->setFeatures(QDockWidget::DockWidgetClosable);
dockWidget->show();
@@ -2567,17 +2515,6 @@ void DebuggerPluginPrivate::remoteCommand(const QStringList &options,
runScheduled();
}
DebuggerLanguages DebuggerPluginPrivate::activeLanguages() const
{
QTC_ASSERT(m_mainWindow, return AnyLanguage);
return m_mainWindow->activeDebugLanguages();
}
bool DebuggerPluginPrivate::isReverseDebugging() const
{
return m_reverseDirectionAction->isChecked();
}
QMessageBox *showMessageBox(int icon, const QString &title,
const QString &text, int buttons)
{
@@ -3133,36 +3070,36 @@ void DebuggerPluginPrivate::extensionsInitialized()
//
// Core
connect(ICore::instance(), SIGNAL(saveSettingsRequested()), SLOT(writeSettings()));
connect(ICore::instance(), &ICore::saveSettingsRequested,
this, &DebuggerPluginPrivate::writeSettings);
// TextEditor
connect(TextEditorSettings::instance(),
SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
SLOT(fontSettingsChanged(TextEditor::FontSettings)));
connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged,
this, &DebuggerPluginPrivate::fontSettingsChanged);
// ProjectExplorer
connect(SessionManager::instance(), SIGNAL(sessionLoaded(QString)),
SLOT(sessionLoaded()));
connect(SessionManager::instance(), SIGNAL(aboutToSaveSession()),
SLOT(aboutToSaveSession()));
connect(SessionManager::instance(), SIGNAL(aboutToUnloadSession(QString)),
SLOT(aboutToUnloadSession()));
connect(ProjectExplorerPlugin::instance(), SIGNAL(updateRunActions()),
SLOT(updateDebugActions()));
connect(SessionManager::instance(), &SessionManager::sessionLoaded,
this, &DebuggerPluginPrivate::sessionLoaded);
connect(SessionManager::instance(), &SessionManager::aboutToSaveSession,
this, &DebuggerPluginPrivate::aboutToSaveSession);
connect(SessionManager::instance(), &SessionManager::aboutToUnloadSession,
this, &DebuggerPluginPrivate::aboutToUnloadSession);
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
this, &DebuggerPluginPrivate::updateDebugActions);
// EditorManager
connect(EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)),
SLOT(editorOpened(Core::IEditor*)));
connect(EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
SLOT(updateBreakMenuItem(Core::IEditor*)));
connect(EditorManager::instance(), &EditorManager::editorOpened,
this, &DebuggerPluginPrivate::editorOpened);
connect(EditorManager::instance(), &EditorManager::currentEditorChanged,
this, &DebuggerPluginPrivate::updateBreakMenuItem);
// Application interaction
connect(action(SettingsDialog), SIGNAL(triggered()),
SLOT(showSettingsDialog()));
connect(action(SettingsDialog), &QAction::triggered,
this, &DebuggerPluginPrivate::showSettingsDialog);
// QML Actions
connect(action(ShowQmlObjectTree), SIGNAL(valueChanged(QVariant)),
SLOT(updateQmlActions()));
connect(action(ShowQmlObjectTree), &SavedAction::valueChanged,
this, &DebuggerPluginPrivate::updateQmlActions);
updateQmlActions();
// Toolbar
@@ -3189,7 +3126,8 @@ void DebuggerPluginPrivate::extensionsInitialized()
m_threadBox = new QComboBox;
m_threadBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
connect(m_threadBox, SIGNAL(activated(int)), SLOT(selectThread(int)));
connect(m_threadBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
this, &DebuggerPluginPrivate::selectThread);
hbox->addWidget(m_threadBox);
hbox->addSpacerItem(new QSpacerItem(4, 0));
@@ -3211,16 +3149,14 @@ void DebuggerPluginPrivate::extensionsInitialized()
m_mainWindow->setToolBar(AnyLanguage, m_statusLabel);
connect(action(EnableReverseDebugging),
SIGNAL(valueChanged(QVariant)),
SLOT(enableReverseDebuggingTriggered(QVariant)));
connect(action(EnableReverseDebugging), &SavedAction::valueChanged,
this, &DebuggerPluginPrivate::enableReverseDebuggingTriggered);
setInitialState();
connectEngine(0);
connect(SessionManager::instance(),
SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
SLOT(onCurrentProjectChanged(ProjectExplorer::Project*)));
connect(SessionManager::instance(), &SessionManager::startupProjectChanged,
this, &DebuggerPluginPrivate::onCurrentProjectChanged);
m_commonOptionsPage = new CommonOptionsPage(m_globalDebuggerOptions);
m_plugin->addAutoReleasedObject(m_commonOptionsPage);
@@ -3234,37 +3170,36 @@ void DebuggerPluginPrivate::extensionsInitialized()
DebuggerEngine *currentEngine()
{
return theDebuggerCore->m_currentEngine;
return dd->m_currentEngine;
}
SavedAction *action(int code)
{
return theDebuggerCore->m_debuggerSettings->item(code);
return dd->m_debuggerSettings->item(code);
}
bool boolSetting(int code)
{
return theDebuggerCore->m_debuggerSettings->item(code)->value().toBool();
return dd->m_debuggerSettings->item(code)->value().toBool();
}
QString stringSetting(int code)
{
QString raw = theDebuggerCore->m_debuggerSettings->item(code)->value().toString();
QString raw = dd->m_debuggerSettings->item(code)->value().toString();
return globalMacroExpander()->expand(raw);
}
QStringList stringListSetting(int code)
{
return theDebuggerCore->m_debuggerSettings->item(code)->value().toStringList();
return dd->m_debuggerSettings->item(code)->value().toStringList();
}
BreakHandler *breakHandler()
{
return theDebuggerCore->m_breakHandler;
return dd->m_breakHandler;
}
void DebuggerPluginPrivate::showModuleSymbols(const QString &moduleName,
const Symbols &symbols)
void showModuleSymbols(const QString &moduleName, const Symbols &symbols)
{
QTreeWidget *w = new QTreeWidget;
w->setUniformRowHeights(true);
@@ -3274,13 +3209,13 @@ void DebuggerPluginPrivate::showModuleSymbols(const QString &moduleName,
w->setSortingEnabled(true);
w->setObjectName(QLatin1String("Symbols.") + moduleName);
QStringList header;
header.append(tr("Symbol"));
header.append(tr("Address"));
header.append(tr("Code"));
header.append(tr("Section"));
header.append(tr("Name"));
header.append(DebuggerPlugin::tr("Symbol"));
header.append(DebuggerPlugin::tr("Address"));
header.append(DebuggerPlugin::tr("Code"));
header.append(DebuggerPlugin::tr("Section"));
header.append(DebuggerPlugin::tr("Name"));
w->setHeaderLabels(header);
w->setWindowTitle(tr("Symbols in \"%1\"").arg(moduleName));
w->setWindowTitle(DebuggerPlugin::tr("Symbols in \"%1\"").arg(moduleName));
foreach (const Symbol &s, symbols) {
QTreeWidgetItem *it = new QTreeWidgetItem;
it->setData(0, Qt::DisplayRole, s.name);
@@ -3293,8 +3228,7 @@ void DebuggerPluginPrivate::showModuleSymbols(const QString &moduleName,
createNewDock(w);
}
void DebuggerPluginPrivate::showModuleSections(const QString &moduleName,
const Sections &sections)
void showModuleSections(const QString &moduleName, const Sections &sections)
{
QTreeWidget *w = new QTreeWidget;
w->setUniformRowHeights(true);
@@ -3304,13 +3238,13 @@ void DebuggerPluginPrivate::showModuleSections(const QString &moduleName,
w->setSortingEnabled(true);
w->setObjectName(QLatin1String("Sections.") + moduleName);
QStringList header;
header.append(tr("Name"));
header.append(tr("From"));
header.append(tr("To"));
header.append(tr("Address"));
header.append(tr("Flags"));
header.append(DebuggerPlugin::tr("Name"));
header.append(DebuggerPlugin::tr("From"));
header.append(DebuggerPlugin::tr("To"));
header.append(DebuggerPlugin::tr("Address"));
header.append(DebuggerPlugin::tr("Flags"));
w->setHeaderLabels(header);
w->setWindowTitle(tr("Sections in \"%1\"").arg(moduleName));
w->setWindowTitle(DebuggerPlugin::tr("Sections in \"%1\"").arg(moduleName));
foreach (const Section &s, sections) {
QTreeWidgetItem *it = new QTreeWidgetItem;
it->setData(0, Qt::DisplayRole, s.name);
@@ -3331,8 +3265,107 @@ void DebuggerPluginPrivate::aboutToShutdown()
this, 0);
}
} // namespace Internal
void updateState(DebuggerEngine *engine)
{
dd->updateState(engine);
}
void updateWatchersWindow(bool showWatch, bool showReturn)
{
dd->updateWatchersWindow(showWatch, showReturn);
}
QIcon locationMarkIcon()
{
return dd->m_locationMarkIcon;
}
bool hasSnapshots()
{
return dd->m_snapshotHandler->size();
}
void openTextEditor(const QString &titlePattern0, const QString &contents)
{
if (dd->m_shuttingDown)
return;
QString titlePattern = titlePattern0;
IEditor *editor = EditorManager::openEditorWithContents(
CC::K_DEFAULT_TEXT_EDITOR_ID, &titlePattern, contents.toUtf8(),
EditorManager::IgnoreNavigationHistory);
QTC_ASSERT(editor, return);
}
bool isActiveDebugLanguage(int language)
{
return dd->m_mainWindow->activeDebugLanguages() & language;
}
// void runTest(const QString &fileName);
void showMessage(const QString &msg, int channel, int timeout)
{
dd->showMessage(msg, channel, timeout);
}
bool isReverseDebugging()
{
return dd->m_reverseDirectionAction->isChecked();
}
void runControlStarted(DebuggerEngine *engine)
{
dd->runControlStarted(engine);
}
void runControlFinished(DebuggerEngine *engine)
{
dd->runControlFinished(engine);
}
void displayDebugger(DebuggerEngine *engine, bool updateEngine)
{
dd->displayDebugger(engine, updateEngine);
}
DebuggerLanguages activeLanguages()
{
QTC_ASSERT(dd->m_mainWindow, return AnyLanguage);
return dd->m_mainWindow->activeDebugLanguages();
}
void synchronizeBreakpoints()
{
dd->synchronizeBreakpoints();
}
QWidget *mainWindow()
{
return dd->mainWindow();
}
bool isDockVisible(const QString &objectName)
{
return dd->isDockVisible(objectName);
}
void openMemoryEditor()
{
AddressDialog dialog;
if (dialog.exec() == QDialog::Accepted)
currentEngine()->openMemoryView(dialog.address(), 0, QList<MemoryMarkup>(), QPoint());
}
void setThreads(const QStringList &list, int index)
{
dd->setThreads(list, index);
}
QSharedPointer<Internal::GlobalDebuggerOptions> globalDebuggerOptions()
{
return dd->m_globalDebuggerOptions;
}
} // namespace Internal
///////////////////////////////////////////////////////////////////////
//
@@ -3340,8 +3373,6 @@ void DebuggerPluginPrivate::aboutToShutdown()
//
///////////////////////////////////////////////////////////////////////
using namespace Debugger::Internal;
/*!
\class Debugger::DebuggerPlugin
@@ -3353,13 +3384,14 @@ using namespace Debugger::Internal;
DebuggerPlugin::DebuggerPlugin()
{
theDebuggerCore = new DebuggerPluginPrivate(this);
setObjectName(QLatin1String("DebuggerCore"));
dd = new DebuggerPluginPrivate(this);
}
DebuggerPlugin::~DebuggerPlugin()
{
delete theDebuggerCore;
theDebuggerCore = 0;
delete dd;
dd = 0;
}
bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMessage)
@@ -3382,25 +3414,25 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
KitManager::registerKitInformation(new DebuggerKitInformation);
return theDebuggerCore->initialize(arguments, errorMessage);
return dd->initialize(arguments, errorMessage);
}
IPlugin::ShutdownFlag DebuggerPlugin::aboutToShutdown()
{
theDebuggerCore->aboutToShutdown();
dd->aboutToShutdown();
return SynchronousShutdown;
}
QObject *DebuggerPlugin::remoteCommand(const QStringList &options,
const QStringList &list)
{
theDebuggerCore->remoteCommand(options, list);
dd->remoteCommand(options, list);
return 0;
}
void DebuggerPlugin::extensionsInitialized()
{
theDebuggerCore->extensionsInitialized();
dd->extensionsInitialized();
}
#ifdef WITH_TESTS
@@ -3483,7 +3515,7 @@ void DebuggerPluginPrivate::testRunProject(const DebuggerStartParameters &sp, co
{
m_testCallbacks.append(cb);
RunControl *rc = DebuggerRunControlFactory::createAndScheduleRun(sp);
connect(rc, SIGNAL(finished()), this, SLOT(testRunControlFinished()));
connect(rc, &RunControl::finished, this, &DebuggerPluginPrivate::testRunControlFinished);
}
void DebuggerPluginPrivate::testRunControlFinished()
@@ -3504,7 +3536,7 @@ void DebuggerPluginPrivate::testFinished()
//void DebuggerPlugin::testStateMachine()
//{
// theDebuggerCore->testStateMachine1();
// dd->testStateMachine1();
//}
//void DebuggerPluginPrivate::testStateMachine1()
@@ -3539,7 +3571,7 @@ void DebuggerPluginPrivate::testFinished()
void DebuggerPlugin::testBenchmark()
{
theDebuggerCore->testBenchmark1();
dd->testBenchmark1();
}
enum FakeEnum { FakeDebuggerCommonSettingsId };

View File

@@ -34,6 +34,8 @@
#include "debugger_global.h"
#include <extensionsystem/iplugin.h>
namespace ProjectExplorer { class RunControl; }
namespace Debugger {
namespace Internal {
@@ -52,6 +54,7 @@ private:
QObject *remoteCommand(const QStringList &options, const QStringList &arguments);
ShutdownFlag aboutToShutdown();
void extensionsInitialized();
Q_SLOT void attachExternalApplication(ProjectExplorer::RunControl *rc);
#ifdef WITH_TESTS
private slots:

View File

@@ -153,7 +153,7 @@ void DebuggerRunControl::start()
"Affected are breakpoints %1")
.arg(unhandledIds.join(QLatin1String(", ")));
debuggerCore()->showMessage(warningMessage, LogWarning);
Internal::showMessage(warningMessage, LogWarning);
static bool checked = true;
if (checked)
@@ -165,7 +165,7 @@ void DebuggerRunControl::start()
}
}
debuggerCore()->runControlStarted(m_engine);
Internal::runControlStarted(m_engine);
// We might get a synchronous startFailed() notification on Windows,
// when launching the process fails. Emit a proper finished() sequence.
@@ -191,7 +191,7 @@ void DebuggerRunControl::handleFinished()
appendMessage(tr("Debugging has finished") + QLatin1Char('\n'), NormalMessageFormat);
if (m_engine)
m_engine->handleFinished();
debuggerCore()->runControlFinished(m_engine);
Internal::runControlFinished(m_engine);
}
bool DebuggerRunControl::promptToStop(bool *optionalPrompt) const
@@ -422,7 +422,7 @@ DebuggerRunControl *DebuggerRunControlFactory::createAndScheduleRun(const Debugg
ProjectExplorerPlugin::showRunErrorMessage(errorMessage);
return 0;
}
debuggerCore()->showMessage(sp.startMessage, 0);
Internal::showMessage(sp.startMessage, 0);
ProjectExplorerPlugin::startRunControl(rc, DebugRunMode);
return rc;
}

View File

@@ -1115,7 +1115,7 @@ void DebuggerToolTipManager::showToolTip
tw->acquireEngine();
const Utils::WidgetContent widgetContent(tw, true);
Utils::ToolTip::show(context.mousePosition, widgetContent, debuggerCore()->mainWindow());
Utils::ToolTip::show(context.mousePosition, widgetContent, Internal::mainWindow());
}
bool DebuggerToolTipManager::eventFilter(QObject *o, QEvent *e)
@@ -1320,7 +1320,7 @@ void DebuggerToolTipManager::slotTooltipOverrideRequested
if (context.expression.isEmpty()) {
const Utils::WidgetContent widgetContent(new QLabel(tr("No valid expression")), true);
Utils::ToolTip::show(context.mousePosition, widgetContent, debuggerCore()->mainWindow());
Utils::ToolTip::show(context.mousePosition, widgetContent, Internal::mainWindow());
*handled = true;
return;
}

View File

@@ -117,7 +117,7 @@ DisassemblerAgentPrivate::DisassemblerAgentPrivate()
mimeType(_("text/x-qtcreator-generic-asm")),
resetLocationScheduled(false)
{
locationMark.setIcon(debuggerCore()->locationMarkIcon());
locationMark.setIcon(Internal::locationMarkIcon());
locationMark.setPriority(TextMark::HighPriority);
}

View File

@@ -3049,7 +3049,7 @@ void GdbEngine::handleShowModuleSymbols(const GdbResponse &response)
}
file.close();
file.remove();
debuggerCore()->showModuleSymbols(modulePath, symbols);
Internal::showModuleSymbols(modulePath, symbols);
} else {
showMessageBox(QMessageBox::Critical, tr("Cannot Read Symbols"),
tr("Cannot read symbols for module \"%1\".").arg(fileName));
@@ -3097,7 +3097,7 @@ void GdbEngine::handleShowModuleSections(const GdbResponse &response)
}
}
if (!sections.isEmpty())
debuggerCore()->showModuleSections(moduleName, sections);
Internal::showModuleSections(moduleName, sections);
}
}
@@ -3555,7 +3555,7 @@ void GdbEngine::handleMakeSnapshot(const GdbResponse &response)
void GdbEngine::reloadRegisters()
{
if (!debuggerCore()->isDockVisible(_(DOCKWIDGET_REGISTER)))
if (!Internal::isDockVisible(_(DOCKWIDGET_REGISTER)))
return;
if (state() != InferiorStopOk && state() != InferiorUnrunnable)
@@ -4250,7 +4250,7 @@ void GdbEngine::startGdb(const QStringList &args)
//showMessage(_("Assuming Qt is installed at %1").arg(qtInstallPath));
const SourcePathMap sourcePathMap =
DebuggerSourcePathMappingWidget::mergePlatformQtPath(sp,
debuggerCore()->globalDebuggerOptions()->sourcePathMap);
Internal::globalDebuggerOptions()->sourcePathMap);
const SourcePathMap completeSourcePathMap =
mergeStartParametersSourcePathMap(sp, sourcePathMap);
for (auto it = completeSourcePathMap.constBegin(), cend = completeSourcePathMap.constEnd();
@@ -4586,7 +4586,7 @@ void GdbEngine::createFullBacktrace()
void GdbEngine::handleCreateFullBacktrace(const GdbResponse &response)
{
if (response.resultClass == GdbResultDone) {
debuggerCore()->openTextEditor(_("Backtrace $"),
Internal::openTextEditor(_("Backtrace $"),
_(response.consoleStreamOutput + response.logStreamOutput));
}
}

View File

@@ -466,7 +466,7 @@ void LldbEngine::handleResponse(const QByteArray &response)
void LldbEngine::showFullBacktrace(const GdbMi &data)
{
debuggerCore()->openTextEditor(_("Backtrace $"),
Internal::openTextEditor(_("Backtrace $"),
QString::fromUtf8(QByteArray::fromHex(data.data())));
}
@@ -805,7 +805,7 @@ void LldbEngine::refreshSymbols(const GdbMi &symbols)
symbol.demangled = item["demangled"].toUtf8();
syms.append(symbol);
}
debuggerCore()->showModuleSymbols(moduleName, syms);
Internal::showModuleSymbols(moduleName, syms);
}
@@ -1232,7 +1232,7 @@ void LldbEngine::refreshLocation(const GdbMi &reportedLocation)
void LldbEngine::reloadRegisters()
{
if (debuggerCore()->isDockVisible(QLatin1String(DOCKWIDGET_REGISTER)))
if (Internal::isDockVisible(QLatin1String(DOCKWIDGET_REGISTER)))
runCommand("reportRegisters");
}

View File

@@ -439,7 +439,7 @@ void PdbEngine::handleListSymbols(const PdbResponse &response)
symbol.name = _(item["name"].data());
symbols.append(symbol);
}
debuggerCore()->showModuleSymbols(moduleName, symbols);
Internal::showModuleSymbols(moduleName, symbols);
}
//////////////////////////////////////////////////////////////////////

View File

@@ -83,7 +83,7 @@ namespace Internal {
static QTreeView *inspectorTreeView()
{
return DebuggerCore::inspectorView();
return Internal::inspectorView();
}
class ASTWalker : public Visitor

View File

@@ -214,7 +214,7 @@ void SnapshotHandler::activateSnapshot(int index)
beginResetModel();
m_currentIndex = index;
//qDebug() << "ACTIVATING INDEX: " << m_currentIndex << " OF " << size();
debuggerCore()->displayDebugger(at(index), true);
Internal::displayDebugger(at(index), true);
endResetModel();
}

View File

@@ -144,7 +144,7 @@ void SourceAgent::updateLocationMarker()
if (d->engine->stackHandler()->currentFrame().file == d->path) {
int lineNumber = d->engine->stackHandler()->currentFrame().line;
d->locationMark = new TextEditor::TextMark(QString(), lineNumber);
d->locationMark->setIcon(debuggerCore()->locationMarkIcon());
d->locationMark->setIcon(Internal::locationMarkIcon());
d->locationMark->setPriority(TextEditor::TextMark::HighPriority);
d->editor->textDocument()->addMark(d->locationMark);
QTextCursor tc = d->editor->textCursor();

View File

@@ -356,7 +356,7 @@ void ThreadsHandler::updateThreadBox()
QStringList list;
foreach (const ThreadData &thread, m_threads)
list.append(QString::fromLatin1("#%1 %2").arg(thread.id.raw()).arg(thread.name));
debuggerCore()->setThreads(list, indexOf(m_currentId));
Internal::setThreads(list, indexOf(m_currentId));
}
void ThreadsHandler::threadDataChanged(ThreadId id)

View File

@@ -150,7 +150,7 @@ class SeparatedView : public QTabWidget
Q_OBJECT
public:
SeparatedView() : QTabWidget(debuggerCore()->mainWindow())
SeparatedView() : QTabWidget(Internal::mainWindow())
{
setTabsClosable(true);
connect(this, SIGNAL(tabCloseRequested(int)), SLOT(closeTab(int)));
@@ -1902,7 +1902,7 @@ void WatchHandler::updateWatchersWindow()
return;
previousShowWatch = showWatch;
previousShowReturn = showReturn;
debuggerCore()->updateWatchersWindow(showWatch, showReturn);
Internal::updateWatchersWindow(showWatch, showReturn);
}
QStringList WatchHandler::watchedExpressions()

View File

@@ -956,7 +956,7 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
copyToClipboard(mi1.data().toString());
} else if (act == &actShowInEditor) {
QString contents = handler->editorContents();
debuggerCore()->openTextEditor(tr("Locals & Expressions"), contents);
Internal::openTextEditor(tr("Locals & Expressions"), contents);
} else if (act == &actCloseEditorToolTips) {
DebuggerToolTipManager::closeAllToolTips();
}