diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index fb44c221bd6d19b17895872329c661bb8457806d..c80a80b3ec8af247b11a1d3af5c8593213a26031 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -2377,6 +2377,8 @@ static QString formatStartParameters(DebuggerStartParameters &sp) str << " (built: " << QDir::toNativeSeparators(sp.projectBuildDir) << ')'; str << '\n'; } + if (!sp.qtInstallPath.isEmpty()) + str << "Qt: " << QDir::toNativeSeparators(sp.qtInstallPath) << '\n'; if (!sp.qmlServerAddress.isEmpty()) str << "QML server: " << sp.qmlServerAddress << ':' << sp.qmlServerPort << '\n'; if (!sp.remoteChannel.isEmpty()) { diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index 5b1c1c997e302a0b4a68659a10f1986eecbb4e73..244ae025d169320e83b668d96808bf614c7aaecf 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -64,6 +64,7 @@ #include <utils/fancymainwindow.h> #include <utils/qtcprocess.h> #include <coreplugin/icore.h> +#include <utils/buildablehelperlibrary.h> #include <QtCore/QDir> #include <QtCore/QDebug> @@ -684,6 +685,11 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu sp.dumperLibraryLocations = rc->dumperLibraryLocations(); if (const ProjectExplorer::Target *target = runConfiguration->target()) { + if (QByteArray(target->metaObject()->className()).contains("Qt4")) { + const QString qmake = Utils::BuildableHelperLibrary::findSystemQt(sp.environment); + if (!qmake.isEmpty()) + sp.qtInstallPath = findQtInstallPath(qmake); + } if (const ProjectExplorer::Project *project = target->project()) { sp.projectDir = project->projectDirectory(); if (const ProjectExplorer::BuildConfiguration *buildConfig = target->activeBuildConfiguration()) { diff --git a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp index e60059b47cf2c92c7b6e8470f5c0289823397249..94ff0473c7ac1cee1a6c303e42ef0b9c1de52bd5 100644 --- a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp +++ b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp @@ -374,5 +374,24 @@ void DebuggerSourcePathMappingWidget::slotEditTargetFieldChanged() } } +/* Merge settings for an installed Qt (unless another setting + * is already in the map. */ +DebuggerSourcePathMappingWidget::SourcePathMap + DebuggerSourcePathMappingWidget::mergePlatformQtPath(const QString &qtInstallPath, + const SourcePathMap &in) +{ + SourcePathMap rc = in; + const size_t buildPathCount = sizeof(qtBuildPaths)/sizeof(const char *); + if (qtInstallPath.isEmpty() || buildPathCount == 0) + return rc; + + for (size_t i = 0; i < buildPathCount; i++) { + const QString buildPath = QString::fromLatin1(qtBuildPaths[i]); + if (!rc.contains(buildPath)) // Do not overwrite user settings. + rc.insert(buildPath, qtInstallPath); + } + return rc; +} + } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/debuggersourcepathmappingwidget.h b/src/plugins/debugger/debuggersourcepathmappingwidget.h index e611a8631a074400956e6769dc0e4e942cdead97..058e168e9e8902fd1c9be4605105ee952a0428a3 100644 --- a/src/plugins/debugger/debuggersourcepathmappingwidget.h +++ b/src/plugins/debugger/debuggersourcepathmappingwidget.h @@ -66,6 +66,11 @@ public: SourcePathMap sourcePathMap() const; void setSourcePathMap(const SourcePathMap &); + /* Merge settings for an installed Qt (unless another setting + * is already in the map. */ + static SourcePathMap mergePlatformQtPath(const QString &qtInstallPath, + const SourcePathMap &in); + signals: private slots: diff --git a/src/plugins/debugger/debuggerstartparameters.h b/src/plugins/debugger/debuggerstartparameters.h index 2e762367834d5fc4e3def5b855f4253ac9127be0..3fd5cb2a8c977833e9f65ec7e6ae005056169bc3 100644 --- a/src/plugins/debugger/debuggerstartparameters.h +++ b/src/plugins/debugger/debuggerstartparameters.h @@ -96,6 +96,7 @@ public: QString projectBuildDir; QString projectDir; + QString qtInstallPath; // Used by remote debugging. QString remoteChannel; QString remoteArchitecture; diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index c5c945021b4a8c851639281658acf3236ca23e52..af77b4680c46842a1e18dece4067cebfe991d556 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -67,6 +67,7 @@ #include "stackhandler.h" #include "threadshandler.h" #include "watchhandler.h" +#include "debuggersourcepathmappingwidget.h" #ifdef Q_OS_WIN # include "dbgwinutils.h" @@ -4614,14 +4615,18 @@ void GdbEngine::notifyInferiorSetupFailed() void GdbEngine::handleInferiorPrepared() { + typedef GlobalDebuggerOptions::SourcePathMap SourcePathMap; + typedef SourcePathMap::const_iterator SourcePathMapIterator; + QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); // Apply source path mappings from global options. - const QSharedPointer<GlobalDebuggerOptions> globalOptions = debuggerCore()->globalDebuggerOptions(); - if (!globalOptions->sourcePathMap.isEmpty()) { - typedef GlobalDebuggerOptions::SourcePathMap::const_iterator SourcePathMapIterator; - const SourcePathMapIterator cend = globalOptions->sourcePathMap.constEnd(); - for (SourcePathMapIterator it = globalOptions->sourcePathMap.constBegin(); it != cend; ++it) { + const SourcePathMap sourcePathMap = + DebuggerSourcePathMappingWidget::mergePlatformQtPath(startParameters().qtInstallPath, + debuggerCore()->globalDebuggerOptions()->sourcePathMap); + if (!sourcePathMap.isEmpty()) { + const SourcePathMapIterator cend = sourcePathMap.constEnd(); + for (SourcePathMapIterator it = sourcePathMap.constBegin(); it != cend; ++it) { QByteArray command = "set substitute-path "; command += it.key().toLocal8Bit(); command += ' ';