diff options
author | Tobias Hunger <[email protected]> | 2012-04-24 15:49:09 +0200 |
---|---|---|
committer | Tobias Hunger <[email protected]> | 2012-06-21 12:08:12 +0200 |
commit | 24314562165588b56a318b3b8a846bf5deda7c41 (patch) | |
tree | b5dcf951e76d003c2623011b0e91994e06e7e061 /src/plugins/debugger | |
parent | 8c77b8c9d7b25d0c89003c8c4a54e8da5bfb7edd (diff) |
Profile introduction
Introduce Profiles to store sets of values that describe a system/device.
These profiles are held by a target, getting rid of much of the information
stored in the Build-/Run-/DeployConfigurations, greatly simplifying those.
This is a squash of the wip/profile branch which has been on gerrit for a
while, rebased to current master.
Change-Id: I25956c8dd4d1962b2134bfaa8a8076ae3909460f
Reviewed-by: Daniel Teske <[email protected]>
Diffstat (limited to 'src/plugins/debugger')
-rw-r--r-- | src/plugins/debugger/debugger.pro | 4 | ||||
-rw-r--r-- | src/plugins/debugger/debugger.qbs | 4 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerplugin.cpp | 58 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerprofileconfigwidget.cpp | 148 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerprofileconfigwidget.h | 81 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerprofileinformation.cpp | 208 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerprofileinformation.h | 67 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerrunner.cpp | 11 | ||||
-rw-r--r-- | src/plugins/debugger/debuggertoolchaincombobox.cpp | 34 |
9 files changed, 573 insertions, 42 deletions
diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro index afe40429e6f..e633c50ab46 100644 --- a/src/plugins/debugger/debugger.pro +++ b/src/plugins/debugger/debugger.pro @@ -38,6 +38,8 @@ HEADERS += \ debuggerstartparameters.h \ debuggerstreamops.h \ debuggerstringutils.h \ + debuggerprofileconfigwidget.h \ + debuggerprofileinformation.h \ disassembleragent.h \ disassemblerlines.h \ loadremotecoredialog.h \ @@ -92,6 +94,8 @@ SOURCES += \ debuggerplugin.cpp \ debuggerrunner.cpp \ debuggerstreamops.cpp \ + debuggerprofileconfigwidget.cpp \ + debuggerprofileinformation.cpp \ disassembleragent.cpp \ disassemblerlines.cpp \ loadremotecoredialog.cpp \ diff --git a/src/plugins/debugger/debugger.qbs b/src/plugins/debugger/debugger.qbs index ca68ebc7b6a..a2de81509e8 100644 --- a/src/plugins/debugger/debugger.qbs +++ b/src/plugins/debugger/debugger.qbs @@ -36,6 +36,10 @@ QtcPlugin { "breakcondition.ui", "breakpoint.ui", "debugger.qrc", + "debuggerprofileconfigwidget.cpp", + "debuggerprofileconfigwidget.h", + "debuggerprofileinformation.cpp", + "debuggerprofileinformation.h", "attachcoredialog.ui", "attachexternaldialog.ui", "attachtoqmlportdialog.ui", diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 01846f3bf76..fecdfa25e7e 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -43,6 +43,7 @@ #include "debuggerrunner.h" #include "debuggerruncontrolfactory.h" #include "debuggerstringutils.h" +#include "debuggerprofileinformation.h" #include "memoryagent.h" #include "breakpoint.h" #include "breakhandler.h" @@ -99,6 +100,8 @@ #include <projectexplorer/projectexplorersettings.h> #include <projectexplorer/project.h> #include <projectexplorer/session.h> +#include <projectexplorer/profileinformation.h> +#include <projectexplorer/profilemanager.h> #include <projectexplorer/target.h> #include <projectexplorer/toolchain.h> #include <projectexplorer/toolchainmanager.h> @@ -2839,18 +2842,27 @@ QString DebuggerPluginPrivate::debuggerForAbi(const Abi &abi, DebuggerEngineType qDebug() << "debuggerForAbi" << abi.toString() << searchAbis.size() << searchAbis.front().toString() << et; - foreach (const Abi &searchAbi, searchAbis) { - const QList<ToolChain *> toolchains = - ToolChainManager::instance()->findToolChains(searchAbi); - // Find manually configured ones first - for (int i = toolchains.size() - 1; i >= 0; i--) { - const QString debugger = toolchains.at(i)->debuggerCommand().toString(); - if (debug) - qDebug() << i << toolchains.at(i)->displayName() << debugger; - if (!debugger.isEmpty()) - return debugger; + QList<Profile *> profileList = ProfileManager::instance()->profiles(); + // Note: stList is not sorted with autodected first! + QStringList debuggerList; + foreach (Profile *p, profileList) { + if (!p->isValid()) + continue; + ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(p); + if (!tc) + continue; + if (searchAbis.contains(tc->targetAbi())) { + const QString debugger = DebuggerProfileInformation::debuggerCommand(p).toString(); + if (!debugger.isEmpty()) { + if (p->isAutoDetected()) + debuggerList.append(debugger); + else + debuggerList.prepend(debugger); + } } } + if (!debuggerList.isEmpty()) + return debuggerList.at(0); return QString(); } @@ -3620,6 +3632,8 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess mstart->addSeparator(globalcontext, Constants::G_MANUAL_REMOTE); mstart->addSeparator(globalcontext, Constants::G_AUTOMATIC_REMOTE); + ProfileManager::instance()->registerProfileInformation(new DebuggerProfileInformation); + return theDebuggerCore->initialize(arguments, errorMessage); } @@ -3711,35 +3725,23 @@ void DebuggerPluginPrivate::testUnloadProject() invoke<void>(pe, "unloadProject"); } -static Project *currentProject() -{ - return ProjectExplorerPlugin::instance()->currentProject(); -} - static Target *activeTarget() { - Project *project = currentProject(); + Project *project = ProjectExplorerPlugin::instance()->currentProject(); return project->activeTarget(); } -static BuildConfiguration *activeBuildConfiguration() -{ - return activeTarget()->activeBuildConfiguration(); -} - -static RunConfiguration *activeRunConfiguration() -{ - return activeTarget()->activeRunConfiguration(); -} - static ToolChain *currentToolChain() { - return activeBuildConfiguration()->toolChain(); + Target *t = activeTarget(); + if (!t || !t->isEnabled()) + return 0; + return ToolChainProfileInformation::toolChain(activeTarget()->profile()); } static LocalApplicationRunConfiguration *activeLocalRunConfiguration() { - return qobject_cast<LocalApplicationRunConfiguration *>(activeRunConfiguration()); + return qobject_cast<LocalApplicationRunConfiguration *>(activeTarget()->activeRunConfiguration()); } void DebuggerPluginPrivate::testRunProject(const DebuggerStartParameters &sp, const TestCallBack &cb) diff --git a/src/plugins/debugger/debuggerprofileconfigwidget.cpp b/src/plugins/debugger/debuggerprofileconfigwidget.cpp new file mode 100644 index 00000000000..735a2584a76 --- /dev/null +++ b/src/plugins/debugger/debuggerprofileconfigwidget.cpp @@ -0,0 +1,148 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation ([email protected]) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at [email protected]. +** +**************************************************************************/ + +#include "debuggerprofileconfigwidget.h" + +#include "debuggerprofileinformation.h" + +#include <projectexplorer/abi.h> +#include <projectexplorer/profileinformation.h> + +#include <utils/pathchooser.h> +#include <utils/qtcassert.h> + +#ifdef Q_OS_WIN +#include <utils/winutils.h> +#endif + +#include <QUrl> + +#include <QDesktopServices> +#include <QHBoxLayout> +#include <QPushButton> +#include <QVBoxLayout> + +namespace Debugger { +namespace Internal { + + +static const char dgbToolsDownloadLink32C[] = "http://www.microsoft.com/whdc/devtools/debugging/installx86.Mspx"; +static const char dgbToolsDownloadLink64C[] = "http://www.microsoft.com/whdc/devtools/debugging/install64bit.Mspx"; +// ----------------------------------------------------------------------- +// DebuggerProfileConfigWidget: +// ----------------------------------------------------------------------- + +DebuggerProfileConfigWidget::DebuggerProfileConfigWidget(ProjectExplorer::Profile *p, + const DebuggerProfileInformation *pi, + QWidget *parent) : + ProjectExplorer::ProfileConfigWidget(parent), + m_profile(p), + m_info(pi), + m_chooser(new Utils::PathChooser) +{ + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(0); + + ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(p); + if (tc && tc->targetAbi().os() == ProjectExplorer::Abi::WindowsOS + && tc->targetAbi().osFlavor() != ProjectExplorer::Abi::WindowsMSysFlavor) { + QLabel *msvcDebuggerConfigLabel = new QLabel; +#ifdef Q_OS_WIN + const bool is64bit = Utils::winIs64BitSystem(); +#else + const bool is64bit = false; +#endif + const QString link = is64bit ? QLatin1String(dgbToolsDownloadLink64C) : QLatin1String(dgbToolsDownloadLink32C); + //: Label text for path configuration. %2 is "x-bit version". + msvcDebuggerConfigLabel->setText(tr("<html><body><p>Specify the path to the " + "<a href=\"%1\">Windows Console Debugger executable</a>" + " (%2) here.</p>" + "</body></html>").arg(link, (is64bit ? tr("64-bit version") + : tr("32-bit version")))); + msvcDebuggerConfigLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); + msvcDebuggerConfigLabel->setOpenExternalLinks(true); + layout->addWidget(msvcDebuggerConfigLabel); + + } + + m_chooser->setContentsMargins(0, 0, 0, 0); + m_chooser->setExpectedKind(Utils::PathChooser::ExistingCommand); + + QPushButton *button = new QPushButton(tr("Auto detect")); + button->setContentsMargins(0, 0, 0, 0); + connect(button, SIGNAL(clicked()), this, SLOT(autoDetectDebugger())); + + QHBoxLayout *box = dynamic_cast<QHBoxLayout *>(m_chooser->layout()); + QTC_CHECK(box); + if (box) + box->insertWidget(1, button); + layout->addWidget(m_chooser); + + discard(); + connect(m_chooser, SIGNAL(changed(QString)), this, SIGNAL(dirty())); +} + +QString DebuggerProfileConfigWidget::displayName() const +{ + return tr("Debugger command:"); +} + +void DebuggerProfileConfigWidget::makeReadOnly() +{ + m_chooser->setEnabled(false); +} + +void DebuggerProfileConfigWidget::apply() +{ + Utils::FileName fn = m_chooser->fileName(); + DebuggerProfileInformation::setDebuggerCommand(m_profile, fn); +} + +void DebuggerProfileConfigWidget::discard() +{ + m_chooser->setFileName(DebuggerProfileInformation::debuggerCommand(m_profile)); +} + +bool DebuggerProfileConfigWidget::isDirty() const +{ + return m_chooser->fileName() != DebuggerProfileInformation::debuggerCommand(m_profile); +} + +void DebuggerProfileConfigWidget::autoDetectDebugger() +{ + QVariant v = m_info->defaultValue(m_profile); + m_chooser->setFileName(Utils::FileName::fromString(v.toString())); +} + +} // namespace Internal + +} // namespace Debugger diff --git a/src/plugins/debugger/debuggerprofileconfigwidget.h b/src/plugins/debugger/debuggerprofileconfigwidget.h new file mode 100644 index 00000000000..f0bc7e329de --- /dev/null +++ b/src/plugins/debugger/debuggerprofileconfigwidget.h @@ -0,0 +1,81 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation ([email protected]) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at [email protected]. +** +**************************************************************************/ + +#ifndef DEBUGGER_DEBUGGERPROFILECONFIGWIDGET_H +#define DEBUGGER_DEBUGGERPROFILECONFIGWIDGET_H + +#include <projectexplorer/profileconfigwidget.h> + +#include <QLabel> +#include <debuggerprofileinformation.h> + +namespace ProjectExplorer { class Profile; } +namespace Utils { class PathChooser; } + +namespace Debugger { +class DebuggerProfileInformation; + +namespace Internal { +// ----------------------------------------------------------------------- +// DebuggerProfileConfigWidget: +// ----------------------------------------------------------------------- + +class DebuggerProfileConfigWidget : public ProjectExplorer::ProfileConfigWidget +{ + Q_OBJECT + +public: + DebuggerProfileConfigWidget(ProjectExplorer::Profile *p, + const DebuggerProfileInformation *pi, + QWidget *parent = 0); + + QString displayName() const; + + void makeReadOnly(); + + void apply(); + void discard(); + bool isDirty() const; + +private slots: + void autoDetectDebugger(); + +private: + ProjectExplorer::Profile *m_profile; + const DebuggerProfileInformation *m_info; + Utils::PathChooser *m_chooser; +}; + +} // namespace Internal +} // namespace Debugger + +#endif // DEBUGGER_DEBUGGERPROFILEINFORMATION_H diff --git a/src/plugins/debugger/debuggerprofileinformation.cpp b/src/plugins/debugger/debuggerprofileinformation.cpp new file mode 100644 index 00000000000..e644978fa93 --- /dev/null +++ b/src/plugins/debugger/debuggerprofileinformation.cpp @@ -0,0 +1,208 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation ([email protected]) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at [email protected]. +** +**************************************************************************/ + +#include "debuggerprofileinformation.h" + +#include "debuggerprofileconfigwidget.h" + +#include <projectexplorer/abi.h> +#include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/toolchain.h> + +#include <utils/environment.h> + +#include <QDir> +#include <QPair> + +// -------------------------------------------------------------------------- +// Helpers: +// -------------------------------------------------------------------------- + +static QPair<QString, QString> autoDetectCdbDebugger() +{ + QPair<QString, QString> result; + QList<Utils::FileName> cdbs; + + QStringList programDirs; + programDirs.append(QString::fromLocal8Bit(qgetenv("ProgramFiles"))); + programDirs.append(QString::fromLocal8Bit(qgetenv("ProgramFiles(x86)"))); + programDirs.append(QString::fromLocal8Bit(qgetenv("ProgramW6432"))); + + foreach (const QString &dirName, programDirs) { + if (dirName.isEmpty()) + continue; + QDir dir(dirName); + // Windows SDK's starting from version 8 live in + // "ProgramDir\Windows Kits\<version>" + const QString windowsKitsFolderName = QLatin1String("Windows Kits"); + if (dir.exists(windowsKitsFolderName)) { + QDir windowKitsFolder = dir; + if (windowKitsFolder.cd(windowsKitsFolderName)) { + // Check in reverse order (latest first) + const QFileInfoList kitFolders = + windowKitsFolder.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, + QDir::Time | QDir::Reversed); + foreach (const QFileInfo &kitFolderFi, kitFolders) { + const QString path = kitFolderFi.absoluteFilePath(); + const QFileInfo cdb32(path + QLatin1String("/Debuggers/x86/cdb.exe")); + if (cdb32.isExecutable()) + cdbs.push_back(Utils::FileName::fromString(cdb32.absoluteFilePath())); + const QFileInfo cdb64(path + QLatin1String("/Debuggers/x64/cdb.exe")); + if (cdb64.isExecutable()) + cdbs.push_back(Utils::FileName::fromString(cdb64.absoluteFilePath())); + } // for Kits + } // can cd to "Windows Kits" + } // "Windows Kits" exists + + // Pre Windows SDK 8: Check 'Debugging Tools for Windows' + foreach (const QFileInfo &fi, dir.entryInfoList(QStringList(QLatin1String("Debugging Tools for Windows*")), + QDir::Dirs | QDir::NoDotAndDotDot)) { + Utils::FileName filePath(fi); + filePath.appendPath(QLatin1String("cdb.exe")); + if (!cdbs.contains(filePath)) + cdbs.append(filePath); + } + } + + foreach (const Utils::FileName &cdb, cdbs) { + QList<ProjectExplorer::Abi> abis = ProjectExplorer::Abi::abisOfBinary(cdb); + if (abis.isEmpty()) + continue; + if (abis.first().wordWidth() == 32) + result.first = cdb.toString(); + else if (abis.first().wordWidth() == 64) + result.second = cdb.toString(); + } + + // prefer 64bit debugger, even for 32bit binaries: + if (!result.second.isEmpty()) + result.first = result.second; + + return result; +} + +namespace Debugger { + +// -------------------------------------------------------------------------- +// DebuggerProfileInformation: +// -------------------------------------------------------------------------- + +static const char DEBUGGER_INFORMATION[] = "Debugger.Information"; + +DebuggerProfileInformation::DebuggerProfileInformation() +{ + setObjectName(QLatin1String("DebuggerProfileInformation")); +} + +Core::Id DebuggerProfileInformation::dataId() const +{ + static Core::Id id = Core::Id(DEBUGGER_INFORMATION); + return id; +} + +unsigned int DebuggerProfileInformation::priority() const +{ + return 28000; +} + +QVariant DebuggerProfileInformation::defaultValue(ProjectExplorer::Profile *p) const +{ + ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(p); + ProjectExplorer::Abi abi = ProjectExplorer::Abi::hostAbi(); + if (tc) + abi = tc->targetAbi(); + + // CDB for windows: + if (abi.os() == ProjectExplorer::Abi::WindowsOS + && abi.osFlavor() != ProjectExplorer::Abi::WindowsMSysFlavor) { + QPair<QString, QString> cdbs = autoDetectCdbDebugger(); + return (abi.wordWidth() == 32) ? cdbs.first : cdbs.second; + } + + // Check suggestions from the SDK: + if (tc) { + const QString path = tc->suggestedDebugger().toString(); + if (!path.isEmpty()) + return path; + } + + // fall back to system GDB: + Utils::Environment env = Utils::Environment::systemEnvironment(); + return env.searchInPath(QLatin1String("gdb")); +} + +QList<ProjectExplorer::Task> DebuggerProfileInformation::validate(ProjectExplorer::Profile *p) const +{ + QList<ProjectExplorer::Task> result; + Utils::FileName dbg = debuggerCommand(p); + if (dbg.isEmpty()) { + result << ProjectExplorer::Task(ProjectExplorer::Task::Warning, + tr("No debugger set up."), Utils::FileName(), -1, + Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)); + return result; + } + + QFileInfo fi = dbg.toFileInfo(); + if (!fi.exists() || fi.isDir()) + result << ProjectExplorer::Task(ProjectExplorer::Task::Error, + tr("Debugger not found."), Utils::FileName(), -1, + Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)); + else if (!fi.isExecutable()) + result << ProjectExplorer::Task(ProjectExplorer::Task::Error, + tr("Debugger not exectutable."), Utils::FileName(), -1, + Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)); + + return result; +} + +ProjectExplorer::ProfileConfigWidget * +DebuggerProfileInformation::createConfigWidget(ProjectExplorer::Profile *p) const +{ + return new Internal::DebuggerProfileConfigWidget(p, this); +} + +ProjectExplorer::ProfileInformation::ItemList DebuggerProfileInformation::toUserOutput(ProjectExplorer::Profile *p) const +{ + return ItemList() << qMakePair(tr("Debugger"), debuggerCommand(p).toUserOutput()); +} + +Utils::FileName DebuggerProfileInformation::debuggerCommand(const ProjectExplorer::Profile *p) +{ + return Utils::FileName::fromString(p->value(Core::Id(DEBUGGER_INFORMATION)).toString()); +} + +void DebuggerProfileInformation::setDebuggerCommand(ProjectExplorer::Profile *p, Utils::FileName &command) +{ + p->setValue(Core::Id(DEBUGGER_INFORMATION), command.toString()); +} + +} // namespace Debugger diff --git a/src/plugins/debugger/debuggerprofileinformation.h b/src/plugins/debugger/debuggerprofileinformation.h new file mode 100644 index 00000000000..aaf990e79b4 --- /dev/null +++ b/src/plugins/debugger/debuggerprofileinformation.h @@ -0,0 +1,67 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation ([email protected]) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at [email protected]. +** +**************************************************************************/ + +#ifndef DEBUGGER_DEBUGGERPROFILEINFORMATION_H +#define DEBUGGER_DEBUGGERPROFILEINFORMATION_H + +#include "debugger_global.h" + +#include <projectexplorer/profileinformation.h> + +namespace Debugger { + +class DEBUGGER_EXPORT DebuggerProfileInformation : public ProjectExplorer::ProfileInformation +{ + Q_OBJECT + +public: + DebuggerProfileInformation(); + + Core::Id dataId() const; + + unsigned int priority() const; // the higher the closer to the top. + + QVariant defaultValue(ProjectExplorer::Profile *p) const; + + QList<ProjectExplorer::Task> validate(ProjectExplorer::Profile *p) const; + + ProjectExplorer::ProfileConfigWidget *createConfigWidget(ProjectExplorer::Profile *p) const; + + ItemList toUserOutput(ProjectExplorer::Profile *p) const; + + static Utils::FileName debuggerCommand(const ProjectExplorer::Profile *p); + static void setDebuggerCommand(ProjectExplorer::Profile *p, Utils::FileName &command); +}; + +} // namespace Debugger + +#endif // DEBUGGER_DEBUGGERPROFILEINFORMATION_H diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index b6ab4e14042..9d95678f8e7 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -41,6 +41,7 @@ #include "debuggerplugin.h" #include "debuggerstringutils.h" #include "debuggerstartparameters.h" +#include "debuggerprofileinformation.h" #include "lldb/lldbenginehost.h" #include "debuggertooltipmanager.h" #include "qml/qmlengine.h" @@ -905,6 +906,12 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu if (const ProjectExplorer::Target *target = runConfiguration->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 Utils::FileName qmake = Utils::BuildableHelperLibrary::findSystemQt(sp.environment); if (!qmake.isEmpty()) sp.qtInstallPath = findQtInstallPath(qmake); @@ -913,8 +920,8 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu sp.projectSourceDirectory = project->projectDirectory(); if (const ProjectExplorer::BuildConfiguration *buildConfig = target->activeBuildConfiguration()) { sp.projectBuildDirectory = buildConfig->buildDirectory(); - if (const ProjectExplorer::ToolChain *tc = buildConfig->toolChain()) - sp.debuggerCommand = tc->debuggerCommand().toString(); + const ProjectExplorer::Profile *p = runConfiguration->target()->profile(); + sp.debuggerCommand = DebuggerProfileInformation::debuggerCommand(p).toString(); } sp.projectSourceFiles = project->files(Project::ExcludeGeneratedFiles); } diff --git a/src/plugins/debugger/debuggertoolchaincombobox.cpp b/src/plugins/debugger/debuggertoolchaincombobox.cpp index 32a0eeb5bb9..0148a8807a9 100644 --- a/src/plugins/debugger/debuggertoolchaincombobox.cpp +++ b/src/plugins/debugger/debuggertoolchaincombobox.cpp @@ -32,8 +32,10 @@ #include "debuggertoolchaincombobox.h" -#include <projectexplorer/toolchainmanager.h> -#include <projectexplorer/toolchain.h> +#include "debuggerprofileinformation.h" + +#include <projectexplorer/profileinformation.h> +#include <projectexplorer/profilemanager.h> #include <projectexplorer/abi.h> #include <utils/qtcassert.h> @@ -58,17 +60,25 @@ DebuggerToolChainComboBox::DebuggerToolChainComboBox(QWidget *parent) : void DebuggerToolChainComboBox::init(bool hostAbiOnly) { const ProjectExplorer::Abi hostAbi = ProjectExplorer::Abi::hostAbi(); - foreach (const ProjectExplorer::ToolChain *tc, ProjectExplorer::ToolChainManager::instance()->toolChains()) { + foreach (const ProjectExplorer::Profile *st, + ProjectExplorer::ProfileManager::instance()->profiles()) { + if (!st->isValid()) + continue; + ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(st); + if (!tc) + continue; const ProjectExplorer::Abi abi = tc->targetAbi(); - if (!hostAbiOnly || hostAbi.isCompatibleWith(abi)) { - const QString debuggerCommand = tc->debuggerCommand().toString(); - if (!debuggerCommand.isEmpty()) { - const AbiDebuggerCommandPair data(abi, debuggerCommand); - const QString completeBase = QFileInfo(debuggerCommand).completeBaseName(); - const QString name = tr("%1 (%2)").arg(tc->displayName(), completeBase); - addItem(name, qVariantFromValue(data)); - } - } + if (hostAbiOnly && hostAbi.os() != abi.os()) + continue; + + const QString debuggerCommand = DebuggerProfileInformation::debuggerCommand(st).toString(); + if (debuggerCommand.isEmpty()) + continue; + + const AbiDebuggerCommandPair data(abi, debuggerCommand); + const QString completeBase = QFileInfo(debuggerCommand).completeBaseName(); + const QString name = tr("%1 (%2)").arg(st->displayName(), completeBase); + addItem(name, qVariantFromValue(data)); } setEnabled(count() > 1); } |