diff --git a/src/plugins/debugger/commonoptionspage.cpp b/src/plugins/debugger/commonoptionspage.cpp index fcfd942443f..3301f74ec84 100644 --- a/src/plugins/debugger/commonoptionspage.cpp +++ b/src/plugins/debugger/commonoptionspage.cpp @@ -72,8 +72,6 @@ public: GlobalDebuggerOptions *options = Internal::globalDebuggerOptions(); SourcePathMap allPathMap = options->sourcePathMap; - for (const auto ®ExpMap : qAsConst(options->sourcePathRegExpMap)) - allPathMap.insert(regExpMap.first.pattern(), regExpMap.second); m_sourceMappingWidget->setSourcePathMap(allPathMap); DebuggerSettings &s = *debuggerSettings(); @@ -121,17 +119,7 @@ void CommonOptionsPageWidget::apply() m_group.writeSettings(ICore::settings()); GlobalDebuggerOptions *options = Internal::globalDebuggerOptions(); - options->sourcePathMap.clear(); - options->sourcePathRegExpMap.clear(); - - SourcePathMap allPathMap = m_sourceMappingWidget->sourcePathMap(); - for (auto it = allPathMap.begin(), end = allPathMap.end(); it != end; ++it) { - const QString key = it.key(); - if (key.startsWith('(')) - options->sourcePathRegExpMap.append(qMakePair(QRegularExpression(key), it.value())); - else - options->sourcePathMap.insert(key, it.value()); - } + options->sourcePathMap = m_sourceMappingWidget->sourcePathMap(); options->toSettings(); } diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index 21c6d8c8b0c..326ee706145 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -58,7 +58,7 @@ void GlobalDebuggerOptions::toSettings() const { QSettings *s = Core::ICore::settings(); s->beginWriteArray(sourcePathMappingArrayNameC); - if (!sourcePathMap.isEmpty() || !sourcePathRegExpMap.isEmpty()) { + if (!sourcePathMap.isEmpty()) { const QString sourcePathMappingSourceKey(sourcePathMappingSourceKeyC); const QString sourcePathMappingTargetKey(sourcePathMappingTargetKeyC); int i = 0; @@ -69,13 +69,6 @@ void GlobalDebuggerOptions::toSettings() const s->setValue(sourcePathMappingSourceKey, it.key()); s->setValue(sourcePathMappingTargetKey, it.value()); } - for (auto it = sourcePathRegExpMap.constBegin(), cend = sourcePathRegExpMap.constEnd(); - it != cend; - ++it, ++i) { - s->setArrayIndex(i); - s->setValue(sourcePathMappingSourceKey, it->first.pattern()); - s->setValue(sourcePathMappingTargetKey, it->second); - } } s->endArray(); } @@ -91,10 +84,7 @@ void GlobalDebuggerOptions::fromSettings() s->setArrayIndex(i); const QString key = s->value(sourcePathMappingSourceKey).toString(); const QString value = s->value(sourcePathMappingTargetKey).toString(); - if (key.startsWith('(')) - sourcePathRegExpMap.append(qMakePair(QRegularExpression(key), value)); - else - sourcePathMap.insert(key, value); + sourcePathMap.insert(key, value); } } s->endArray(); diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index 0930c43f8cb..e078d353de1 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -37,7 +36,6 @@ namespace Debugger { namespace Internal { using SourcePathMap = QMap; -using SourcePathRegExpMap = QVector>; // Global debugger options that are not stored as saved action. class GlobalDebuggerOptions @@ -46,8 +44,13 @@ public: void toSettings() const; void fromSettings(); + // Entries starting with '(' are considered regular expressions in the ElfReader. + // This is useful when there are multiple build machines with different + // path, and the user would like to match anything up to some known + // directory to his local project. + // Syntax: (/home/.*)/KnownSubdir -> /home/my/project + SourcePathMap sourcePathMap; - SourcePathRegExpMap sourcePathRegExpMap; }; class GeneralSettings diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index f989774d8b6..7c13b96385c 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -2813,12 +2813,14 @@ void CppDebuggerEngine::validateRunParameters(DebuggerRunParameters &rp) 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)); + QList> globalRegExpSourceMap; + globalRegExpSourceMap.reserve(options->sourcePathMap.size()); + for (auto it = options->sourcePathMap.begin(), end = options->sourcePathMap.end(); it != end; ++it) { + if (it.key().startsWith('(')) { + const QString expanded = Utils::globalMacroExpander()->expand(it.value()); + if (!expanded.isEmpty()) + globalRegExpSourceMap.push_back(qMakePair(it.key(), expanded)); + } } if (globalRegExpSourceMap.isEmpty()) return; @@ -2828,13 +2830,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; }