diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 8832acef367a4527e17d94751ab2d077bb8036a3..f2b15d42e53a521b9b8d1c0fd553e744c1cdaa89 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -2641,8 +2641,6 @@ static QString formatStartParameters(DebuggerStartParameters &sp) << ')'; 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'; diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index da14cb5ecabc7f86ce829545ba892efaad5fb35c..7e017a71cc0973c38e94d7cfca4780aff60ddc8c 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -64,7 +64,6 @@ #include <utils/qtcprocess.h> #include <coreplugin/icore.h> #include <coreplugin/helpmanager.h> -#include <utils/buildablehelperlibrary.h> #include <QDir> #include <QCheckBox> @@ -897,17 +896,6 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu sp.dumperLibraryLocations = rc->dumperLibraryLocations(); if (target) { - if (QByteArray(target->metaObject()->className()).contains("Qt4")) { - // FIXME: Get this from the profile? - // We could query the QtVersion for this information directly, but then we - // will need to add a dependency on QtSupport to the debugger. - // - // The profile could also get a method to extract the required information from - // its information to avoid this dependecy (as we do for the environment). - const FileName qmake = BuildableHelperLibrary::findSystemQt(sp.environment); - if (!qmake.isEmpty()) - sp.qtInstallPath = findQtInstallPath(qmake); - } if (const Project *project = target->project()) { sp.projectSourceDirectory = project->projectDirectory(); if (const BuildConfiguration *buildConfig = target->activeBuildConfiguration()) diff --git a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp index 1d2172b9573e2f5d93475d80621e0853fda228db..b42453de60e7d0e95b11beceaffc6a8220a00178 100644 --- a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp +++ b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp @@ -29,9 +29,12 @@ **************************************************************************/ #include "debuggersourcepathmappingwidget.h" +#include "debuggerstartparameters.h" +#include <utils/buildablehelperlibrary.h> #include <utils/pathchooser.h> #include <utils/qtcassert.h> +#include <utils/synchronousprocess.h> #include <QVBoxLayout> #include <QHBoxLayout> @@ -48,11 +51,11 @@ #include <QDir> #include <QPair> +using namespace Utils; + // Qt's various build paths for unpatched versions. #if defined(Q_OS_WIN) static const char* qtBuildPaths[] = { - "C:/qt-greenhouse/Trolltech/Code_less_create_more/" - "Trolltech/Code_less_create_more/Troll/4.6/qt", "C:/iwmake/build_mingw_opensource", "C:/ndk_buildrepos/qt-desktop/src"}; #elif defined(Q_OS_MAC) @@ -206,7 +209,7 @@ DebuggerSourcePathMappingWidget::DebuggerSourcePathMappingWidget(QWidget *parent m_addQtButton(new QPushButton(tr("Add Qt sources..."), this)), m_removeButton(new QPushButton(tr("Remove"), this)), m_sourceLineEdit(new QLineEdit(this)), - m_targetChooser(new Utils::PathChooser(this)) + m_targetChooser(new PathChooser(this)) { setTitle(tr("Source Paths Mapping")); setToolTip(tr("<html><head/><body><p>Mappings of source file folders to " @@ -245,7 +248,7 @@ DebuggerSourcePathMappingWidget::DebuggerSourcePathMappingWidget(QWidget *parent treeHLayout->addLayout(buttonLayout); // Edit part - m_targetChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory); + m_targetChooser->setExpectedKind(PathChooser::ExistingDirectory); connect(m_sourceLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotEditSourceFieldChanged())); connect(m_targetChooser, SIGNAL(changed(QString)), @@ -390,12 +393,52 @@ void DebuggerSourcePathMappingWidget::slotEditTargetFieldChanged() } } +// Find Qt installation by running qmake +static QString findQtInstallPath(const FileName &qmakePath) +{ + if (qmakePath.isEmpty()) + return QString(); + QProcess proc; + QStringList args; + args.append(QLatin1String("-query")); + args.append(QLatin1String("QT_INSTALL_HEADERS")); + proc.start(qmakePath.toString(), args); + if (!proc.waitForStarted()) { + qWarning("%s: Cannot start '%s': %s", Q_FUNC_INFO, qPrintable(qmakePath.toString()), + qPrintable(proc.errorString())); + return QString(); + } + proc.closeWriteChannel(); + if (!proc.waitForFinished()) { + SynchronousProcess::stopProcess(proc); + qWarning("%s: Timeout running '%s'.", Q_FUNC_INFO, qPrintable(qmakePath.toString())); + return QString(); + } + if (proc.exitStatus() != QProcess::NormalExit) { + qWarning("%s: '%s' crashed.", Q_FUNC_INFO, qPrintable(qmakePath.toString())); + return QString(); + } + const QByteArray ba = proc.readAllStandardOutput().trimmed(); + QDir dir(QString::fromLocal8Bit(ba)); + if (dir.exists() && dir.cdUp()) + return dir.absolutePath(); + return QString(); +} + /* Merge settings for an installed Qt (unless another setting * is already in the map. */ DebuggerSourcePathMappingWidget::SourcePathMap - DebuggerSourcePathMappingWidget::mergePlatformQtPath(const QString &qtInstallPath, + DebuggerSourcePathMappingWidget::mergePlatformQtPath(const DebuggerStartParameters &sp, const SourcePathMap &in) { + const FileName qmake = BuildableHelperLibrary::findSystemQt(sp.environment); + // FIXME: Get this from the profile? + // We could query the QtVersion for this information directly, but then we + // will need to add a dependency on QtSupport to the debugger. + // + // The profile could also get a method to extract the required information from + // its information to avoid this dependency (as we do for the environment). + const QString qtInstallPath = findQtInstallPath(qmake); SourcePathMap rc = in; const size_t buildPathCount = sizeof(qtBuildPaths)/sizeof(const char *); if (qtInstallPath.isEmpty() || buildPathCount == 0) diff --git a/src/plugins/debugger/debuggersourcepathmappingwidget.h b/src/plugins/debugger/debuggersourcepathmappingwidget.h index a49e9c9c50c42401c2cb29b3e9f90a7156b85525..1a606c1e17cf7275e44b3cb2cc1bcb38dc4da607 100644 --- a/src/plugins/debugger/debuggersourcepathmappingwidget.h +++ b/src/plugins/debugger/debuggersourcepathmappingwidget.h @@ -44,17 +44,20 @@ class QLineEdit; class QModelIndex; QT_END_NAMESPACE -namespace Utils { -class PathChooser; -} +namespace Utils { class PathChooser; } namespace Debugger { + +class DebuggerStartParameters; + namespace Internal { + class SourcePathMappingModel; class DebuggerSourcePathMappingWidget : public QGroupBox { Q_OBJECT + public: typedef QMap<QString, QString> SourcePathMap; @@ -65,11 +68,9 @@ public: /* Merge settings for an installed Qt (unless another setting * is already in the map. */ - static SourcePathMap mergePlatformQtPath(const QString &qtInstallPath, + static SourcePathMap mergePlatformQtPath(const DebuggerStartParameters &sp, const SourcePathMap &in); -signals: - private slots: void slotAdd(); void slotAddQt(); diff --git a/src/plugins/debugger/debuggerstartparameters.h b/src/plugins/debugger/debuggerstartparameters.h index 8ede708d6112bef97a98a675927da62ffcc0016c..30bd8d8db4be00c06f1da4cd6c518cdb6eaf613f 100644 --- a/src/plugins/debugger/debuggerstartparameters.h +++ b/src/plugins/debugger/debuggerstartparameters.h @@ -107,14 +107,11 @@ public: QString projectBuildDirectory; QStringList projectSourceFiles; - - QString qtInstallPath; // Used by remote debugging. QString remoteChannel; QString symbolFileName; bool useServerStartScript; QString serverStartScript; - //QString sysroot; QString searchPath; // Gdb "set solib-search-path" QString debugInfoLocation; // Gdb "set-debug-file-directory". QStringList debugSourceLocation; // Gdb "directory" @@ -125,9 +122,6 @@ public: QSsh::SshConnectionParameters connParams; bool remoteSetupNeeded; - //QString debuggerCommand; - //ProjectExplorer::Abi toolChainAbi; - QString dumperLibrary; QStringList solibSearchPath; QStringList dumperLibraryLocations; diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 4bcecc8c462bf20811ee8c1922dbeadcb700b08c..482ca8d4083163458665c06ac5747fb67f152f13 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -4797,8 +4797,9 @@ void GdbEngine::startGdb(const QStringList &args) modulesHandler()->updateModule(module); // Apply source path mappings from global options. + //showMessage(_("Assuming Qt is installed at %1").arg(qtInstallPath)); const SourcePathMap sourcePathMap = - DebuggerSourcePathMappingWidget::mergePlatformQtPath(sp.qtInstallPath, + DebuggerSourcePathMappingWidget::mergePlatformQtPath(sp, debuggerCore()->globalDebuggerOptions()->sourcePathMap); const SourcePathMapIterator cend = sourcePathMap.constEnd(); SourcePathMapIterator it = sourcePathMap.constBegin();