summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2021-06-21 10:27:02 +0200
committerhjk <hjk@qt.io>2021-06-21 12:14:29 +0000
commitaca55dce58baf4124f6a66a47b2deaf0ef47c9d0 (patch)
tree1b15f2153d05d060d729294dae20c5874f4bea8c
parentf558323bacbb0de16d0fec4ee2d1ea717d518b79 (diff)
downloadqt-creator-aca55dce58baf4124f6a66a47b2deaf0ef47c9d0.tar.gz
Docker: Auto-detect debugger binaries in docker devices
Change-Id: Iec7c2b16277ea626520372603ae769418e9efd12 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--src/plugins/debugger/debuggeritemmanager.cpp38
-rw-r--r--src/plugins/debugger/debuggeritemmanager.h2
-rw-r--r--src/plugins/debugger/debuggerplugin.cpp5
-rw-r--r--src/plugins/debugger/debuggerplugin.h4
-rw-r--r--src/plugins/docker/dockerdevice.cpp17
5 files changed, 51 insertions, 15 deletions
diff --git a/src/plugins/debugger/debuggeritemmanager.cpp b/src/plugins/debugger/debuggeritemmanager.cpp
index c6733020c3..d4f54e2818 100644
--- a/src/plugins/debugger/debuggeritemmanager.cpp
+++ b/src/plugins/debugger/debuggeritemmanager.cpp
@@ -32,6 +32,7 @@
#include <extensionsystem/pluginmanager.h>
+#include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorericons.h>
@@ -91,7 +92,7 @@ public:
QVariant registerDebugger(const DebuggerItem &item);
void readDebuggers(const FilePath &fileName, bool isSystem);
void autoDetectCdbDebuggers();
- void autoDetectGdbOrLldbDebuggers();
+ void autoDetectGdbOrLldbDebuggers(const FilePath &deviceRoot);
void autoDetectUvscDebuggers();
QString uniqueDisplayName(const QString &base);
@@ -714,7 +715,7 @@ static Utils::FilePaths searchGdbPathsFromRegistry()
return searchPaths;
}
-void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers()
+void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers(const FilePath &deviceRoot)
{
const QStringList filters = {"gdb-i686-pc-mingw32", "gdb-i686-pc-mingw32.exe", "gdb",
"gdb.exe", "lldb", "lldb.exe", "lldb-[1-9]*",
@@ -740,13 +741,17 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers()
}
*/
+ IDevice::ConstPtr device = DeviceManager::deviceForPath(deviceRoot);
+ QTC_ASSERT(device, return);
+
FilePaths suspects;
- if (HostOsInfo::isMacHost()) {
+ if (device->osType() == OsTypeMac) {
SynchronousProcess proc;
proc.setTimeoutS(2);
proc.setCommand({"xcrun", {"--find", "lldb"}});
proc.runBlocking();
+ // FIXME:
if (proc.result() == QtcProcess::FinishedWithSuccess) {
QString lPath = proc.allOutput().trimmed();
if (!lPath.isEmpty()) {
@@ -757,17 +762,15 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers()
}
}
- FilePaths path = Utils::filteredUnique(
- Environment::systemEnvironment().path() + searchGdbPathsFromRegistry());
-
- QDir dir;
- dir.setNameFilters(filters);
- dir.setFilter(QDir::Files | QDir::Executable);
- for (const FilePath &base : path) {
- dir.setPath(base.toFileInfo().absoluteFilePath());
- const QStringList entries = dir.entryList();
- for (const QString &entry : entries)
- suspects.append(FilePath::fromString(dir.absoluteFilePath(entry)));
+ FilePaths paths = device->systemEnvironment().path();
+ if (!deviceRoot.needsDevice())
+ paths.append(searchGdbPathsFromRegistry());
+
+ paths = Utils::filteredUnique(paths);
+
+ for (const FilePath &path : paths) {
+ const FilePath globalPath = path.onDevice(deviceRoot);
+ suspects.append(device->directoryEntries(globalPath, filters, QDir::Files | QDir::Executable));
}
for (const FilePath &command : qAsConst(suspects)) {
@@ -939,7 +942,7 @@ void DebuggerItemManagerPrivate::restoreDebuggers()
// Auto detect current.
autoDetectCdbDebuggers();
- autoDetectGdbOrLldbDebuggers();
+ autoDetectGdbOrLldbDebuggers({});
autoDetectUvscDebuggers();
}
@@ -1023,4 +1026,9 @@ void DebuggerItemManager::deregisterDebugger(const QVariant &id)
});
}
+void DebuggerItemManager::autoDetectDebuggersForDevice(const Utils::FilePath &deviceRoot)
+{
+ d->autoDetectGdbOrLldbDebuggers(deviceRoot);
+}
+
} // namespace Debugger
diff --git a/src/plugins/debugger/debuggeritemmanager.h b/src/plugins/debugger/debuggeritemmanager.h
index 1b2c21e052..1278da2b67 100644
--- a/src/plugins/debugger/debuggeritemmanager.h
+++ b/src/plugins/debugger/debuggeritemmanager.h
@@ -52,6 +52,8 @@ public:
static QVariant registerDebugger(const DebuggerItem &item);
static void deregisterDebugger(const QVariant &id);
+ static void autoDetectDebuggersForDevice(const Utils::FilePath &deviceRoot);
+
static const DebuggerItem *findByCommand(const Utils::FilePath &command);
static const DebuggerItem *findById(const QVariant &id);
static const DebuggerItem *findByEngineType(DebuggerEngineType engineType);
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 309adc35e0..780051c57d 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -1731,6 +1731,11 @@ void DebuggerPlugin::getEnginesState(QByteArray *json) const
*json = QJsonDocument(QJsonObject::fromVariantMap(result)).toJson();
}
+void DebuggerPlugin::autoDetectDebuggersForDevice(const FilePath &deviceRoot)
+{
+ dd->m_debuggerItemManager.autoDetectDebuggersForDevice(deviceRoot);
+}
+
void DebuggerPluginPrivate::attachToQmlPort()
{
AttachToQmlPortDialog dlg(ICore::dialogParent());
diff --git a/src/plugins/debugger/debuggerplugin.h b/src/plugins/debugger/debuggerplugin.h
index b45f538cde..1d22225dc2 100644
--- a/src/plugins/debugger/debuggerplugin.h
+++ b/src/plugins/debugger/debuggerplugin.h
@@ -29,6 +29,7 @@
#include <extensionsystem/iplugin.h>
namespace ProjectExplorer { class RunControl; }
+namespace Utils { class FilePath; }
namespace Debugger {
namespace Internal {
@@ -57,6 +58,9 @@ private:
// Called from GammaRayIntegration
Q_SLOT void getEnginesState(QByteArray *json) const;
+ // Called from DockerDevice
+ Q_SLOT void autoDetectDebuggersForDevice(const Utils::FilePath &deviceRoot);
+
QVector<QObject *> createTestObjects() const override;
};
diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp
index 8074b88132..233204314e 100644
--- a/src/plugins/docker/dockerdevice.cpp
+++ b/src/plugins/docker/dockerdevice.cpp
@@ -260,6 +260,7 @@ public:
QList<BaseQtVersion *> autoDetectQtVersions(QTextBrowser *log) const;
QList<ToolChain *> autoDetectToolChains(QTextBrowser *log);
void autoDetectCMake(QTextBrowser *log);
+ void autoDetectDebugger(QTextBrowser *log);
void fetchSystemEnviroment();
@@ -496,6 +497,21 @@ void DockerDevicePrivate::autoDetectCMake(QTextBrowser *log)
}
}
+void DockerDevicePrivate::autoDetectDebugger(QTextBrowser *log)
+{
+ QObject *debuggerPlugin = ExtensionSystem::PluginManager::getObjectByName("DebuggerPlugin");
+ if (!debuggerPlugin)
+ return;
+
+ if (log)
+ log->append('\n' + tr("Searching debuggers..."));
+ const FilePath deviceRoot = q->mapToGlobalPath({});
+ const bool res = QMetaObject::invokeMethod(debuggerPlugin,
+ "autoDetectDebuggersForDevice",
+ Q_ARG(Utils::FilePath, deviceRoot));
+ QTC_CHECK(res);
+}
+
void DockerDevicePrivate::autoDetect(QTextBrowser *log)
{
QApplication::setOverrideCursor(Qt::WaitCursor);
@@ -511,6 +527,7 @@ void DockerDevicePrivate::autoDetect(QTextBrowser *log)
QList<BaseQtVersion *> qtVersions = autoDetectQtVersions(log);
autoDetectCMake(log);
+ autoDetectDebugger(log);
const auto initializeKit = [this, toolChains, qtVersions](Kit *k) {
k->setAutoDetected(false);