Debugger: Support setting substitute path by regexp

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 (variable support will also be useful -
will try to add that later).

Syntax: (/home/.*)/KnownSubdir -> /home/my/project

Capture group will be replaced by the value.

In this example the substitute path will be (in case a source string
found such as /home/SomeUser/SomeProject/KnownSubdir/foo.cpp):
/home/SomeUser/SomeProject -> /home/my/project

Change-Id: I19d03c9388161d8456a86676086dcb06dc3d7370
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Orgad Shaneh
2014-09-07 23:24:10 +03:00
committed by Orgad Shaneh
parent 63da3cb9e0
commit f0e2708d3e
8 changed files with 130 additions and 50 deletions

View File

@@ -55,7 +55,7 @@ void GlobalDebuggerOptions::toSettings() const
{
QSettings *s = Core::ICore::settings();
s->beginWriteArray(QLatin1String(sourcePathMappingArrayNameC));
if (!sourcePathMap.isEmpty()) {
if (!sourcePathMap.isEmpty() || !sourcePathRegExpMap.isEmpty()) {
const QString sourcePathMappingSourceKey = QLatin1String(sourcePathMappingSourceKeyC);
const QString sourcePathMappingTargetKey = QLatin1String(sourcePathMappingTargetKeyC);
int i = 0;
@@ -66,6 +66,13 @@ 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();
}
@@ -79,8 +86,12 @@ void GlobalDebuggerOptions::fromSettings()
const QString sourcePathMappingTargetKey = QLatin1String(sourcePathMappingTargetKeyC);
for (int i = 0; i < count; ++i) {
s->setArrayIndex(i);
sourcePathMap.insert(s->value(sourcePathMappingSourceKey).toString(),
s->value(sourcePathMappingTargetKey).toString());
const QString key = s->value(sourcePathMappingSourceKey).toString();
const QString value = s->value(sourcePathMappingTargetKey).toString();
if (key.startsWith(QLatin1Char('(')))
sourcePathRegExpMap.append(qMakePair(QRegExp(key), value));
else
sourcePathMap.insert(key, value);
}
}
s->endArray();