From 06bb01249b5c4e246df4bec61b0e0624dccfd774 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Wed, 23 Jul 2014 11:54:36 +0200 Subject: Android: Check for broken gdb on mac Task-number: QTCREATORBUG-12636 Change-Id: Ib41db2607fef6291c1464e5ce2ea626fd86b3025 Reviewed-by: hjk --- src/plugins/android/androidsettingswidget.cpp | 78 +++++ src/plugins/android/androidsettingswidget.h | 5 + src/plugins/android/androidsettingswidget.ui | 421 +++++++++++++++----------- 3 files changed, 332 insertions(+), 172 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp index 4fc6d78ec7..6db4467442 100644 --- a/src/plugins/android/androidsettingswidget.cpp +++ b/src/plugins/android/androidsettingswidget.cpp @@ -49,6 +49,8 @@ #include #include #include +#include +#include #include #include @@ -170,11 +172,16 @@ AndroidSettingsWidget::AndroidSettingsWidget(QWidget *parent) m_ui->downloadAntToolButton->setVisible(!Utils::HostOsInfo::isLinuxHost()); m_ui->downloadOpenJDKToolButton->setVisible(!Utils::HostOsInfo::isLinuxHost()); + connect(m_ui->gdbWarningLabel, SIGNAL(linkActivated(QString)), + this, SLOT(showGdbWarningDialog())); + check(All); applyToUi(All); connect(&m_futureWatcher, SIGNAL(finished()), this, SLOT(avdAdded())); + connect(&m_checkGdbWatcher, SIGNAL(finished()), + this, SLOT(checkGdbFinished())); } AndroidSettingsWidget::~AndroidSettingsWidget() @@ -183,6 +190,41 @@ AndroidSettingsWidget::~AndroidSettingsWidget() m_futureWatcher.waitForFinished(); } +// NOTE: Will be run via QFuture +static QPair checkGdbForBrokenPython(const QString &path) +{ + QTime timer; + timer.start(); + QProcess proc; + proc.setProcessChannelMode(QProcess::MergedChannels); + proc.start(path); + proc.waitForStarted(); + + QByteArray output; + while (proc.waitForReadyRead(300)) { + output += proc.readAll(); + if (output.contains("(gdb)")) + break; + if (timer.elapsed() > 7 * 1000) + return qMakePair(path, false); // Took too long, abort + } + + output.clear(); + + proc.write("python import struct\n"); + proc.write("quit\n"); + while (proc.waitForFinished(300)) { + if (timer.elapsed() > 9 * 1000) + return qMakePair(path, false); // Took too long, abort + } + proc.waitForFinished(); + + output = proc.readAll(); + + bool error = output.contains("_PyObject_Free") || output.contains("_PyExc_IOError"); + return qMakePair(path, error); +} + void AndroidSettingsWidget::check(AndroidSettingsWidget::Mode mode) { if (mode & Sdk) { @@ -214,6 +256,23 @@ void AndroidSettingsWidget::check(AndroidSettingsWidget::Mode mode) = AndroidToolChainFactory::toolchainPathsForNdk(m_androidConfig.ndkLocation()); m_ndkCompilerCount = compilerPaths.count(); + // Check for a gdb with a broken python + if (Utils::HostOsInfo::isMacHost()) { + foreach (const AndroidToolChainFactory::AndroidToolChainInformation &ati, compilerPaths) { + // we only check the arm gdbs, that's indicative enough + if (ati.architecture != ProjectExplorer::Abi::ArmArchitecture) + continue; + Utils::FileName gdbPath = AndroidConfigurations::currentConfig().gdbPath(ati.architecture, ati.version); + if (gdbPath.toFileInfo().exists()) { + m_ui->gdbWarningIconLabel->setVisible(false); + m_ui->gdbWarningLabel->setVisible(false); + m_checkGdbWatcher.setFuture(QtConcurrent::run(&checkGdbForBrokenPython, gdbPath.toString())); + m_gdbCheckPath = gdbPath.toString(); + break; + } + } + } + // See if we have qt versions for those toolchains QSet toolchainsForArch; @@ -508,6 +567,25 @@ void AndroidSettingsWidget::createKitToggled() m_androidConfig.setAutomaticKitCreation(m_ui->CreateKitCheckBox->isChecked()); } +void AndroidSettingsWidget::checkGdbFinished() +{ + QPair result = m_checkGdbWatcher.future().result(); + if (result.first != m_gdbCheckPath) // no longer relevant + return; + m_ui->gdbWarningIconLabel->setVisible(result.second); + m_ui->gdbWarningLabel->setVisible(result.second); +} + +void AndroidSettingsWidget::showGdbWarningDialog() +{ + QMessageBox::warning(this, + tr("Unsupported GDB"), + tr("The GDB inside this NDK seems to not support Python. " + "The Qt Project offers fixed GDB builds at: " + "" + "http://download.qt-project.org/official_releases/gdb/osx/")); +} + void AndroidSettingsWidget::manageAVD() { QProcess *avdProcess = new QProcess(); diff --git a/src/plugins/android/androidsettingswidget.h b/src/plugins/android/androidsettingswidget.h index e657db3e6d..2be6b1b522 100644 --- a/src/plugins/android/androidsettingswidget.h +++ b/src/plugins/android/androidsettingswidget.h @@ -92,6 +92,9 @@ private slots: void manageAVD(); void createKitToggled(); + void checkGdbFinished(); + void showGdbWarningDialog(); + private: enum Mode { Sdk = 1, Ndk = 2, Java = 4, All = Sdk | Ndk | Java }; enum State { NotSet = 0, Okay = 1, Error = 2 }; @@ -111,6 +114,8 @@ private: AndroidConfig m_androidConfig; AvdModel m_AVDModel; QFutureWatcher m_futureWatcher; + QFutureWatcher> m_checkGdbWatcher; + QString m_gdbCheckPath; }; } // namespace Internal diff --git a/src/plugins/android/androidsettingswidget.ui b/src/plugins/android/androidsettingswidget.ui index 5b40861e16..4b4321f70a 100644 --- a/src/plugins/android/androidsettingswidget.ui +++ b/src/plugins/android/androidsettingswidget.ui @@ -6,45 +6,34 @@ 0 0 - 573 - 429 + 843 + 625 Android Configuration - - - + + + - + 0 0 - JDK location: + Android SDK location: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Download JDK - - - - :/android/images/download.png:/android/images/download.png - - + + - + @@ -58,7 +47,7 @@ - :/core/images/warning.png + :/core/images/warning.png @@ -80,37 +69,7 @@ - - - - - 0 - 0 - - - - Android SDK location: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Download Android SDK - - - - :/android/images/download.png:/android/images/download.png - - - - + @@ -146,29 +105,13 @@ - - - - - 0 - 0 - - - - Android NDK location: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - + + - - + + - Download Android NDK + Download Ant @@ -176,98 +119,7 @@ - - - - 2 - - - - - - 0 - 0 - - - - - - - :/core/images/error.png - - - - - - - - 0 - 0 - - - - - - - - - - - - - - 0 - 0 - - - - Automatically create kits for Android tool chains - - - true - - - - - - - 2 - - - - - - 0 - 0 - - - - - - - :/core/images/warning.png - - - - - - - - 0 - 0 - - - - - - - true - - - - - - + @@ -283,13 +135,21 @@ - - + + + + Download Android SDK + + + + :/android/images/download.png:/android/images/download.png + + - - + + - Download Ant + Download Android NDK @@ -297,7 +157,7 @@ - + QFrame::StyledPanel @@ -416,6 +276,182 @@ + + + + + 0 + 0 + + + + JDK location: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 2 + + + + + + 0 + 0 + + + + + + + :/core/images/error.png + + + + + + + + 0 + 0 + + + + + + + + + + + + + + 0 + 0 + + + + Android NDK location: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Download JDK + + + + :/android/images/download.png:/android/images/download.png + + + + + + + + 0 + 0 + + + + Automatically create kits for Android tool chains + + + true + + + + + + + 2 + + + + + + 0 + 0 + + + + + + + :/core/images/warning.png + + + + + + + + 0 + 0 + + + + + + + true + + + + + + + + + + + + 2 + + + + + + 0 + 0 + + + + + + + :/core/images/error.png + + + + + + + + 0 + 0 + + + + <a href="xx">The GDB in the NDK appears to have broken python support.</a> + + + + + @@ -428,6 +464,7 @@ + @@ -627,24 +664,64 @@ clicked() AndroidSettingsWidget openSDKDownloadUrl() + + + 20 + 20 + + + 20 + 20 + + downloadNDKToolButton clicked() AndroidSettingsWidget openNDKDownloadUrl() + + + 20 + 20 + + + 20 + 20 + + downloadAntToolButton clicked() AndroidSettingsWidget openAntDownloadUrl() + + + 20 + 20 + + + 20 + 20 + + downloadOpenJDKToolButton clicked() AndroidSettingsWidget openOpenJDKDownloadUrl() + + + 20 + 20 + + + 20 + 20 + + -- cgit v1.2.1