From 8ff480881a12d5517fe69d0cd540936b0660a37e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Fri, 18 Mar 2011 10:02:07 +0100 Subject: [PATCH] Debugger: Always add Qt install source mappings for gdb. As it fails for MinGW. Task-number: QTCREATORBUG-4132 Reviewed-by: hjk --- src/plugins/debugger/debuggerplugin.cpp | 2 ++ src/plugins/debugger/debuggerrunner.cpp | 6 ++++++ .../debuggersourcepathmappingwidget.cpp | 19 +++++++++++++++++++ .../debuggersourcepathmappingwidget.h | 5 +++++ .../debugger/debuggerstartparameters.h | 1 + src/plugins/debugger/gdb/gdbengine.cpp | 15 ++++++++++----- 6 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index fb44c221bd6..c80a80b3ec8 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 5b1c1c997e3..244ae025d16 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 e60059b47cf..94ff0473c7a 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 e611a8631a0..058e168e9e8 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 2e762367834..3fd5cb2a8c9 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 c5c945021b4..af77b4680c4 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 += ' '; -- GitLab