From f6e5202b80af2f910fc06f4b46537ec7a65f2394 Mon Sep 17 00:00:00 2001 From: Ivan Donchevskii Date: Wed, 26 Sep 2018 14:10:35 +0200 Subject: [PATCH 01/17] CompilerOptionsBuilder unit-tests Bonus: minor compiler options builder issues fixed. Change-Id: Ie25f8fad6729339de05f2bf9b614ceac873e2634 Reviewed-by: Marco Bubke --- .../cpptools/compileroptionsbuilder.cpp | 28 +- src/plugins/cpptools/compileroptionsbuilder.h | 31 +- tests/unit/mockup/projectexplorer/project.h | 2 + tests/unit/unittest/clang_dependency.pri | 2 + .../unittest/compileroptionsbuilder-test.cpp | 343 ++++++++++++++++++ .../unittest/data/compileroptionsbuilder.pch | 0 tests/unit/unittest/unittest.pro | 2 + 7 files changed, 380 insertions(+), 28 deletions(-) create mode 100644 tests/unit/unittest/compileroptionsbuilder-test.cpp create mode 100644 tests/unit/unittest/data/compileroptionsbuilder.pch diff --git a/src/plugins/cpptools/compileroptionsbuilder.cpp b/src/plugins/cpptools/compileroptionsbuilder.cpp index 8ec63484f97..e722722e252 100644 --- a/src/plugins/cpptools/compileroptionsbuilder.cpp +++ b/src/plugins/cpptools/compileroptionsbuilder.cpp @@ -170,11 +170,6 @@ void CompilerOptionsBuilder::add(const QString &option) m_options.append(option); } -void CompilerOptionsBuilder::addDefine(const ProjectExplorer::Macro ¯o) -{ - m_options.append(defineDirectiveToDefineOption(macro)); -} - void CompilerOptionsBuilder::addWordWidth() { const QString argument = m_projectPart.toolChainWordWidth == ProjectPart::WordWidth64Bit @@ -211,7 +206,7 @@ static QString creatorResourcePath() #ifndef UNIT_TESTS return Core::ICore::resourcePath(); #else - return QString(); + return QDir::toNativeSeparators(QString::fromUtf8(QTC_RESOURCE_DIR "")); #endif } @@ -221,7 +216,7 @@ static QString clangIncludeDirectory(const QString &clangVersion, #ifndef UNIT_TESTS return Core::ICore::clangIncludeDirectory(clangVersion, clangResourceDirectory); #else - return QString(); + return QDir::toNativeSeparators(QString::fromUtf8(CLANG_RESOURCE_DIR "")); #endif } @@ -238,12 +233,20 @@ static int lastIncludeIndex(const QStringList &options, const QRegularExpression return index; } -static int includeIndexForResourceDirectory(const QStringList &options) +static int includeIndexForResourceDirectory(const QStringList &options, bool isMacOs = false) { // include/c++/{version}, include/c++/v1 and include/g++ - const int cppIncludeIndex = lastIncludeIndex( - options, - QRegularExpression("\\A.*[\\/\\\\]include[\\/\\\\].*(g\\+\\+.*\\z|c\\+\\+[\\/\\\\](v1\\z|\\d+.*\\z))")); + static const QRegularExpression includeRegExp( + R"(\A.*[\/\\]include[\/\\].*(g\+\+.*\z|c\+\+[\/\\](v1\z|\d+.*\z)))"); + + // The same as includeRegExp but also matches /usr/local/include + static const QRegularExpression includeRegExpMac( + R"(\A(.*[\/\\]include[\/\\].*(g\+\+.*\z|c\+\+[\/\\](v1\z|\d+.*\z))))" + R"(|([\/\\]usr[\/\\]local[\/\\]include\z))"); + + const int cppIncludeIndex = lastIncludeIndex(options, isMacOs + ? includeRegExpMac + : includeRegExp); if (cppIncludeIndex > 0) return cppIncludeIndex + 1; @@ -317,7 +320,8 @@ void CompilerOptionsBuilder::addHeaderPathOptions() const QString clangIncludePath = clangIncludeDirectory(m_clangVersion, m_clangResourceDirectory); - int includeIndexForResourceDir = includeIndexForResourceDirectory(builtInIncludes); + int includeIndexForResourceDir = includeIndexForResourceDirectory( + builtInIncludes, m_projectPart.toolChainTargetTriple.contains("darwin")); if (includeIndexForResourceDir >= 0) { builtInIncludes.insert(includeIndexForResourceDir, clangIncludePath); diff --git a/src/plugins/cpptools/compileroptionsbuilder.h b/src/plugins/cpptools/compileroptionsbuilder.h index ba29d6e4301..1274c1b860c 100644 --- a/src/plugins/cpptools/compileroptionsbuilder.h +++ b/src/plugins/cpptools/compileroptionsbuilder.h @@ -56,33 +56,27 @@ public: SkipBuiltIn skipBuiltInHeaderPathsAndDefines = SkipBuiltIn::No, QString clangVersion = QString(), QString clangResourceDirectory = QString()); - virtual ~CompilerOptionsBuilder() {} - - virtual void addTargetTriple(); - virtual void addExtraCodeModelFlags(); - virtual void enableExceptions(); - virtual void insertWrappedQtHeaders(); - virtual void addOptionsForLanguage(bool checkForBorlandExtensions = true); - virtual void updateLanguageOption(ProjectFile::Kind fileKind); - - virtual void addExtraOptions() {} QStringList build(ProjectFile::Kind fileKind, PchUsage pchUsage); QStringList options() const; - // Add custom options - void add(const QString &option); - void addDefine(const ProjectExplorer::Macro &marco); - + virtual void addExtraOptions() {} // Add options based on project part + virtual void addToolchainAndProjectMacros(); void addWordWidth(); void addToolchainFlags(); void addHeaderPathOptions(); void addPrecompiledHeaderOptions(PchUsage pchUsage); - virtual void addToolchainAndProjectMacros(); void addMacros(const ProjectExplorer::Macros ¯os); + void addTargetTriple(); + void addExtraCodeModelFlags(); + void enableExceptions(); + void insertWrappedQtHeaders(); + void addOptionsForLanguage(bool checkForBorlandExtensions = true); + void updateLanguageOption(ProjectFile::Kind fileKind); + void addMsvcCompatibilityVersion(); void undefineCppLanguageFeatureMacrosForMsvc2015(); void addDefineFunctionMacrosMsvc(); @@ -97,8 +91,13 @@ protected: virtual QString defineOption() const; virtual QString undefineOption() const; virtual QString includeOption() const; + + // Add custom options + void add(const QString &option); + QString includeDirOptionForPath(const QString &path) const; - const ProjectPart m_projectPart; + + const ProjectPart &m_projectPart; private: QByteArray macroOption(const ProjectExplorer::Macro ¯o) const; diff --git a/tests/unit/mockup/projectexplorer/project.h b/tests/unit/mockup/projectexplorer/project.h index 78b4211dca4..9e8f2e1ac39 100644 --- a/tests/unit/mockup/projectexplorer/project.h +++ b/tests/unit/mockup/projectexplorer/project.h @@ -33,6 +33,8 @@ namespace ProjectExplorer { class Project : public QObject { public: + Project() = default; + Utils::FileName projectDirectory() const { return Utils::FileName(); } diff --git a/tests/unit/unittest/clang_dependency.pri b/tests/unit/unittest/clang_dependency.pri index e0c3b1a9483..744c9ff4283 100644 --- a/tests/unit/unittest/clang_dependency.pri +++ b/tests/unit/unittest/clang_dependency.pri @@ -1,4 +1,6 @@ include(../../../src/shared/clang/clang_installation.pri) +include(../../../src/shared/clang/clang_defines.pri) + !isEmpty(LLVM_VERSION) { requires(!isEmpty(LIBCLANG_LIBS)) equals(LLVM_IS_COMPILED_WITH_RTTI, "NO") : message("LLVM needs to be compiled with RTTI!") diff --git a/tests/unit/unittest/compileroptionsbuilder-test.cpp b/tests/unit/unittest/compileroptionsbuilder-test.cpp new file mode 100644 index 00000000000..ae81f7d0cae --- /dev/null +++ b/tests/unit/unittest/compileroptionsbuilder-test.cpp @@ -0,0 +1,343 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "googletest.h" + +#include +#include +#include + +#include +#include + +using CppTools::CompilerOptionsBuilder; +using CppTools::ProjectFile; +using CppTools::ProjectPart; +using ProjectExplorer::HeaderPath; +using ProjectExplorer::HeaderPathType; +using ProjectExplorer::Project; + +MATCHER_P(IsPartOfHeader, headerPart, std::string(negation ? "isn't " : "is ") + headerPart) +{ + return arg.contains(QString::fromUtf8(headerPart)); +} + +class CompilerOptionsBuilderTest : public ::testing::Test +{ +protected: + void SetUp() final + { + projectPart.project = project.get(); + projectPart.toolchainType = ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID; + projectPart.languageVersion = CppTools::ProjectPart::CXX17; + projectPart.toolChainWordWidth = CppTools::ProjectPart::WordWidth64Bit; + projectPart.toolChainTargetTriple = "x86_64-apple-darwin10"; + projectPart.extraCodeModelFlags = QStringList{"-arch", "x86_64"}; + + projectPart.precompiledHeaders = QStringList{TESTDATA_DIR "/compileroptionsbuilder.pch"}; + projectPart.toolChainMacros = {ProjectExplorer::Macro{"foo", "bar"}}; + projectPart.projectMacros = {ProjectExplorer::Macro{"projectFoo", "projectBar"}}; + projectPart.qtVersion = ProjectPart::Qt5; + + projectPart.headerPaths = {HeaderPath{"/tmp/builtin_path", HeaderPathType::BuiltIn}, + HeaderPath{"/tmp/system_path", HeaderPathType::System}, + HeaderPath{"/tmp/path", HeaderPathType::User}}; + } + + std::unique_ptr project{std::make_unique()}; + ProjectPart projectPart; + CompilerOptionsBuilder compilerOptionsBuilder{projectPart}; +}; + +TEST_F(CompilerOptionsBuilderTest, AddToolchainAndProjectMacros) +{ + compilerOptionsBuilder.addToolchainAndProjectMacros(); + + ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("-Dfoo=bar", "-DprojectFoo=projectBar")); +} + +TEST_F(CompilerOptionsBuilderTest, AddWordWidth) +{ + compilerOptionsBuilder.addWordWidth(); + + ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("-m64")); +} + +TEST_F(CompilerOptionsBuilderTest, AddToolchainFlags) +{ + compilerOptionsBuilder.addToolchainFlags(); + + ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("-undef")); +} + +TEST_F(CompilerOptionsBuilderTest, HeaderPathOptionsOrder) +{ + compilerOptionsBuilder.addHeaderPathOptions(); + + ASSERT_THAT(compilerOptionsBuilder.options(), + ElementsAre("-nostdlibinc", + "-I", QDir::toNativeSeparators("/tmp/path"), + "-I", QDir::toNativeSeparators("/tmp/system_path"), + "-isystem", QDir::toNativeSeparators("/tmp/builtin_path"))); +} + +TEST_F(CompilerOptionsBuilderTest, UseSystemHeader) +{ + CompilerOptionsBuilder compilerOptionsBuilder(projectPart, CppTools::UseSystemHeader::Yes); + + compilerOptionsBuilder.addHeaderPathOptions(); + + ASSERT_THAT(compilerOptionsBuilder.options(), + ElementsAre("-nostdlibinc", + "-I", QDir::toNativeSeparators("/tmp/path"), + "-isystem", QDir::toNativeSeparators("/tmp/system_path"), + "-isystem", QDir::toNativeSeparators("/tmp/builtin_path"))); +} + +TEST_F(CompilerOptionsBuilderTest, ClangHeadersPath) +{ + CompilerOptionsBuilder compilerOptionsBuilder(projectPart, + CppTools::UseSystemHeader::No, + CppTools::SkipBuiltIn::No, + "7.0.0", + ""); + + compilerOptionsBuilder.addHeaderPathOptions(); + + ASSERT_THAT(compilerOptionsBuilder.options(), + ElementsAre("-nostdinc", + "-nostdlibinc", + "-I", QDir::toNativeSeparators("/tmp/path"), + "-I", QDir::toNativeSeparators("/tmp/system_path"), + "-isystem", QDir::toNativeSeparators(CLANG_RESOURCE_DIR ""), + "-isystem", QDir::toNativeSeparators("/tmp/builtin_path"))); +} + +TEST_F(CompilerOptionsBuilderTest, ClangHeadersAndCppIncludesPathsOrderMacOs) +{ + auto defaultPaths = projectPart.headerPaths; + projectPart.headerPaths = {HeaderPath{"/usr/include/c++/4.2.1", HeaderPathType::BuiltIn}, + HeaderPath{"/usr/include/c++/4.2.1/backward", HeaderPathType::BuiltIn}, + HeaderPath{"/usr/local/include", HeaderPathType::BuiltIn}, + HeaderPath{"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include", HeaderPathType::BuiltIn}, + HeaderPath{"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include", HeaderPathType::BuiltIn}, + HeaderPath{"/usr/include", HeaderPathType::BuiltIn} + }; + projectPart.headerPaths.append(defaultPaths); + CompilerOptionsBuilder compilerOptionsBuilder(projectPart, + CppTools::UseSystemHeader::No, + CppTools::SkipBuiltIn::No, + "7.0.0", + ""); + + compilerOptionsBuilder.addHeaderPathOptions(); + + ASSERT_THAT(compilerOptionsBuilder.options(), + ElementsAre("-nostdinc", + "-nostdlibinc", + "-I", QDir::toNativeSeparators("/tmp/path"), + "-I", QDir::toNativeSeparators("/tmp/system_path"), + "-isystem", QDir::toNativeSeparators("/usr/include/c++/4.2.1"), + "-isystem", QDir::toNativeSeparators("/usr/include/c++/4.2.1/backward"), + "-isystem", QDir::toNativeSeparators("/usr/local/include"), + "-isystem", QDir::toNativeSeparators(CLANG_RESOURCE_DIR ""), + "-isystem", QDir::toNativeSeparators("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include"), + "-isystem", QDir::toNativeSeparators("/usr/include"), + "-isystem", QDir::toNativeSeparators("/tmp/builtin_path"))); +} + +TEST_F(CompilerOptionsBuilderTest, ClangHeadersAndCppIncludesPathsOrderLinux) +{ + projectPart.headerPaths = {HeaderPath{"/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8", HeaderPathType::BuiltIn}, + HeaderPath{"/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward", HeaderPathType::BuiltIn}, + HeaderPath{"/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8", HeaderPathType::BuiltIn}, + HeaderPath{"/usr/local/include", HeaderPathType::BuiltIn}, + HeaderPath{"/usr/lib/gcc/x86_64-linux-gnu/4.8/include", HeaderPathType::BuiltIn}, + HeaderPath{"/usr/include/x86_64-linux-gnu", HeaderPathType::BuiltIn}, + HeaderPath{"/usr/include", HeaderPathType::BuiltIn} + }; + projectPart.toolChainTargetTriple = "x86_64-linux-gnu"; + CompilerOptionsBuilder compilerOptionsBuilder(projectPart, + CppTools::UseSystemHeader::No, + CppTools::SkipBuiltIn::No, + "7.0.0", + ""); + + compilerOptionsBuilder.addHeaderPathOptions(); + + ASSERT_THAT(compilerOptionsBuilder.options(), + ElementsAre("-nostdinc", + "-nostdlibinc", + "-isystem", QDir::toNativeSeparators("/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8"), + "-isystem", QDir::toNativeSeparators("/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward"), + "-isystem", QDir::toNativeSeparators("/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8"), + "-isystem", QDir::toNativeSeparators(CLANG_RESOURCE_DIR ""), + "-isystem", QDir::toNativeSeparators("/usr/local/include"), + "-isystem", QDir::toNativeSeparators("/usr/lib/gcc/x86_64-linux-gnu/4.8/include"), + "-isystem", QDir::toNativeSeparators("/usr/include/x86_64-linux-gnu"), + "-isystem", QDir::toNativeSeparators("/usr/include"))); +} + +TEST_F(CompilerOptionsBuilderTest, NoPrecompiledHeader) +{ + compilerOptionsBuilder.addPrecompiledHeaderOptions(CompilerOptionsBuilder::PchUsage::None); + + ASSERT_THAT(compilerOptionsBuilder.options().empty(), true); +} + +TEST_F(CompilerOptionsBuilderTest, UsePrecompiledHeader) +{ + compilerOptionsBuilder.addPrecompiledHeaderOptions(CompilerOptionsBuilder::PchUsage::Use); + + ASSERT_THAT(compilerOptionsBuilder.options(), + ElementsAre("-include", QDir::toNativeSeparators(TESTDATA_DIR "/compileroptionsbuilder.pch"))); +} + +TEST_F(CompilerOptionsBuilderTest, AddMacros) +{ + compilerOptionsBuilder.addMacros(ProjectExplorer::Macros{ProjectExplorer::Macro{"key", "value"}}); + + ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("-Dkey=value")); +} + +TEST_F(CompilerOptionsBuilderTest, AddTargetTriple) +{ + compilerOptionsBuilder.addTargetTriple(); + + ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("-target", "x86_64-apple-darwin10")); +} + +TEST_F(CompilerOptionsBuilderTest, EnableCExceptions) +{ + projectPart.languageVersion = CppTools::ProjectPart::C99; + + compilerOptionsBuilder.enableExceptions(); + + ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("-fexceptions")); +} + +TEST_F(CompilerOptionsBuilderTest, EnableCXXExceptions) +{ + compilerOptionsBuilder.enableExceptions(); + + ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("-fcxx-exceptions", "-fexceptions")); +} + +TEST_F(CompilerOptionsBuilderTest, InsertWrappedQtHeaders) +{ + compilerOptionsBuilder.insertWrappedQtHeaders(); + + ASSERT_THAT(compilerOptionsBuilder.options(), Contains(IsPartOfHeader("wrappedQtHeaders"))); +} + +TEST_F(CompilerOptionsBuilderTest, SetLanguageVersion) +{ + compilerOptionsBuilder.updateLanguageOption(ProjectFile::CXXSource); + + ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("-x", "c++")); +} + +TEST_F(CompilerOptionsBuilderTest, HandleLanguageExtension) +{ + projectPart.languageExtensions = ProjectPart::ObjectiveCExtensions; + + compilerOptionsBuilder.updateLanguageOption(ProjectFile::CXXSource); + + ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("-x", "objective-c++")); +} + +TEST_F(CompilerOptionsBuilderTest, UpdateLanguageVersion) +{ + compilerOptionsBuilder.updateLanguageOption(ProjectFile::CXXSource); + + compilerOptionsBuilder.updateLanguageOption(ProjectFile::CXXHeader); + + ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("-x", "c++-header")); +} + +TEST_F(CompilerOptionsBuilderTest, AddMsvcCompatibilityVersion) +{ + projectPart.toolchainType = ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID; + projectPart.toolChainMacros.append(ProjectExplorer::Macro{"_MSC_FULL_VER", "190000000"}); + + compilerOptionsBuilder.addMsvcCompatibilityVersion(); + + ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("-fms-compatibility-version=19.00")); +} + +TEST_F(CompilerOptionsBuilderTest, UndefineCppLanguageFeatureMacrosForMsvc2015) +{ + projectPart.toolchainType = ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID; + projectPart.isMsvc2015Toolchain = true; + + compilerOptionsBuilder.undefineCppLanguageFeatureMacrosForMsvc2015(); + + ASSERT_THAT(compilerOptionsBuilder.options(), Contains(QString{"-U__cpp_aggregate_bases"})); +} + +TEST_F(CompilerOptionsBuilderTest, AddDefineFunctionMacrosMsvc) +{ + projectPart.toolchainType = ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID; + + compilerOptionsBuilder.addDefineFunctionMacrosMsvc(); + + ASSERT_THAT(compilerOptionsBuilder.options(), Contains(QString{"-D__FUNCTION__=\"\""})); +} + +TEST_F(CompilerOptionsBuilderTest, AddProjectConfigFileInclude) +{ + projectPart.projectConfigFile = "dummy_file.h"; + + compilerOptionsBuilder.addProjectConfigFileInclude(); + + ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("-include", "dummy_file.h")); +} + +TEST_F(CompilerOptionsBuilderTest, UndefineClangVersionMacrosForMsvc) +{ + projectPart.toolchainType = ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID; + + compilerOptionsBuilder.undefineClangVersionMacrosForMsvc(); + + ASSERT_THAT(compilerOptionsBuilder.options(), Contains(QString{"-U__clang__"})); +} + +TEST_F(CompilerOptionsBuilderTest, BuildAllOptions) +{ + compilerOptionsBuilder.build(ProjectFile::CXXSource, CompilerOptionsBuilder::PchUsage::None); + + ASSERT_THAT(compilerOptionsBuilder.options(), + ElementsAre( + "-nostdlibinc", "-c", "-m64", "-target", "x86_64-apple-darwin10", + "-arch", "x86_64", "-x", "c++", "-std=c++17", "-fcxx-exceptions", + "-fexceptions", "-Dfoo=bar", "-DprojectFoo=projectBar", "-undef", + "-I", QDir::toNativeSeparators("D:/code/qt-creator/tests/unit/unittest/../../../share/qtcreator/cplusplus/wrappedQtHeaders"), + "-I", QDir::toNativeSeparators("D:/code/qt-creator/tests/unit/unittest/../../../share/qtcreator/cplusplus/wrappedQtHeaders/QtCore"), + "-I", QDir::toNativeSeparators("/tmp/path"), + "-I", QDir::toNativeSeparators("/tmp/system_path"), + "-isystem", QDir::toNativeSeparators("/tmp/builtin_path") + )); +} + diff --git a/tests/unit/unittest/data/compileroptionsbuilder.pch b/tests/unit/unittest/data/compileroptionsbuilder.pch new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/unit/unittest/unittest.pro b/tests/unit/unittest/unittest.pro index c0807a541d2..bbd4c0f3aff 100644 --- a/tests/unit/unittest/unittest.pro +++ b/tests/unit/unittest/unittest.pro @@ -20,6 +20,7 @@ DEFINES += \ QT_USE_FAST_CONCATENATION \ UNIT_TESTS \ DONT_CHECK_MESSAGE_COUNTER \ + QTC_RESOURCE_DIR=\"R\\\"xxx($$PWD/../../../share/qtcreator)xxx\\\"\" \ TESTDATA_DIR=\"R\\\"xxx($$PWD/data)xxx\\\"\" msvc: QMAKE_CXXFLAGS_WARN_ON -= -w34100 # 'unreferenced formal parameter' in MATCHER_* functions win32:DEFINES += ECHOSERVER=\"R\\\"xxx($$OUT_PWD/../echo)xxx\\\"\" @@ -102,6 +103,7 @@ SOURCES += \ projectpartqueue-test.cpp \ processormanager-test.cpp \ taskscheduler-test.cpp \ + compileroptionsbuilder-test.cpp !isEmpty(LIBCLANG_LIBS) { SOURCES += \ From 1bc3103ef2d2a3e43f6e3e07479678aadb8a738a Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 4 Oct 2018 11:17:20 +0200 Subject: [PATCH 02/17] QmlProfiler: Add more fine grained checks to tool test The test frequently fails for unknown reasons. Check if we actually see the attach dialog, or if some other dialog interfers. Change-Id: Id279b8aa0a822dbdb565fe4105bfcb28ad704e3c Reviewed-by: Christian Kandeler --- .../tests/qmlprofilertool_test.cpp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp b/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp index 6a766b6aa86..ea27c3cb505 100644 --- a/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp +++ b/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp @@ -69,11 +69,22 @@ void QmlProfilerToolTest::testAttachToWaitingApplication() QTimer timer; timer.setInterval(100); + + bool modalSeen = false; + bool dialogAccepted = false; + connect(&timer, &QTimer::timeout, this, [&]() { - if (auto activeModal - = qobject_cast(QApplication::activeModalWidget())) { - activeModal->setPort(serverUrl.port()); - activeModal->accept(); + if (QWidget *activeModal = QApplication::activeModalWidget()) { + modalSeen = true; + auto dialog = qobject_cast(activeModal); + if (dialog) { + dialog->setPort(serverUrl.port()); + dialog->accept(); + dialogAccepted = true; + } else { + qWarning() << "Some other modal widget popped up:" << activeModal; + QFAIL("Interference from unrelated code."); + } } }); @@ -83,6 +94,8 @@ void QmlProfilerToolTest::testAttachToWaitingApplication() QTRY_VERIFY(connection); QTRY_VERIFY(runControl->isRunning()); + QTRY_VERIFY(modalSeen); + QTRY_VERIFY(dialogAccepted); QTRY_VERIFY(profilerTool.clientManager()->isConnected()); connection.reset(); From 2e4e18161bc2a80869fa3171c8855c3bca1393ac Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 4 Oct 2018 09:58:41 +0200 Subject: [PATCH 03/17] Debugger: Guard against some impossible situations Change-Id: Ia1fd356b4f8ef71dd3b456a3b28598ff680b9344 Reviewed-by: Christian Stenger --- src/plugins/debugger/debuggermainwindow.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index 7c7e632388d..c1586e6edd4 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -568,6 +568,7 @@ void Perspective::setEnabled(bool enabled) QToolButton *PerspectivePrivate::setupToolButton(QAction *action) { + QTC_ASSERT(action, return nullptr); auto toolButton = new QToolButton(m_innerToolBar); toolButton->setProperty("panelwidget", true); toolButton->setDefaultAction(action); @@ -577,16 +578,19 @@ QToolButton *PerspectivePrivate::setupToolButton(QAction *action) void Perspective::addToolBarAction(QAction *action) { + QTC_ASSERT(action, return); d->setupToolButton(action); } void Perspective::addToolBarAction(OptionalAction *action) { + QTC_ASSERT(action, return); action->m_toolButton = d->setupToolButton(action); } void Perspective::addToolBarWidget(QWidget *widget) { + QTC_ASSERT(widget, return); // QStyle::polish is called before it is added to the toolbar, explicitly make it a panel widget widget->setProperty("panelwidget", true); widget->setParent(d->m_innerToolBar); @@ -644,6 +648,7 @@ void Perspective::addWindow(QWidget *widget, bool visibleByDefault, Qt::DockWidgetArea area) { + QTC_ASSERT(widget, return); DockOperation op; op.widget = widget; if (anchorWidget) From 10262574d4f96c7d1505d526e67a4efaa0cea043 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 4 Oct 2018 14:44:39 +0200 Subject: [PATCH 04/17] Debugger: Fix stopping of core file debugging using the fat button Task-number: QTCREATORBUG-21094 Change-Id: If60f6bea93a583ab27e9e8b17c07402b2ac0854c Reviewed-by: Orgad Shaneh --- src/plugins/debugger/debugger.qrc | 2 ++ src/plugins/debugger/debuggericons.cpp | 3 +++ src/plugins/debugger/debuggericons.h | 1 + src/plugins/debugger/debuggerplugin.cpp | 4 ++-- .../debugger/images/debugger_stop_mask.png | Bin 0 -> 100 bytes .../debugger/images/debugger_stop_mask@2x.png | Bin 0 -> 104 bytes src/tools/icons/qtcreatoricons.svg | 21 ++++++++++++++++++ 7 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/plugins/debugger/images/debugger_stop_mask.png create mode 100644 src/plugins/debugger/images/debugger_stop_mask@2x.png diff --git a/src/plugins/debugger/debugger.qrc b/src/plugins/debugger/debugger.qrc index 4dbc903b591..2e457b74e13 100644 --- a/src/plugins/debugger/debugger.qrc +++ b/src/plugins/debugger/debugger.qrc @@ -14,6 +14,8 @@ images/debugger_interrupt@2x.png images/debugger_interrupt_mask.png images/debugger_interrupt_mask@2x.png + images/debugger_stop_mask.png + images/debugger_stop_mask@2x.png images/debugger_reversemode.png images/debugger_reversemode@2x.png images/debugger_reversemode_background.png diff --git a/src/plugins/debugger/debuggericons.cpp b/src/plugins/debugger/debuggericons.cpp index 776e54afe12..96107377df7 100644 --- a/src/plugins/debugger/debuggericons.cpp +++ b/src/plugins/debugger/debuggericons.cpp @@ -66,6 +66,9 @@ const Icon INTERRUPT( const Icon INTERRUPT_FLAT({ {":/debugger/images/debugger_interrupt_mask.png", Theme::IconsInterruptToolBarColor}, {":/projectexplorer/images/debugger_beetle_mask.png", Theme::IconsDebugColor}}); +const Icon STOP_FLAT({ + {":/debugger/images/debugger_stop_mask.png", Theme::IconsStopColor}, + {":/projectexplorer/images/debugger_beetle_mask.png", Theme::IconsDebugColor}}); const Icon DEBUG_INTERRUPT_SMALL({ {":/utils/images/interrupt_small.png", Theme::IconsInterruptColor}, {":/projectexplorer/images/debugger_overlay_small.png", Theme::PanelTextColorMid}}, Icon::MenuTintedStyle); diff --git a/src/plugins/debugger/debuggericons.h b/src/plugins/debugger/debuggericons.h index 0030597dbfa..3785a2191e5 100644 --- a/src/plugins/debugger/debuggericons.h +++ b/src/plugins/debugger/debuggericons.h @@ -50,6 +50,7 @@ extern const Utils::Icon DEBUG_CONTINUE_SMALL; extern const Utils::Icon DEBUG_CONTINUE_SMALL_TOOLBAR; extern const Utils::Icon INTERRUPT; extern const Utils::Icon INTERRUPT_FLAT; +extern const Utils::Icon STOP_FLAT; extern const Utils::Icon DEBUG_INTERRUPT_SMALL; extern const Utils::Icon DEBUG_INTERRUPT_SMALL_TOOLBAR; extern const Utils::Icon DEBUG_EXIT_SMALL; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 68f224f5eb2..e016674da5d 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1576,8 +1576,8 @@ void DebuggerPluginPrivate::updatePresetState() m_continueAction.setEnabled(false); m_exitAction.setEnabled(true); m_debugWithoutDeployAction.setEnabled(false); - m_visibleStartAction.setAction(&m_undisturbableAction); - m_visibleStartAction.setIcon(startIcon(true)); + m_visibleStartAction.setAction(&m_exitAction); + m_visibleStartAction.setIcon(Icons::STOP_FLAT.icon()); m_hiddenStopAction.setAction(&m_exitAction); m_stepAction.setEnabled(false); m_nextAction.setEnabled(false); diff --git a/src/plugins/debugger/images/debugger_stop_mask.png b/src/plugins/debugger/images/debugger_stop_mask.png new file mode 100644 index 0000000000000000000000000000000000000000..d56a35f4857ea097d0c8889bc98d6501cf43387c GIT binary patch literal 100 zcmeAS@N?(olHy`uVBq!ia0y~yU{C^KMrH;E28Pa=jSLJ7YymzYt_%ze|NsAAdUO6= z1_lO6PZ!4!j_Bkc{4DGe9ZHfCuU@((-SV5k!r*9IBAXlTp99kE>FVdQ&MBb@09_jy AzyJUM literal 0 HcmV?d00001 diff --git a/src/plugins/debugger/images/debugger_stop_mask@2x.png b/src/plugins/debugger/images/debugger_stop_mask@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..e69d67dfaf885ff989a870bf4096527e5efb69e3 GIT binary patch literal 104 zcmeAS@N?(olHy`uVBq!ia0y~yU~mCpMrH;E2By1=9~l@J*aCb)Tp1V`{{R2K^yd7# z3=9mio-U3d8o|jw_*vy8*qFN+Io`NOnxrRk|8_jf#Bk=#W{2Me{{t8p7#KWV{an^L HB{Ts5{^T8B literal 0 HcmV?d00001 diff --git a/src/tools/icons/qtcreatoricons.svg b/src/tools/icons/qtcreatoricons.svg index f3dca3a6c00..4dffd7a6b39 100644 --- a/src/tools/icons/qtcreatoricons.svg +++ b/src/tools/icons/qtcreatoricons.svg @@ -9464,6 +9464,27 @@ y="0" x="0" /> + + + + From 8f987866b67a6d7d2ff6e95d80936595ea5d112e Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 25 Sep 2018 08:24:10 +0200 Subject: [PATCH 05/17] Project: Introduce BaseIntegerAspect base using spinboxes Basically upstreamed/pimpled from VxWorks::BaseNumberValueAspect Change-Id: I1dbedbbdd55b684fe1bb823e57d4830fb2eb0b0e Reviewed-by: Christian Kandeler --- .../projectconfigurationaspects.cpp | 92 +++++++++++++++++++ .../projectconfigurationaspects.h | 27 ++++++ 2 files changed, 119 insertions(+) diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.cpp b/src/plugins/projectexplorer/projectconfigurationaspects.cpp index 92dd68f60a1..fc295bbec0e 100644 --- a/src/plugins/projectexplorer/projectconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/projectconfigurationaspects.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include using namespace Utils; @@ -77,6 +78,19 @@ public: QPixmap m_labelPixmap; }; +class BaseIntegerAspectPrivate +{ +public: + QVariant m_value; + QVariant m_minimumValue; + QVariant m_maximumValue; + int m_displayIntegerBase = 10; + QString m_label; + QString m_prefix; + QString m_suffix; + QPointer m_spinBox; // Owned by configuration widget +}; + } // Internal /*! @@ -337,4 +351,82 @@ void BaseBoolAspect::setLabel(const QString &label) d->m_label = label; } +/*! + \class ProjectExplorer::BaseIntegerAspect +*/ + +// BaseIntegerAspect + +BaseIntegerAspect::BaseIntegerAspect() + : d(new Internal::BaseIntegerAspectPrivate) +{} + +BaseIntegerAspect::~BaseIntegerAspect() = default; + +void BaseIntegerAspect::addToConfigurationLayout(QFormLayout *layout) +{ + QTC_CHECK(!d->m_spinBox); + d->m_spinBox = new QSpinBox(layout->parentWidget()); + d->m_spinBox->setValue(d->m_value.toInt()); + d->m_spinBox->setDisplayIntegerBase(d->m_displayIntegerBase); + d->m_spinBox->setPrefix(d->m_prefix); + d->m_spinBox->setSuffix(d->m_suffix); + if (d->m_maximumValue.isValid() && d->m_maximumValue.isValid()) + d->m_spinBox->setRange(d->m_minimumValue.toInt(), d->m_maximumValue.toInt()); + layout->addRow(d->m_label, d->m_spinBox); + connect(d->m_spinBox.data(), static_cast(&QSpinBox::valueChanged), + this, [this](int value) { + d->m_value = value; + emit changed(); + }); +} + +void BaseIntegerAspect::fromMap(const QVariantMap &map) +{ + d->m_value = map.value(settingsKey()); +} + +void BaseIntegerAspect::toMap(QVariantMap &data) const +{ + data.insert(settingsKey(), d->m_value); +} + +int BaseIntegerAspect::value() const +{ + return d->m_value.toInt(); +} + +void BaseIntegerAspect::setValue(int value) +{ + d->m_value = value; + if (d->m_spinBox) + d->m_spinBox->setValue(d->m_value.toInt()); +} + +void BaseIntegerAspect::setRange(int min, int max) +{ + d->m_minimumValue = min; + d->m_maximumValue = max; +} + +void BaseIntegerAspect::setLabel(const QString &label) +{ + d->m_label = label; +} + +void BaseIntegerAspect::setPrefix(const QString &prefix) +{ + d->m_prefix = prefix; +} + +void BaseIntegerAspect::setSuffix(const QString &suffix) +{ + d->m_suffix = suffix; +} + +void BaseIntegerAspect::setDisplayIntegerBase(int base) +{ + d->m_displayIntegerBase = base; +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.h b/src/plugins/projectexplorer/projectconfigurationaspects.h index a058c20ec0f..e47d232f2ee 100644 --- a/src/plugins/projectexplorer/projectconfigurationaspects.h +++ b/src/plugins/projectexplorer/projectconfigurationaspects.h @@ -38,6 +38,7 @@ namespace ProjectExplorer { namespace Internal { class BaseBoolAspectPrivate; class BaseStringAspectPrivate; +class BaseIntegerAspectPrivate; } // Internal class PROJECTEXPLORER_EXPORT BaseBoolAspect : public ProjectConfigurationAspect @@ -106,4 +107,30 @@ private: std::unique_ptr d; }; +class PROJECTEXPLORER_EXPORT BaseIntegerAspect : public ProjectConfigurationAspect +{ + Q_OBJECT + +public: + BaseIntegerAspect(); + ~BaseIntegerAspect() override; + + void addToConfigurationLayout(QFormLayout *layout) override; + + int value() const; + void setValue(int val); + + void setRange(int min, int max); + void setLabel(const QString &label); + void setPrefix(const QString &prefix); + void setSuffix(const QString &suffix); + void setDisplayIntegerBase(int base); + + void fromMap(const QVariantMap &map) override; + void toMap(QVariantMap &map) const override; + +private: + std::unique_ptr d; +}; + } // namespace ProjectExplorer From 25264d9bd904aaeaebe4f2f8b053fc1398793eb7 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 1 Oct 2018 14:22:49 +0300 Subject: [PATCH 06/17] Fix debugging on Android arm64/x86_64 On Android 64, there is no lib/ symlink anymore, so we need to upload gdbserver from QtCreator. Change-Id: Ib6f6d9b623dc61b72dd434ce1b3b409e880bdeaa Reviewed-by: Vikas Pachdha --- src/libs/utils/synchronousprocess.cpp | 19 ++++++++++-- src/libs/utils/synchronousprocess.h | 2 +- src/plugins/android/androidconfigurations.cpp | 23 +++++++++++++- src/plugins/android/androidconfigurations.h | 1 + src/plugins/android/androidrunnerworker.cpp | 31 ++++++++++++++++--- src/plugins/android/androidrunnerworker.h | 4 ++- src/plugins/android/androidtoolchain.cpp | 14 +-------- src/plugins/debugger/debuggerengine.cpp | 2 +- 8 files changed, 71 insertions(+), 25 deletions(-) diff --git a/src/libs/utils/synchronousprocess.cpp b/src/libs/utils/synchronousprocess.cpp index 0f8d4ea8258..f9ab96eb478 100644 --- a/src/libs/utils/synchronousprocess.cpp +++ b/src/libs/utils/synchronousprocess.cpp @@ -443,7 +443,8 @@ static bool isGuiThread() } SynchronousProcessResponse SynchronousProcess::run(const QString &binary, - const QStringList &args) + const QStringList &args, + const QByteArray &writeData) { if (debug) qDebug() << '>' << Q_FUNC_INFO << binary << args; @@ -454,8 +455,20 @@ SynchronousProcessResponse SynchronousProcess::run(const QString &binary, // executable cannot be found in the path. Do not start the // event loop in that case. d->m_binary = binary; - d->m_process.start(binary, args, QIODevice::ReadOnly); - d->m_process.closeWriteChannel(); + d->m_process.start(binary, args, writeData.isEmpty() ? QIODevice::ReadOnly : QIODevice::ReadWrite); + connect(&d->m_process, &QProcess::started, this, [this, writeData] { + if (!writeData.isEmpty()) { + int pos = 0; + int sz = writeData.size(); + do { + d->m_process.waitForBytesWritten(); + auto res = d->m_process.write(writeData.constData() + pos, sz - pos); + if (res > 0) pos += res; + } while (pos < sz); + d->m_process.waitForBytesWritten(); + } + d->m_process.closeWriteChannel(); + }); if (!d->m_startFailure) { d->m_timer.start(); if (isGuiThread()) diff --git a/src/libs/utils/synchronousprocess.h b/src/libs/utils/synchronousprocess.h index b1901207d8e..d8e3275030b 100644 --- a/src/libs/utils/synchronousprocess.h +++ b/src/libs/utils/synchronousprocess.h @@ -127,7 +127,7 @@ public: ExitCodeInterpreter exitCodeInterpreter() const; // Starts an nested event loop and runs the binary with the arguments - SynchronousProcessResponse run(const QString &binary, const QStringList &args); + SynchronousProcessResponse run(const QString &binary, const QStringList &args, const QByteArray &writeData = {}); // Starts the binary with the arguments blocking the UI fully SynchronousProcessResponse runBlocking(const QString &binary, const QStringList &args); diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index 0ceb88240f9..de738bee302 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -768,6 +768,27 @@ FileName AndroidConfig::ndkLocation() const return m_ndkLocation; } +static inline QString gdbServerArch(const Abi &abi) +{ + switch (abi.architecture()) { + case Abi::X86Architecture: + return abi.wordWidth() == 64 ? QString{"x86_64"} : QString{"x86"}; + case Abi::ArmArchitecture: + return abi.wordWidth() == 64 ? QString{"arm64"} : QString{"arm"}; + default: return {}; + }; +} + +FileName AndroidConfig::gdbServer(const ProjectExplorer::Abi &abi) const +{ + FileName path = AndroidConfigurations::currentConfig().ndkLocation(); + path.appendPath(QString::fromLatin1("prebuilt/android-%1/gdbserver/gdbserver") + .arg(gdbServerArch(abi))); + if (path.exists()) + return path; + return {}; +} + QVersionNumber AndroidConfig::ndkVersion() const { QVersionNumber version; @@ -1081,7 +1102,7 @@ void AndroidConfigurations::updateAutomaticKitList() QVariant id = Debugger::DebuggerItemManager::registerDebugger(debugger); Debugger::DebuggerKitInformation::setDebugger(toSetup, id); - AndroidGdbServerKitInformation::setGdbSever(toSetup, tc->suggestedGdbServer()); + AndroidGdbServerKitInformation::setGdbSever(toSetup, currentConfig().gdbServer(tc->targetAbi())); toSetup->makeSticky(); toSetup->setUnexpandedDisplayName(tr("Android for %1 (GCC %2, %3)") .arg(static_cast(qt)->targetArch()) diff --git a/src/plugins/android/androidconfigurations.h b/src/plugins/android/androidconfigurations.h index 941fab7fbd5..99544da511e 100644 --- a/src/plugins/android/androidconfigurations.h +++ b/src/plugins/android/androidconfigurations.h @@ -106,6 +106,7 @@ public: void setSdkManagerToolArgs(const QStringList &args); Utils::FileName ndkLocation() const; + Utils::FileName gdbServer(const ProjectExplorer::Abi &abi) const; QVersionNumber ndkVersion() const; void setNdkLocation(const Utils::FileName &ndkLocation); diff --git a/src/plugins/android/androidrunnerworker.cpp b/src/plugins/android/androidrunnerworker.cpp index f117d70c82e..b932e372a4a 100644 --- a/src/plugins/android/androidrunnerworker.cpp +++ b/src/plugins/android/androidrunnerworker.cpp @@ -29,6 +29,7 @@ #include "androidconstants.h" #include "androidmanager.h" #include "androidrunconfiguration.h" +#include "androidgdbserverkitinformation.h" #include #include @@ -42,6 +43,7 @@ #include #include #include +#include #include #include @@ -222,6 +224,7 @@ AndroidRunnerWorker::AndroidRunnerWorker(RunWorker *runner, const QString &packa << "Extra Start Args:" << m_amStartExtraArgs << "Before Start ADB cmds:" << m_beforeStartAdbCommands << "After finish ADB cmds:" << m_afterFinishAdbCommands; + m_gdbserverPath = AndroidGdbServerKitInformation::gdbServer(target->kit()).toString(); } AndroidRunnerWorker::~AndroidRunnerWorker() @@ -255,13 +258,13 @@ bool AndroidRunnerWorker::adbShellAmNeedsQuotes() return !oldSdk; } -bool AndroidRunnerWorker::runAdb(const QStringList &args, int timeoutS) +bool AndroidRunnerWorker::runAdb(const QStringList &args, int timeoutS, const QByteArray &writeData) { QStringList adbArgs = selector() + args; qCDebug(androidRunWorkerLog) << "ADB command: " << m_adb << adbArgs.join(' '); Utils::SynchronousProcess adb; adb.setTimeoutS(timeoutS); - Utils::SynchronousProcessResponse response = adb.run(m_adb, adbArgs); + Utils::SynchronousProcessResponse response = adb.run(m_adb, adbArgs, writeData); m_lastRunAdbError = response.exitMessage(m_adb, timeoutS); m_lastRunAdbRawOutput = response.allRawOutput(); bool success = response.result == Utils::SynchronousProcessResponse::Finished; @@ -269,6 +272,18 @@ bool AndroidRunnerWorker::runAdb(const QStringList &args, int timeoutS) return success; } +bool AndroidRunnerWorker::uploadFile(const QString &from, const QString &to, const QString &flags) +{ + QFile f(from); + if (!f.open(QIODevice::ReadOnly)) + return false; + runAdb({"shell", "run-as", m_packageName, "rm", to}); + auto res = runAdb({"shell", "run-as", m_packageName, "sh", "-c", QString("'cat > %1'").arg(to)}, 60, f.readAll()); + if (!res) + return false; + return runAdb({"shell", "run-as", m_packageName, "chmod", flags, to}); +} + void AndroidRunnerWorker::adbKill(qint64 pid) { runAdb({"shell", "kill", "-9", QString::number(pid)}); @@ -411,9 +426,15 @@ void AndroidRunnerWorker::asyncStartHelper() runAdb({"shell", "run-as", m_packageName, "chmod", "a+x", packageDir}); QString gdbServerExecutable; + QString gdbServerPrefix = "./lib/"; if (!runAdb({"shell", "run-as", m_packageName, "ls", "lib/"})) { - emit remoteProcessFinished(tr("Failed to get process path. Reason: %1.").arg(m_lastRunAdbError)); - return; + if (m_gdbserverPath.isEmpty()) { + emit remoteProcessFinished(tr("Failed to get process path. Reason: %1.").arg(m_lastRunAdbError)); + return; + } + uploadFile(m_gdbserverPath, "gdbserver"); + runAdb({"shell", "run-as", m_packageName, "ls"}); + gdbServerPrefix = "./"; } for (const auto &line: m_lastRunAdbRawOutput.split('\n')) { @@ -433,7 +454,7 @@ void AndroidRunnerWorker::asyncStartHelper() runAdb({"shell", "run-as", m_packageName, "rm", gdbServerSocket}); std::unique_ptr gdbServerProcess(new QProcess, deleter); gdbServerProcess->start(m_adb, selector() << "shell" << "run-as" - << m_packageName << "lib/" + gdbServerExecutable + << m_packageName << gdbServerPrefix + gdbServerExecutable << "--multi" << "+" + gdbServerSocket); if (!gdbServerProcess->waitForStarted()) { emit remoteProcessFinished(tr("Failed to start C++ debugger.")); diff --git a/src/plugins/android/androidrunnerworker.h b/src/plugins/android/androidrunnerworker.h index c9714724ccf..9c2bbf1f1be 100644 --- a/src/plugins/android/androidrunnerworker.h +++ b/src/plugins/android/androidrunnerworker.h @@ -47,7 +47,8 @@ public: AndroidRunnerWorker(ProjectExplorer::RunWorker *runner, const QString &packageName); ~AndroidRunnerWorker() override; bool adbShellAmNeedsQuotes(); - bool runAdb(const QStringList &args, int timeoutS = 10); + bool runAdb(const QStringList &args, int timeoutS = 10, const QByteArray &writeData = {}); + bool uploadFile(const QString &from, const QString &to, const QString &flags = "+x"); void adbKill(qint64 pid); QStringList selector() const; void forceStop(); @@ -110,6 +111,7 @@ protected: int m_apiLevel = -1; QString m_extraAppParams; Utils::Environment m_extraEnvVars; + QString m_gdbserverPath; }; } // namespace Internal diff --git a/src/plugins/android/androidtoolchain.cpp b/src/plugins/android/androidtoolchain.cpp index 9540b162408..7b32e5be69c 100644 --- a/src/plugins/android/androidtoolchain.cpp +++ b/src/plugins/android/androidtoolchain.cpp @@ -193,19 +193,7 @@ FileName AndroidToolChain::suggestedDebugger() const FileName AndroidToolChain::suggestedGdbServer() const { - FileName path = AndroidConfigurations::currentConfig().ndkLocation(); - path.appendPath(QString::fromLatin1("prebuilt/android-%1/gdbserver/gdbserver") - .arg(Abi::toString(targetAbi().architecture()))); - if (path.exists()) - return path; - path = AndroidConfigurations::currentConfig().ndkLocation(); - path.appendPath(QString::fromLatin1("toolchains/%1-%2/prebuilt/gdbserver") - .arg(AndroidConfig::toolchainPrefix(targetAbi())) - .arg(m_ndkToolChainVersion)); - if (path.exists()) - return path; - - return FileName(); + return AndroidConfigurations::currentConfig().gdbServer(targetAbi()); } QVariantMap AndroidToolChain::toMap() const diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index d18cfd3f54c..18092c8099e 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -2529,7 +2529,7 @@ Context CppDebuggerEngine::languageContext() const void CppDebuggerEngine::validateExecutable() { DebuggerRunParameters &rp = mutableRunParameters(); - const bool warnOnRelease = boolSetting(WarnOnReleaseBuilds); + const bool warnOnRelease = boolSetting(WarnOnReleaseBuilds) && rp.toolChainAbi.osFlavor() != Abi::AndroidLinuxFlavor; bool warnOnInappropriateDebugger = false; QString detailedWarning; switch (rp.toolChainAbi.binaryFormat()) { From 50d1790886430e99a702bf02598151f57656c814 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 4 Oct 2018 19:00:39 +0200 Subject: [PATCH 07/17] creatoricons.svg: Remove unused icons and adjust outdated ids Change-Id: I34989912a6e23de91a4ac2fa095c0b7826a4e578 Reviewed-by: Tim Jenssen --- src/tools/icons/export.py | 6 ++ src/tools/icons/qtcreatoricons.svg | 133 ++++------------------------- 2 files changed, 21 insertions(+), 118 deletions(-) diff --git a/src/tools/icons/export.py b/src/tools/icons/export.py index d7bb9a1bcc2..e28b7e6e4e9 100644 --- a/src/tools/icons/export.py +++ b/src/tools/icons/export.py @@ -68,6 +68,12 @@ for svgElement in svgTreeRoot.iter(): except: pass +for id in svgIDs: + pngFile = qtcSourceRoot + id + ".png" + pngAt2XFile = qtcSourceRoot + id + "@2x.png" + if not (os.path.isfile(pngFile) or os.path.isfile(pngAt2XFile)): + sys.stderr.write(id + " has not yet been exported as .png.\n") + # The shell mode of Inkscape is used to execute several export commands # with one launch of Inkscape. inkscapeShellCommands = "" diff --git a/src/tools/icons/qtcreatoricons.svg b/src/tools/icons/qtcreatoricons.svg index 4dffd7a6b39..1307b159a82 100644 --- a/src/tools/icons/qtcreatoricons.svg +++ b/src/tools/icons/qtcreatoricons.svg @@ -1300,7 +1300,7 @@ sodipodi:nodetypes="cc" /> + id="share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/images/down-arrow"> @@ -2528,52 +2528,6 @@ width="100%" height="100%" /> - - - - - - - - - @@ -2770,7 +2724,7 @@ x="0" /> + id="g2818" /> - - - - - @@ -4773,7 +4702,7 @@ + id="src/libs/tracing/qml/ico_rangeselection"> + id="src/libs/tracing/qml/ico_rangeselected"> + id="src/libs/tracing/qml/ico_edit"> - - - - - - - + id="../boot2qt/common/images/boot2qtdevice"> + id="../boot2qt/common/images/boot2qtemulator"> + id="../boot2qt/common/images/boot2qtstartvm"> + id="../vxworks/plugins/vxworks/images/vxworksqtdevice"> Date: Fri, 5 Oct 2018 08:00:46 +0200 Subject: [PATCH 08/17] Android: Fix compile for gcc5.3 Change-Id: Ic061a4bc55e1924b82cc2ac1fd5c483654de90eb Reviewed-by: Orgad Shaneh --- src/plugins/android/androidrunnerworker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/android/androidrunnerworker.h b/src/plugins/android/androidrunnerworker.h index 9c2bbf1f1be..ee5ec87287a 100644 --- a/src/plugins/android/androidrunnerworker.h +++ b/src/plugins/android/androidrunnerworker.h @@ -48,7 +48,7 @@ public: ~AndroidRunnerWorker() override; bool adbShellAmNeedsQuotes(); bool runAdb(const QStringList &args, int timeoutS = 10, const QByteArray &writeData = {}); - bool uploadFile(const QString &from, const QString &to, const QString &flags = "+x"); + bool uploadFile(const QString &from, const QString &to, const QString &flags = QString("+x")); void adbKill(qint64 pid); QStringList selector() const; void forceStop(); From 0f4782fbcad7cd71de3967f58f0d29e099431548 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 4 Oct 2018 20:03:22 +0200 Subject: [PATCH 09/17] design.creatortheme: Set DarkUserInterface=true It is a dark theme and should be marked accordingly. Change-Id: I437a293162f5bff4ac549f08401ed9f7349213eb Reviewed-by: Eike Ziller --- share/qtcreator/themes/design.creatortheme | 1 + 1 file changed, 1 insertion(+) diff --git a/share/qtcreator/themes/design.creatortheme b/share/qtcreator/themes/design.creatortheme index b3ca4e3a02a..60f074f328a 100644 --- a/share/qtcreator/themes/design.creatortheme +++ b/share/qtcreator/themes/design.creatortheme @@ -419,6 +419,7 @@ FlatProjectsMode=true FlatMenuBar=true ToolBarIconShadow=true WindowColorAsBase=false +DarkUserInterface=true [Gradients] DetailsWidgetHeaderGradient\1\color=00000000 From e8f28dbef34adbbb46c04ca1f497f5a07d5c3ae7 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 5 Oct 2018 01:24:49 +0200 Subject: [PATCH 10/17] LanguageClient: Add an options icon Server "can" with speech bubble saying "<>". Change-Id: I7eca0109aa5917f341f6310c8f175b1833ff9c00 Reviewed-by: Eike Ziller --- .../settingscategory_languageclient.png | Bin 0 -> 227 bytes .../settingscategory_languageclient@2x.png | Bin 0 -> 433 bytes src/plugins/languageclient/languageclient.pro | 3 + src/plugins/languageclient/languageclient.qrc | 6 ++ .../languageclient/languageclientsettings.cpp | 3 +- src/tools/icons/qtcreatoricons.svg | 69 ++++++++++++++++++ 6 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/plugins/languageclient/images/settingscategory_languageclient.png create mode 100644 src/plugins/languageclient/images/settingscategory_languageclient@2x.png create mode 100644 src/plugins/languageclient/languageclient.qrc diff --git a/src/plugins/languageclient/images/settingscategory_languageclient.png b/src/plugins/languageclient/images/settingscategory_languageclient.png new file mode 100644 index 0000000000000000000000000000000000000000..78978b45ca14b603e82bb705bb7390c77ca97ecd GIT binary patch literal 227 zcmeAS@N?(olHy`uVBq!ia0y~yV2}V|4h9AWhNCh`Dhvz^t2|vCLp07O|LA8nxZsqu zP=lGJL(gTZz}{c~|H~`@8DJ?VNH2Vp~Tv%U&V_QP6)5jzccaA!3~#!yL?Y& ziyrN@4mEq?eG`KelFuVK}xA^#9x7k3Bmq%b@ z_^zk_|Cg_}brn0j{NYl*=5y2Ev++os@3{QIYr5m(pa1{A_mwzMCUAuzl>fS;2lEMA zeZ@WI3E_dBho`4{swu5mW1!wx`;D3dW`=D%M-E)j>M#gjA^Ya+R-SpqHzn@aC!Aj7zTdhBl^(D5l20n|NGVOlmeYFJF52?lc}AzWJO}@7V`j mzT~geRXt^kNt7mE9xnsWhYhO)-mQ`a#f7J + + images/settingscategory_languageclient.png + images/settingscategory_languageclient@2x.png + + diff --git a/src/plugins/languageclient/languageclientsettings.cpp b/src/plugins/languageclient/languageclientsettings.cpp index 4348e95e521..6b23f38e7c6 100644 --- a/src/plugins/languageclient/languageclientsettings.cpp +++ b/src/plugins/languageclient/languageclientsettings.cpp @@ -201,7 +201,8 @@ LanguageClientSettingsPage::LanguageClientSettingsPage() setCategory(Constants::LANGUAGECLIENT_SETTINGS_CATEGORY); setDisplayCategory(QCoreApplication::translate("LanguageClient", Constants::LANGUAGECLIENT_SETTINGS_TR)); - //setCategoryIcon( /* TODO */ ); + setCategoryIcon(Utils::Icon({{":/languageclient/images/settingscategory_languageclient.png", + Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint)); } LanguageClientSettingsPage::~LanguageClientSettingsPage() diff --git a/src/tools/icons/qtcreatoricons.svg b/src/tools/icons/qtcreatoricons.svg index 1307b159a82..67f88eda497 100644 --- a/src/tools/icons/qtcreatoricons.svg +++ b/src/tools/icons/qtcreatoricons.svg @@ -3119,6 +3119,75 @@ width="100%" height="100%" /> + + + + + + + + + + + Date: Fri, 5 Oct 2018 09:14:47 +0200 Subject: [PATCH 11/17] QmlProfiler: Make the tool test more robust Apparently there is a different message box that commonly pops up while we are waiting for the attach dialog. Just close it and try again. Also, stop the timer once we have seen the dialog. Otherwise we might fail on extra message boxes that pop up afterwards. Change-Id: I06ae16eb3ad89c9a022ac6fae781f8465425d96f Reviewed-by: Christian Stenger --- src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp b/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp index ea27c3cb505..a519f6a775a 100644 --- a/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp +++ b/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp @@ -71,8 +71,6 @@ void QmlProfilerToolTest::testAttachToWaitingApplication() timer.setInterval(100); bool modalSeen = false; - bool dialogAccepted = false; - connect(&timer, &QTimer::timeout, this, [&]() { if (QWidget *activeModal = QApplication::activeModalWidget()) { modalSeen = true; @@ -80,10 +78,10 @@ void QmlProfilerToolTest::testAttachToWaitingApplication() if (dialog) { dialog->setPort(serverUrl.port()); dialog->accept(); - dialogAccepted = true; + timer.stop(); } else { qWarning() << "Some other modal widget popped up:" << activeModal; - QFAIL("Interference from unrelated code."); + activeModal->close(); } } }); @@ -95,7 +93,7 @@ void QmlProfilerToolTest::testAttachToWaitingApplication() QTRY_VERIFY(connection); QTRY_VERIFY(runControl->isRunning()); QTRY_VERIFY(modalSeen); - QTRY_VERIFY(dialogAccepted); + QTRY_VERIFY(!timer.isActive()); QTRY_VERIFY(profilerTool.clientManager()->isConnected()); connection.reset(); From a743e25d272ed3c96c706d7e7fa07418c7ab0e0c Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 4 Oct 2018 15:34:12 +0200 Subject: [PATCH 12/17] Debugger: Use the intented mechanism to update icon on the fat button Change-Id: I58e40c2d3db23d00d55e5e86c6f4ebc6cbabea90 Reviewed-by: Christian Stenger --- src/plugins/debugger/debuggerplugin.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index e016674da5d..dcf62cbd1e7 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1143,11 +1143,14 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, m_visibleStartAction.initialize(&m_startAction); m_visibleStartAction.setAttribute(ProxyAction::UpdateText); + m_visibleStartAction.setAttribute(ProxyAction::UpdateIcon); m_visibleStartAction.setAction(&m_startAction); - m_visibleStartAction.setIcon(startIcon(true)); ModeManager::addAction(&m_visibleStartAction, Constants::P_ACTION_DEBUG); + m_undisturbableAction.setIcon(interruptIcon(false)); + m_undisturbableAction.setEnabled(false); + cmd = ActionManager::registerAction(&m_debugWithoutDeployAction, "Debugger.DebugWithoutDeploy"); cmd->setAttribute(Command::CA_Hide); @@ -1475,7 +1478,7 @@ void DebuggerPluginPrivate::updatePresetState() m_continueAction.setEnabled(false); m_exitAction.setEnabled(false); m_debugWithoutDeployAction.setEnabled(canRun); - m_visibleStartAction.setIcon(startIcon(true)); + m_visibleStartAction.setAction(&m_startAction); m_hiddenStopAction.setAction(&m_undisturbableAction); m_detachAction.setEnabled(false); m_jumpToLineAction.setEnabled(false); @@ -1517,7 +1520,6 @@ void DebuggerPluginPrivate::updatePresetState() m_exitAction.setEnabled(true); m_debugWithoutDeployAction.setEnabled(false); m_visibleStartAction.setAction(&m_continueAction); - m_visibleStartAction.setIcon(continueIcon(true)); m_hiddenStopAction.setAction(&m_exitAction); m_stepAction.setEnabled(!companionPreventsAction); m_nextAction.setEnabled(!companionPreventsAction); @@ -1537,7 +1539,6 @@ void DebuggerPluginPrivate::updatePresetState() m_exitAction.setEnabled(true); m_debugWithoutDeployAction.setEnabled(false); m_visibleStartAction.setAction(&m_interruptAction); - m_visibleStartAction.setIcon(interruptIcon(true)); m_hiddenStopAction.setAction(&m_interruptAction); m_stepAction.setEnabled(false); m_nextAction.setEnabled(false); @@ -1557,7 +1558,6 @@ void DebuggerPluginPrivate::updatePresetState() m_exitAction.setEnabled(false); m_debugWithoutDeployAction.setEnabled(canRun); m_visibleStartAction.setAction(&m_startAction); - m_visibleStartAction.setIcon(startIcon(true)); m_hiddenStopAction.setAction(&m_undisturbableAction); m_stepAction.setEnabled(false); m_nextAction.setEnabled(false); @@ -1577,7 +1577,6 @@ void DebuggerPluginPrivate::updatePresetState() m_exitAction.setEnabled(true); m_debugWithoutDeployAction.setEnabled(false); m_visibleStartAction.setAction(&m_exitAction); - m_visibleStartAction.setIcon(Icons::STOP_FLAT.icon()); m_hiddenStopAction.setAction(&m_exitAction); m_stepAction.setEnabled(false); m_nextAction.setEnabled(false); @@ -1589,10 +1588,10 @@ void DebuggerPluginPrivate::updatePresetState() m_stepOutAction.setEnabled(false); m_runToLineAction.setEnabled(false); m_runToSelectedFunctionAction.setEnabled(false); - } else if (state == DebuggerNotReady) { - // The startup phase should be over once we are here - QTC_CHECK(false); } else { + // The startup phase should be over once we are here. + // But treat it as 'undisturbable if we are here by accident. + QTC_CHECK(state != DebuggerNotReady); // Everything else is "undisturbable". m_startAction.setEnabled(false); m_interruptAction.setEnabled(false); @@ -1600,7 +1599,6 @@ void DebuggerPluginPrivate::updatePresetState() m_exitAction.setEnabled(false); m_debugWithoutDeployAction.setEnabled(false); m_visibleStartAction.setAction(&m_undisturbableAction); - m_visibleStartAction.setIcon(startIcon(true)); m_hiddenStopAction.setAction(&m_undisturbableAction); m_stepAction.setEnabled(false); m_nextAction.setEnabled(false); From 4d2a6db1a8ed2936355b98ea743b750d0f072ec3 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 4 Oct 2018 17:25:11 +0200 Subject: [PATCH 13/17] Debugger: Show something in start action text again ... even if the action is disabled. Change-Id: I7f5bb0abd73d25650fab4c9dafbe70c772d2cb0e Reviewed-by: hjk Reviewed-by: Orgad Shaneh --- src/plugins/debugger/debuggerplugin.cpp | 33 +++++++++++++------------ 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index dcf62cbd1e7..64a085cd9e0 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1449,28 +1449,31 @@ void DebuggerPluginPrivate::updatePresetState() DebuggerEngine *currentEngine = EngineManager::currentEngine(); QString whyNot; - const bool canRun = startupProject - && ProjectExplorerPlugin::canRunStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, &whyNot); + const bool canRun = + ProjectExplorerPlugin::canRunStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, &whyNot); + + QString startupRunConfigName; + if (startupRunConfig) + startupRunConfigName = startupRunConfig->displayName(); + if (startupRunConfigName.isEmpty() && startupProject) + startupRunConfigName = startupProject->displayName(); + + const QString startToolTip = + canRun ? tr("Start debugging of \"%1\"").arg(startupRunConfigName) : whyNot; + + m_startAction.setToolTip(startToolTip); + m_startAction.setText(canRun ? startToolTip : tr("Start Debugging")); if (!currentEngine || !currentEngine->isStartupRunConfiguration()) { // No engine running -- or -- we have a running engine but it does not // correspond to the current start up project. - QString startupRunConfigName; - if (startupRunConfig) - startupRunConfigName = startupRunConfig->displayName(); - if (startupRunConfigName.isEmpty() && startupProject) - startupRunConfigName = startupProject->displayName(); - - QString startToolTip = canRun ? tr("Start debugging of \"%1\"").arg(startupRunConfigName) : whyNot; - QString stepToolTip = canRun ? tr("Start \"%1\" and break at function \"main\"").arg(startupRunConfigName) : whyNot; // Step into/next: Start and break at 'main' unless a debugger is running. - m_stepAction.setEnabled(canRun); + QString stepToolTip = canRun ? tr("Start \"%1\" and break at function \"main\"").arg(startupRunConfigName) : whyNot; m_stepAction.setToolTip(stepToolTip); - m_nextAction.setEnabled(canRun); m_nextAction.setToolTip(stepToolTip); + m_stepAction.setEnabled(canRun); + m_nextAction.setEnabled(canRun); m_startAction.setEnabled(canRun); - m_startAction.setToolTip(startToolTip); - m_startAction.setText(startToolTip); m_startAction.setIcon(startIcon(false)); m_startAction.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); m_startAction.setVisible(true); @@ -1493,8 +1496,6 @@ void DebuggerPluginPrivate::updatePresetState() m_nextAction.setToolTip(QString()); // The 'state' bits only affect the fat debug button, not the preset start button. - m_startAction.setText(QString()); - m_startAction.setToolTip(whyNot); m_startAction.setIcon(startIcon(false)); m_startAction.setEnabled(false); m_startAction.setVisible(false); From efc851e01e1d5cd16ec2cd69a640b192e5e43e6d Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 5 Oct 2018 09:31:25 +0200 Subject: [PATCH 14/17] Debugger: Hide 'Registers' by default Registers had been not visible before 4.8 except the user explicitly enables it. Change-Id: Ie515a59b40a7f3cd3b9e62eca2707d8a76ab4ab1 Reviewed-by: hjk --- src/plugins/debugger/debuggerengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 18092c8099e..67a01d026c1 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -770,7 +770,7 @@ void DebuggerEnginePrivate::setupViews() m_perspective->addWindow(m_sourceFilesWindow, Perspective::AddToTab, m_modulesWindow, false); m_perspective->addWindow(m_localsAndInspectorWindow, Perspective::AddToTab, nullptr, true, Qt::RightDockWidgetArea); m_perspective->addWindow(m_watchersWindow, Perspective::AddToTab, m_localsAndInspectorWindow, true, Qt::RightDockWidgetArea); - m_perspective->addWindow(m_registerWindow, Perspective::AddToTab, m_watchersWindow, true, Qt::RightDockWidgetArea); + m_perspective->addWindow(m_registerWindow, Perspective::AddToTab, m_watchersWindow, false, Qt::RightDockWidgetArea); m_perspective->addWindow(m_logWindow, Perspective::AddToTab, nullptr, false, Qt::TopDockWidgetArea); m_perspective->select(); From 5811848a7b273771e85a72fcdd3bf0aca1965fcd Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Tue, 2 Oct 2018 12:51:55 +0300 Subject: [PATCH 15/17] Android: Remove old support for gdbserver Change-Id: I6d2e8abf0baa5606ad3d79cc7f1f57813e8255b1 Reviewed-by: BogDan Vatra Reviewed-by: Vikas Pachdha --- src/plugins/android/androidrunnerworker.cpp | 27 +++------------------ 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/plugins/android/androidrunnerworker.cpp b/src/plugins/android/androidrunnerworker.cpp index b932e372a4a..648a0d363d4 100644 --- a/src/plugins/android/androidrunnerworker.cpp +++ b/src/plugins/android/androidrunnerworker.cpp @@ -425,36 +425,17 @@ void AndroidRunnerWorker::asyncStartHelper() // e.g. on Android 8 with NDK 10e runAdb({"shell", "run-as", m_packageName, "chmod", "a+x", packageDir}); - QString gdbServerExecutable; - QString gdbServerPrefix = "./lib/"; - if (!runAdb({"shell", "run-as", m_packageName, "ls", "lib/"})) { - if (m_gdbserverPath.isEmpty()) { - emit remoteProcessFinished(tr("Failed to get process path. Reason: %1.").arg(m_lastRunAdbError)); - return; - } - uploadFile(m_gdbserverPath, "gdbserver"); - runAdb({"shell", "run-as", m_packageName, "ls"}); - gdbServerPrefix = "./"; - } - - for (const auto &line: m_lastRunAdbRawOutput.split('\n')) { - if (line.indexOf("gdbserver") != -1/* || line.indexOf("lldb-server") != -1*/) { - gdbServerExecutable = QString::fromUtf8(line.trimmed()); - break; - } - } - - if (gdbServerExecutable.isEmpty()) { - emit remoteProcessFinished(tr("Cannot find C++ debugger.")); + if (m_gdbserverPath.isEmpty() || !uploadFile(m_gdbserverPath, "gdbserver")) { + emit remoteProcessFinished(tr("Can not find/copy C++ debug server.")); return; } QString gdbServerSocket = packageDir + "/debug-socket"; - runAdb({"shell", "run-as", m_packageName, "killall", gdbServerExecutable}); + runAdb({"shell", "run-as", m_packageName, "killall", "gdbserver"}); runAdb({"shell", "run-as", m_packageName, "rm", gdbServerSocket}); std::unique_ptr gdbServerProcess(new QProcess, deleter); gdbServerProcess->start(m_adb, selector() << "shell" << "run-as" - << m_packageName << gdbServerPrefix + gdbServerExecutable + << m_packageName << "./gdbserver" << "--multi" << "+" + gdbServerSocket); if (!gdbServerProcess->waitForStarted()) { emit remoteProcessFinished(tr("Failed to start C++ debugger.")); From 0e84c8892d98adb61c16d6a9acfee6abfa1a7abe Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 4 Oct 2018 15:55:42 +0200 Subject: [PATCH 16/17] Debugger: Do not double quote in tooltips Instead of e.g. 'Interrupt "GDB for "test""' use 'Interrupt GDB for "test"' for button tooltips. Change-Id: Ibe08e0007800332696dbc7f298bf5119ea8e5338 Reviewed-by: Christian Stenger --- src/plugins/debugger/debuggerplugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 64a085cd9e0..81c657345bc 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1501,8 +1501,8 @@ void DebuggerPluginPrivate::updatePresetState() m_startAction.setVisible(false); QString currentDisplayName = currentEngine->displayName(); - m_interruptAction.setToolTip(tr("Interrupt \"%1\"").arg(currentDisplayName)); - m_continueAction.setToolTip(tr("Continue \"%1\"").arg(currentDisplayName)); + m_interruptAction.setToolTip(tr("Interrupt %1").arg(currentDisplayName)); + m_continueAction.setToolTip(tr("Continue %1").arg(currentDisplayName)); m_debugWithoutDeployAction.setEnabled(canRun); From e0d7d037207c2716380b7a2a860e13138f6eaed5 Mon Sep 17 00:00:00 2001 From: Ivan Donchevskii Date: Tue, 2 Oct 2018 10:53:31 +0200 Subject: [PATCH 17/17] Clang: Fix ClangFormat build with clang-7 Change-Id: I0859b7aad1a49f8d46ee4b32cc32039cfa0b482b Reviewed-by: Tobias Hunger --- qbs/modules/libclang/functions.js | 34 ++++++++++++++----- qbs/modules/libclang/libclang.qbs | 2 +- src/plugins/clangformat/clangformat.pro | 2 +- .../clangformat/clangformatindenter.cpp | 7 ++++ src/shared/clang/clang_installation.pri | 14 ++++++-- 5 files changed, 45 insertions(+), 14 deletions(-) diff --git a/qbs/modules/libclang/functions.js b/qbs/modules/libclang/functions.js index 85334992600..bdffcc9c23a 100644 --- a/qbs/modules/libclang/functions.js +++ b/qbs/modules/libclang/functions.js @@ -101,17 +101,33 @@ function extraLibraries(llvmConfig, targetOS) })); } -function formattingLibs(llvmConfig, targetOS) +function formattingLibs(llvmConfig, qtcFunctions, targetOS) { - var fixedList = [ - "clangFormat", - "clangToolingCore", - "clangRewrite", - "clangLex", - "clangBasic", - ]; + var clangVersion = version(llvmConfig) + var libs = [] + if (qtcFunctions.versionIsAtLeast(clangVersion, MinimumLLVMVersion)) { + if (qtcFunctions.versionIsAtLeast(clangVersion, "7.0.0")) { + libs.concat([ + "clangFormat", + "clangToolingInclusions", + "clangToolingCore", + "clangRewrite", + "clangLex", + "clangBasic", + ]); + } else { + libs.concat([ + "clangFormat", + "clangToolingCore", + "clangRewrite", + "clangLex", + "clangBasic", + ]); + } + libs.concat(extraLibraries(llvmConfig, targetOS)); + } - return fixedList.concat(extraLibraries(llvmConfig, targetOS)); + return libs; } function toolingLibs(llvmConfig, targetOS) diff --git a/qbs/modules/libclang/libclang.qbs b/qbs/modules/libclang/libclang.qbs index 1d695a2c8d5..e95250ddba3 100644 --- a/qbs/modules/libclang/libclang.qbs +++ b/qbs/modules/libclang/libclang.qbs @@ -38,7 +38,7 @@ Module { llvmToolingDefines = toolingParams.defines; llvmToolingIncludes = toolingParams.includes; llvmToolingCxxFlags = toolingParams.cxxFlags; - llvmFormattingLibs = ClangFunctions.formattingLibs(llvmConfig, targetOS); + llvmFormattingLibs = ClangFunctions.formattingLibs(llvmConfig, QtcFunctions, targetOS); found = llvmConfig && File.exists(llvmIncludeDir.concat("/clang-c/Index.h")); } } diff --git a/src/plugins/clangformat/clangformat.pro b/src/plugins/clangformat/clangformat.pro index 8657acb21b3..c2e2edd49f5 100644 --- a/src/plugins/clangformat/clangformat.pro +++ b/src/plugins/clangformat/clangformat.pro @@ -3,7 +3,7 @@ include(../../shared/clang/clang_installation.pri) include(../../shared/clang/clang_defines.pri) -requires(!isEmpty(LLVM_VERSION)) +requires(!isEmpty(CLANGFORMAT_LIBS)) win32 { LLVM_BUILDMODE = $$system($$llvm_config --build-mode, lines) diff --git a/src/plugins/clangformat/clangformatindenter.cpp b/src/plugins/clangformat/clangformatindenter.cpp index f83cefb8aed..3164f4ad003 100644 --- a/src/plugins/clangformat/clangformatindenter.cpp +++ b/src/plugins/clangformat/clangformatindenter.cpp @@ -36,6 +36,8 @@ #include +#include + #include #include #include @@ -60,7 +62,12 @@ void adjustFormatStyleForLineBreak(format::FormatStyle &style, if (length > 0) style.ColumnLimit = prevBlockSize; style.AlwaysBreakBeforeMultilineStrings = true; +#if LLVM_VERSION_MAJOR >= 7 + style.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes; +#else style.AlwaysBreakTemplateDeclarations = true; +#endif + style.AllowAllParametersOfDeclarationOnNextLine = true; style.AllowShortBlocksOnASingleLine = true; style.AllowShortCaseLabelsOnASingleLine = true; diff --git a/src/shared/clang/clang_installation.pri b/src/shared/clang/clang_installation.pri index 863d29cf481..728cbb3ba4e 100644 --- a/src/shared/clang/clang_installation.pri +++ b/src/shared/clang/clang_installation.pri @@ -116,9 +116,6 @@ CLANGTOOLING_LIBS=-lclangTooling -lclangIndex -lclangFrontend -lclangParse -lcla -lclangASTMatchers -lclangToolingCore -lclangAST -lclangLex -lclangBasic win32:CLANGTOOLING_LIBS += -lversion -CLANGFORMAT_LIBS=-lclangFormat -lclangToolingCore -lclangRewrite -lclangLex -lclangBasic -win32:CLANGFORMAT_LIBS += -lversion - BIN_EXTENSION = win32: BIN_EXTENSION = .exe @@ -141,6 +138,17 @@ isEmpty(LLVM_INSTALL_DIR) { output = $$system($$llvm_config --version, lines) LLVM_VERSION = $$extractVersion($$output) + +!isEmpty(LLVM_VERSION) { + versionIsAtLeast($$LLVM_VERSION, 7, 0, 0): { + CLANGFORMAT_LIBS=-lclangFormat -lclangToolingInclusions -lclangToolingCore -lclangRewrite -lclangLex -lclangBasic + win32:CLANGFORMAT_LIBS += -lversion + } else:versionIsAtLeast($$LLVM_VERSION, 6, 0, 0): { + CLANGFORMAT_LIBS=-lclangFormat -lclangToolingCore -lclangRewrite -lclangLex -lclangBasic + win32:CLANGFORMAT_LIBS += -lversion + } +} + isEmpty(LLVM_VERSION) { $$llvmWarningOrError(\ "Cannot determine clang version. Set LLVM_INSTALL_DIR to build the Clang Code Model",\