diff options
Diffstat (limited to 'src/plugins/debugger/debuggerengine.cpp')
-rw-r--r-- | src/plugins/debugger/debuggerengine.cpp | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 7f306bb8a5..b156ff1e18 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -78,7 +78,6 @@ #include <utils/processhandle.h> #include <utils/qtcassert.h> #include <utils/qtcprocess.h> -#include <utils/savedaction.h> #include <utils/styledbar.h> #include <utils/utilsicons.h> @@ -286,7 +285,7 @@ public: m_logWindow = new LogWindow(m_engine); // Needed before start() m_logWindow->setObjectName("Debugger.Dock.Output"); - connect(action(EnableReverseDebugging), &SavedAction::valueChanged, this, [this] { + connect(&debuggerSettings()->enableReverseDebugging, &BaseAspect::changed, this, [this] { updateState(); if (m_companionEngine) m_companionEngine->d->updateState(); @@ -427,7 +426,7 @@ public: m_watchHandler.cleanup(); m_engine->showMessage(tr("Debugger finished."), StatusBar); m_engine->setState(DebuggerFinished); // Also destroys views. - if (boolSetting(SwitchModeOnExit)) + if (debuggerSettings()->switchModeOnExit.value()) EngineManager::deactivateDebugMode(); } @@ -831,7 +830,7 @@ void DebuggerEnginePrivate::setupViews() connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged, this, [this](const FontSettings &settings) { - if (!boolSetting(FontSizeFollowsEditor)) + if (!debuggerSettings()->fontSizeFollowsEditor.value()) return; const qreal size = settings.fontZoom() * settings.fontSize() / 100.; QFont font = m_breakWindow->font(); @@ -1107,7 +1106,7 @@ void DebuggerEngine::gotoLocation(const Location &loc) &newEditor); QTC_ASSERT(editor, return); // Unreadable file? - editor->gotoLine(line, 0, !boolSetting(StationaryEditorWhileStepping)); + editor->gotoLine(line, 0, !debuggerSettings()->stationaryEditorWhileStepping.value()); if (newEditor) editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true); @@ -1369,7 +1368,7 @@ void DebuggerEngine::notifyInferiorSpontaneousStop() d->m_perspective->select(); showMessage(tr("Stopped."), StatusBar); setState(InferiorStopOk); - if (boolSetting(RaiseOnInterrupt)) + if (debuggerSettings()->raiseOnInterrupt.value()) ICore::raiseWindow(DebuggerMainWindow::instance()); } @@ -1427,8 +1426,8 @@ void DebuggerEnginePrivate::setInitialActionStates() m_jumpToLineAction.setVisible(false); m_stepOverAction.setEnabled(true); - action(AutoDerefPointers)->setEnabled(true); - action(ExpandStack)->setEnabled(false); + debuggerSettings()->autoDerefPointers.setEnabled(true); + debuggerSettings()->expandStack.setEnabled(false); m_threadLabel->setEnabled(false); } @@ -1566,9 +1565,9 @@ void DebuggerEnginePrivate::updateState() const bool actionsEnabled = m_engine->debuggerActionsEnabled(); const bool canDeref = actionsEnabled && m_engine->hasCapability(AutoDerefPointersCapability); - action(AutoDerefPointers)->setEnabled(canDeref); - action(AutoDerefPointers)->setEnabled(true); - action(ExpandStack)->setEnabled(actionsEnabled); + debuggerSettings()->autoDerefPointers.setEnabled(canDeref); + debuggerSettings()->autoDerefPointers.setEnabled(true); + debuggerSettings()->expandStack.setEnabled(actionsEnabled); const bool notbusy = state == InferiorStopOk || state == DebuggerNotReady @@ -1580,7 +1579,7 @@ void DebuggerEnginePrivate::updateState() void DebuggerEnginePrivate::updateReverseActions() { const bool stopped = m_state == InferiorStopOk; - const bool reverseEnabled = boolSetting(EnableReverseDebugging); + const bool reverseEnabled = debuggerSettings()->enableReverseDebugging.value(); const bool canReverse = reverseEnabled && m_engine->hasCapability(ReverseSteppingCapability); const bool doesRecord = m_recordForReverseOperationAction.isChecked(); @@ -1598,8 +1597,8 @@ void DebuggerEnginePrivate::updateReverseActions() void DebuggerEnginePrivate::cleanupViews() { - const bool closeSource = boolSetting(CloseSourceBuffersOnExit); - const bool closeMemory = boolSetting(CloseMemoryBuffersOnExit); + const bool closeSource = debuggerSettings()->closeSourceBuffersOnExit.value(); + const bool closeMemory = debuggerSettings()->closeMemoryBuffersOnExit.value(); QList<IDocument *> toClose; foreach (IDocument *document, DocumentModel::openedDocuments()) { @@ -1885,8 +1884,15 @@ QString DebuggerEngine::expand(const QString &string) const QString DebuggerEngine::nativeStartupCommands() const { - return expand(QStringList({stringSetting(GdbStartupCommands), - runParameters().additionalStartupCommands}).join('\n')); + QStringList lines = debuggerSettings()->gdbStartupCommands.value().split('\n'); + lines += runParameters().additionalStartupCommands.split('\n'); + + lines = Utils::filtered(lines, [](const QString line) { + const QString trimmed = line.trimmed(); + return !trimmed.isEmpty() && !trimmed.startsWith('#'); + }); + + return lines.join('\n'); } Perspective *DebuggerEngine::perspective() const @@ -2723,7 +2729,8 @@ Context CppDebuggerEngine::languageContext() const void CppDebuggerEngine::validateRunParameters(DebuggerRunParameters &rp) { - const bool warnOnRelease = boolSetting(WarnOnReleaseBuilds) && rp.toolChainAbi.osFlavor() != Abi::AndroidLinuxFlavor; + const bool warnOnRelease = debuggerSettings()->warnOnReleaseBuilds.value() + && rp.toolChainAbi.osFlavor() != Abi::AndroidLinuxFlavor; bool warnOnInappropriateDebugger = false; QString detailedWarning; switch (rp.toolChainAbi.binaryFormat()) { @@ -2817,13 +2824,16 @@ void CppDebuggerEngine::validateRunParameters(DebuggerRunParameters &rp) bool hasEmbeddedInfo = elfData.indexOf(".debug_info") >= 0; bool hasLink = elfData.indexOf(".gnu_debuglink") >= 0; if (hasEmbeddedInfo) { - const GlobalDebuggerOptions *options = Internal::globalDebuggerOptions(); - SourcePathRegExpMap globalRegExpSourceMap; - globalRegExpSourceMap.reserve(options->sourcePathRegExpMap.size()); - for (const auto &entry : qAsConst(options->sourcePathRegExpMap)) { - const QString expanded = Utils::globalMacroExpander()->expand(entry.second); - if (!expanded.isEmpty()) - globalRegExpSourceMap.push_back(qMakePair(entry.first, expanded)); + const SourcePathMap sourcePathMap = debuggerSettings()->sourcePathMap.value(); + QList<QPair<QRegularExpression, QString>> globalRegExpSourceMap; + globalRegExpSourceMap.reserve(sourcePathMap.size()); + for (auto it = sourcePathMap.begin(), end = sourcePathMap.end(); it != end; ++it) { + if (it.key().startsWith('(')) { + const QString expanded = Utils::globalMacroExpander()->expand(it.value()); + if (!expanded.isEmpty()) + globalRegExpSourceMap.push_back( + qMakePair(QRegularExpression(it.key()), expanded)); + } } if (globalRegExpSourceMap.isEmpty()) return; @@ -2833,13 +2843,11 @@ void CppDebuggerEngine::validateRunParameters(DebuggerRunParameters &rp) bool found = false; while (str < limit) { const QString string = QString::fromUtf8(str); - for (auto itExp = globalRegExpSourceMap.begin(), itEnd = globalRegExpSourceMap.end(); - itExp != itEnd; - ++itExp) { - const QRegularExpressionMatch match = itExp->first.match(string); + for (auto pair : qAsConst(globalRegExpSourceMap)) { + const QRegularExpressionMatch match = pair.first.match(string); if (match.hasMatch()) { rp.sourcePathMap.insert(string.left(match.capturedStart()) + match.captured(1), - itExp->second); + pair.second); found = true; break; } |