Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a gammaray helper.

This helper will copy share/qtcreator/gammaray into the Qt directory, and compiles it for the Qt version.
It's working like the QML debugger and other helpers.
On Windows, it's only available for MSVC

Most of the work has been done by Milian Wolff
  • Loading branch information...
commit beb7722b0383be20c6639aa76c4e9fd1b1f490ed 1 parent 2fba9ba
@narnaud narnaud authored
View
3  share/qtcreator/static.pro
@@ -38,7 +38,8 @@ DATA_DIRS = \
qml \
qml-type-descriptions \
generic-highlighter \
- glsl
+ glsl \
+ gammaray
macx: DATA_DIRS += scripts
# conditionally deployed data
View
19 src/plugins/qtsupport/baseqtversion.cpp
@@ -34,6 +34,7 @@
#include "qmlobservertool.h"
#include "qmldumptool.h"
#include "qmldebugginglibrary.h"
+#include "gammaraytool.h"
#include "qtversionmanager.h"
#include "profilereader.h"
@@ -168,6 +169,7 @@ BaseQtVersion::BaseQtVersion(const QString &qmakeCommand, bool isAutodetected, c
m_hasQmlDump(false),
m_hasQmlDebuggingLibrary(false),
m_hasQmlObserver(false),
+ m_hasGammaray(false),
m_mkspecUpToDate(false),
m_mkspecReadUpToDate(false),
m_defaultConfigIsDebug(true),
@@ -189,6 +191,7 @@ BaseQtVersion::BaseQtVersion()
m_hasQmlDump(false),
m_hasQmlDebuggingLibrary(false),
m_hasQmlObserver(false),
+ m_hasGammaray(false),
m_mkspecUpToDate(false),
m_mkspecReadUpToDate(false),
m_defaultConfigIsDebug(true),
@@ -699,6 +702,7 @@ void BaseQtVersion::updateVersionInfo() const
m_hasQmlDump = false;
m_hasQmlDebuggingLibrary = false;
m_hasQmlObserver = false;
+ m_hasGammaray = false;
if (!queryQMakeVariables(qmakeCommand(), &m_versionInfo, &m_qmakeIsExecutable))
return;
@@ -717,6 +721,7 @@ void BaseQtVersion::updateVersionInfo() const
= !QmlDebuggingLibrary::libraryByInstallData(qtInstallData, false).isEmpty()
|| !QmlDebuggingLibrary::libraryByInstallData(qtInstallData, true).isEmpty();
m_hasQmlObserver = !QmlObserverTool::toolByInstallData(qtInstallData).isEmpty();
+ m_hasGammaray = !GammarayTool::toolByInstallData(qtInstallData).isEmpty();
}
}
@@ -847,6 +852,12 @@ bool BaseQtVersion::hasQmlObserver() const
return m_hasQmlObserver;
}
+bool BaseQtVersion::hasGammaray() const
+{
+ updateVersionInfo();
+ return m_hasGammaray;
+}
+
Utils::Environment BaseQtVersion::qmlToolsEnvironment() const
{
// FIXME: This seems broken!
@@ -895,6 +906,14 @@ QString BaseQtVersion::qmlObserverTool() const
return QmlObserverTool::toolByInstallData(qtInstallData);
}
+QString BaseQtVersion::gammarayTool() const
+{
+ QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
+ if (qtInstallData.isEmpty())
+ return QString();
+ return GammarayTool::toolByInstallData(qtInstallData);
+}
+
QStringList BaseQtVersion::debuggingHelperLibraryLocations() const
{
QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
View
3  src/plugins/qtsupport/baseqtversion.h
@@ -188,6 +188,7 @@ class QTSUPPORT_EXPORT BaseQtVersion
virtual QString qmlDebuggingHelperLibrary(bool debugVersion) const;
virtual QString qmlDumpTool(bool debugVersion) const;
virtual QString qmlObserverTool() const;
+ virtual QString gammarayTool() const;
virtual QStringList debuggingHelperLibraryLocations() const;
virtual bool hasGdbDebuggingHelper() const;
@@ -195,6 +196,7 @@ class QTSUPPORT_EXPORT BaseQtVersion
virtual bool hasQmlDebuggingLibrary() const;
virtual bool needsQmlDebuggingLibrary() const;
virtual bool hasQmlObserver() const;
+ virtual bool hasGammaray() const;
Utils::Environment qmlToolsEnvironment() const;
virtual QtConfigWidget *createConfigurationWidget() const;
@@ -235,6 +237,7 @@ class QTSUPPORT_EXPORT BaseQtVersion
mutable bool m_hasQmlDump; // controlled by m_versionInfoUpToDate
mutable bool m_hasQmlDebuggingLibrary; // controlled by m_versionInfoUpdate
mutable bool m_hasQmlObserver; // controlled by m_versionInfoUpToDate
+ mutable bool m_hasGammaray;
mutable bool m_mkspecUpToDate;
mutable QString m_mkspec;
View
34 src/plugins/qtsupport/debugginghelper.ui
@@ -161,6 +161,40 @@
</property>
</widget>
</item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="gammarayLabel">
+ <property name="text">
+ <string>GammaRay:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QLabel" name="gammarayStatus">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="2">
+ <spacer name="horizontalSpacer_6">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="5" column="4">
+ <widget class="QPushButton" name="gammarayBuildButton">
+ <property name="text">
+ <string>Build</string>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
<item>
View
19 src/plugins/qtsupport/debugginghelperbuildtask.cpp
@@ -34,6 +34,7 @@
#include "qmldumptool.h"
#include "qmlobservertool.h"
#include "qmldebugginglibrary.h"
+#include "gammaraytool.h"
#include "baseqtversion.h"
#include "qtversionmanager.h"
#include <coreplugin/messagemanager.h>
@@ -138,6 +139,9 @@ DebuggingHelperBuildTask::Tools DebuggingHelperBuildTask::availableTools(const B
if (QmlObserverTool::canBuild(version))
tools |= QmlObserver; // requires QML debugging.
}
+ if (GammarayTool::canBuild(version)) {
+ tools |= GammaRay;
+ }
return tools;
}
@@ -148,7 +152,7 @@ void DebuggingHelperBuildTask::showOutputOnError(bool show)
void DebuggingHelperBuildTask::run(QFutureInterface<void> &future)
{
- future.setProgressRange(0, 5);
+ future.setProgressRange(0, 6);
future.setProgressValue(1);
if (m_invalidQt || !buildDebuggingHelper(future)) {
@@ -247,6 +251,19 @@ bool DebuggingHelperBuildTask::buildDebuggingHelper(QFutureInterface<void> &futu
}
}
future.setProgressValue(5);
+ if (m_tools & GammaRay) {
+ QString output, error;
+ bool success = true;
+
+ arguments.directory = GammarayTool::copy(m_qtInstallData, &error);
+ if (arguments.directory.isEmpty()
+ || !GammarayTool::build(arguments, &output, &error))
+ success = false;
+ log(output, error);
+ if (!success)
+ return false;
+ }
+ future.setProgressValue(6);
return true;
}
View
3  src/plugins/qtsupport/debugginghelperbuildtask.h
@@ -53,7 +53,8 @@ class QTSUPPORT_EXPORT DebuggingHelperBuildTask : public QObject {
QmlDebugging = 0x02,
QmlObserver = 0x04,
QmlDump = 0x08,
- AllTools = GdbDebugging | QmlDebugging | QmlObserver | QmlDump
+ GammaRay = 0x10,
+ AllTools = GdbDebugging | QmlDebugging | QmlObserver | QmlDump | GammaRay
};
Q_DECLARE_FLAGS(Tools, DebuggingHelper)
View
175 src/plugins/qtsupport/gammaraytool.cpp
@@ -0,0 +1,175 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2011 KDAB.
+**
+** Contact: KDAB (info@kdab.com)
+**
+**
+** 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 info@qt.nokia.com.
+**
+**************************************************************************/
+
+#include "gammaraytool.h"
+
+#include <coreplugin/icore.h>
+
+#include <utils/synchronousprocess.h>
+#include <utils/qtcassert.h>
+
+#include <projectexplorer/projectexplorerconstants.h>
+
+#include <QtCore/QFileInfo>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QHash>
+#include <QtCore/QProcess>
+#include <QtCore/QDir>
+#include <QtCore/QDateTime>
+#include <QtCore/QStringList>
+#include <QtCore/QQueue>
+
+#include <QtGui/QDesktopServices>
+
+#include "baseqtversion.h"
+
+using namespace QtSupport;
+
+static inline QStringList validBinaryFilenames()
+{
+ return QStringList()
+ << QLatin1String("debug/gammaray.exe")
+ << QLatin1String("gammaray")
+ << QLatin1String("gammaray.app/Contents/MacOS/gammaray");
+}
+
+static QString sourcePath()
+{
+ return Core::ICore::instance()->resourcePath() + QLatin1String("/gammaray/");
+}
+
+static QStringList sourceFileNames()
+{
+ QStringList ret;
+
+ QQueue<QString> paths;
+ paths << sourcePath();
+
+ QDir baseDir(sourcePath());
+ QTC_ASSERT(baseDir.exists(), return ret);
+
+ while(!paths.isEmpty()) {
+ QDir dir(paths.dequeue());
+ QTC_ASSERT(dir.exists(), return ret);
+
+ foreach(const QFileInfo &entry, dir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot)) {
+ if (entry.isDir()) {
+ paths << entry.absoluteFilePath();
+ } else {
+ ret << baseDir.relativeFilePath(entry.absoluteFilePath());
+ }
+ }
+ }
+
+ return ret;
+}
+
+QString GammarayTool::toolByInstallData(const QString &qtInstallData)
+{
+ if (!Core::ICore::instance())
+ return QString();
+
+ const QStringList directories = installDirectories(qtInstallData);
+ const QStringList binFilenames = validBinaryFilenames();
+
+ return byInstallDataHelper(sourcePath(), sourceFileNames(), directories, binFilenames, false);
+}
+
+QStringList GammarayTool::locationsByInstallData(const QString &qtInstallData)
+{
+ QStringList result;
+ QFileInfo fileInfo;
+ const QStringList binFilenames = validBinaryFilenames();
+ foreach(const QString &directory, installDirectories(qtInstallData)) {
+ if (getHelperFileInfoFor(binFilenames, directory, &fileInfo))
+ result << fileInfo.filePath();
+ }
+ return result;
+}
+
+bool GammarayTool::canBuild(const BaseQtVersion *qtVersion, QString *reason)
+{
+ foreach (const ProjectExplorer::Abi &abi, qtVersion->qtAbis()) {
+ if (abi.os() == ProjectExplorer::Abi::WindowsOS) {
+ // windows version, we only support msvc
+ if (abi.osFlavor() != ProjectExplorer::Abi::WindowsMsvc2005Flavor &&
+ abi.osFlavor() != ProjectExplorer::Abi::WindowsMsvc2008Flavor &&
+ abi.osFlavor() != ProjectExplorer::Abi::WindowsMsvc2010Flavor)
+ {
+ *reason = QCoreApplication::translate("Analyzer::GammarayTool",
+ "Only available for Qt built with MSVC.");
+ return false;
+ }
+ return true;
+ }
+ }
+
+ // assume we can build it everywhere else
+ return true;
+}
+
+QString GammarayTool::copy(const QString &qtInstallData,
+ QString *errorMessage)
+{
+ const QStringList directories = GammarayTool::installDirectories(qtInstallData);
+
+ // Try to find a writeable directory.
+ foreach(const QString &directory, directories) {
+ if (copyFiles(sourcePath(), sourceFileNames(), directory, errorMessage)) {
+ return directory;
+ }
+ }
+ *errorMessage = QCoreApplication::translate("Analyzer::GammarayTool",
+ "gammaray could not be built in any of the directories:\n- %1\n\nReason: %2")
+ .arg(directories.join(QLatin1String("\n- ")), *errorMessage);
+ return QString();
+}
+
+bool GammarayTool::build(BuildHelperArguments arguments, QString *log, QString *errorMessage)
+{
+ arguments.proFilename = QLatin1String("gammaray.pro");
+ arguments.helperName = QCoreApplication::translate("Analyzer::GammarayTool",
+ "GammaRay");
+ return buildHelper(arguments, log, errorMessage);
+}
+
+QStringList GammarayTool::installDirectories(const QString &qtInstallData)
+{
+ const QChar slash = QLatin1Char('/');
+ const uint hash = qHash(qtInstallData);
+ QStringList directories;
+ directories
+ << (qtInstallData + QLatin1String("/qtc-gammaray/"))
+ << QDir::cleanPath((QCoreApplication::applicationDirPath() + QLatin1String("/../qtc-gammaray/") + QString::number(hash))) + slash
+ << (QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/qtc-gammaray/") + QString::number(hash)) + slash;
+ return directories;
+}
View
66 src/plugins/qtsupport/gammaraytool.h
@@ -0,0 +1,66 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2011 KDAB.
+**
+** Contact: KDAB (info@kdab.com)
+**
+**
+** 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 info@qt.nokia.com.
+**
+**************************************************************************/
+
+#ifndef QTSUPPORT_GAMMARAYTOOL_H
+#define QTSUPPORT_GAMMARAYTOOL_H
+
+#include "qtsupport_global.h"
+
+#include <utils/buildablehelperlibrary.h>
+
+#include <QtCore/QStringList>
+
+namespace QtSupport {
+class BaseQtVersion;
+
+class QTSUPPORT_EXPORT GammarayTool : public Utils::BuildableHelperLibrary
+{
+public:
+ static QString toolByInstallData(const QString &qtInstallData);
+ static QStringList locationsByInstallData(const QString &qtInstallData);
+
+ static bool canBuild(const BaseQtVersion *qtVersion, QString *reason = 0);
+
+ // Build the helpers and return the output log/errormessage.
+ static bool build(BuildHelperArguments arguments, QString *log, QString *errorMessage);
+
+ // Copy the source files to a target location and return the chosen target location.
+ static QString copy(const QString &qtInstallData, QString *errorMessage);
+
+private:
+ static QStringList installDirectories(const QString &qtInstallData);
+
+};
+
+}
+
+#endif // QTSUPPORT_GAMMARAYTOOL_H
View
35 src/plugins/qtsupport/qtoptionspage.cpp
@@ -41,6 +41,7 @@
#include "qmldumptool.h"
#include "qmldebugginglibrary.h"
#include "qmlobservertool.h"
+#include "gammaraytool.h"
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
@@ -202,6 +203,8 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<BaseQtVersion *>
this, SLOT(buildQmlDebuggingLibrary()));
connect(m_debuggingHelperUi->qmlObserverBuildButton, SIGNAL(clicked()),
this, SLOT(buildQmlObserver()));
+ connect(m_debuggingHelperUi->gammarayBuildButton, SIGNAL(clicked()),
+ this, SLOT(buildGammaray()));
connect(m_debuggingHelperUi->showLogButton, SIGNAL(clicked()),
this, SLOT(slotShowDebuggingBuildLog()));
@@ -290,6 +293,8 @@ void QtOptionsPageWidget::debuggingHelperBuildFinished(int qtVersionId, const QS
success &= version->hasQmlDump();
if (tools & DebuggingHelperBuildTask::QmlObserver)
success &= version->hasQmlObserver();
+ if (tools & DebuggingHelperBuildTask::GammaRay)
+ success &= version->hasGammaray();
if (!success)
showDebuggingBuildLog(item);
@@ -515,6 +520,11 @@ void QtOptionsPageWidget::buildQmlObserver()
buildDebuggingHelper(qmlDbgTools);
}
+void QtOptionsPageWidget::buildGammaray()
+{
+ buildDebuggingHelper(DebuggingHelperBuildTask::GammaRay);
+}
+
// Non-modal dialog
class BuildLogDialog : public QDialog {
public:
@@ -674,17 +684,20 @@ void QtOptionsPageWidget::updateDebuggingHelperUi()
const bool canBuildQmlDumper = availableTools & DebuggingHelperBuildTask::QmlDump;
const bool canBuildQmlDebuggingLib = availableTools & DebuggingHelperBuildTask::QmlDebugging;
const bool canBuildQmlObserver = availableTools & DebuggingHelperBuildTask::QmlObserver;
+ const bool canBuildGammaRay = availableTools & DebuggingHelperBuildTask::GammaRay;
const bool hasGdbHelper = !version->gdbDebuggingHelperLibrary().isEmpty();
const bool hasQmlDumper = version->hasQmlDump();
const bool hasQmlDebuggingLib = version->hasQmlDebuggingLibrary();
const bool needsQmlDebuggingLib = version->needsQmlDebuggingLibrary();
const bool hasQmlObserver = !version->qmlObserverTool().isEmpty();
+ const bool hasGammaray = version->hasGammaray();
bool isBuildingGdbHelper = false;
bool isBuildingQmlDumper = false;
bool isBuildingQmlDebuggingLib = false;
bool isBuildingQmlObserver = false;
+ bool isBuildingGammaRay = false;
if (currentItem) {
DebuggingHelperBuildTask::Tools buildingTools
@@ -693,6 +706,7 @@ void QtOptionsPageWidget::updateDebuggingHelperUi()
isBuildingQmlDumper = buildingTools & DebuggingHelperBuildTask::QmlDump;
isBuildingQmlDebuggingLib = buildingTools & DebuggingHelperBuildTask::QmlDebugging;
isBuildingQmlObserver = buildingTools & DebuggingHelperBuildTask::QmlObserver;
+ isBuildingGammaRay = buildingTools & DebuggingHelperBuildTask::GammaRay;
}
// get names of tools from labels
@@ -705,6 +719,8 @@ void QtOptionsPageWidget::updateDebuggingHelperUi()
helperNames << m_debuggingHelperUi->qmlDebuggingLibLabel->text().remove(':');
if (hasQmlObserver)
helperNames << m_debuggingHelperUi->qmlObserverLabel->text().remove(':');
+ if (hasGammaray)
+ helperNames << m_debuggingHelperUi->gammarayLabel->text().remove(':');
QString status;
if (helperNames.isEmpty()) {
@@ -811,6 +827,24 @@ void QtOptionsPageWidget::updateDebuggingHelperUi()
m_debuggingHelperUi->qmlObserverBuildButton->setEnabled(canBuildQmlObserver
& !isBuildingQmlObserver);
+ QString gammarayStatusText, gammarayStatusToolTip;
+ Qt::TextInteractionFlags gammarayStatusTextFlags = Qt::NoTextInteraction;
+ if (hasGammaray) {
+ gammarayStatusText = QDir::toNativeSeparators(version->gammarayTool());
+ gammarayStatusTextFlags = Qt::TextSelectableByMouse;
+ } else {
+ if (canBuildGammaRay) {
+ gammarayStatusText = tr("<i>Not yet built.</i>");
+ } else {
+ gammarayStatusText = tr("<i>Cannot be compiled.</i>");
+ GammarayTool::canBuild(version, &gammarayStatusToolTip);
+ }
+ }
+ m_debuggingHelperUi->gammarayStatus->setText(gammarayStatusText);
+ m_debuggingHelperUi->gammarayStatus->setTextInteractionFlags(gammarayStatusTextFlags);
+ m_debuggingHelperUi->gammarayStatus->setToolTip(gammarayStatusToolTip);
+ m_debuggingHelperUi->gammarayBuildButton->setEnabled(canBuildGammaRay & !isBuildingGammaRay);
+
QList<ProjectExplorer::ToolChain*> toolchains = toolChains(currentVersion());
QString selectedToolChainId = currentItem->data(0, ToolChainIdRole).toString();
m_debuggingHelperUi->toolChainComboBox->clear();
@@ -1027,3 +1061,4 @@ QString QtOptionsPageWidget::searchKeywords() const
rc.remove(QLatin1Char('&'));
return rc;
}
+
View
1  src/plugins/qtsupport/qtoptionspage.h
@@ -110,6 +110,7 @@ private slots:
void buildQmlDump();
void buildQmlDebuggingLibrary();
void buildQmlObserver();
+ void buildGammaray();
void slotShowDebuggingBuildLog();
void debuggingHelperBuildFinished(int qtVersionId, const QString &output,
DebuggingHelperBuildTask::Tools tools);
View
8 src/plugins/qtsupport/qtsupport.pro
@@ -25,7 +25,8 @@ HEADERS += \
profilereader.h \
qtparser.h \
gettingstartedwelcomepage.h \
- exampleslistmodel.h
+ exampleslistmodel.h \
+ gammaraytool.h
SOURCES += \
qtsupportplugin.cpp \
@@ -41,7 +42,8 @@ SOURCES += \
profilereader.cpp \
qtparser.cpp \
gettingstartedwelcomepage.cpp \
- exampleslistmodel.cpp
+ exampleslistmodel.cpp \
+ gammaraytool.cpp
FORMS += \
showbuildlog.ui \
@@ -52,3 +54,5 @@ FORMS += \
DEFINES += QT_NO_CAST_TO_ASCII
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.