forked from qt-creator/qt-creator
Docker: Auto-detect debugger binaries in docker devices
Change-Id: Iec7c2b16277ea626520372603ae769418e9efd12 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
|
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/projectexplorericons.h>
|
#include <projectexplorer/projectexplorericons.h>
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ public:
|
|||||||
QVariant registerDebugger(const DebuggerItem &item);
|
QVariant registerDebugger(const DebuggerItem &item);
|
||||||
void readDebuggers(const FilePath &fileName, bool isSystem);
|
void readDebuggers(const FilePath &fileName, bool isSystem);
|
||||||
void autoDetectCdbDebuggers();
|
void autoDetectCdbDebuggers();
|
||||||
void autoDetectGdbOrLldbDebuggers();
|
void autoDetectGdbOrLldbDebuggers(const FilePath &deviceRoot);
|
||||||
void autoDetectUvscDebuggers();
|
void autoDetectUvscDebuggers();
|
||||||
QString uniqueDisplayName(const QString &base);
|
QString uniqueDisplayName(const QString &base);
|
||||||
|
|
||||||
@@ -714,7 +715,7 @@ static Utils::FilePaths searchGdbPathsFromRegistry()
|
|||||||
return searchPaths;
|
return searchPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers()
|
void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers(const FilePath &deviceRoot)
|
||||||
{
|
{
|
||||||
const QStringList filters = {"gdb-i686-pc-mingw32", "gdb-i686-pc-mingw32.exe", "gdb",
|
const QStringList filters = {"gdb-i686-pc-mingw32", "gdb-i686-pc-mingw32.exe", "gdb",
|
||||||
"gdb.exe", "lldb", "lldb.exe", "lldb-[1-9]*",
|
"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;
|
FilePaths suspects;
|
||||||
|
|
||||||
if (HostOsInfo::isMacHost()) {
|
if (device->osType() == OsTypeMac) {
|
||||||
SynchronousProcess proc;
|
SynchronousProcess proc;
|
||||||
proc.setTimeoutS(2);
|
proc.setTimeoutS(2);
|
||||||
proc.setCommand({"xcrun", {"--find", "lldb"}});
|
proc.setCommand({"xcrun", {"--find", "lldb"}});
|
||||||
proc.runBlocking();
|
proc.runBlocking();
|
||||||
|
// FIXME:
|
||||||
if (proc.result() == QtcProcess::FinishedWithSuccess) {
|
if (proc.result() == QtcProcess::FinishedWithSuccess) {
|
||||||
QString lPath = proc.allOutput().trimmed();
|
QString lPath = proc.allOutput().trimmed();
|
||||||
if (!lPath.isEmpty()) {
|
if (!lPath.isEmpty()) {
|
||||||
@@ -757,17 +762,15 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePaths path = Utils::filteredUnique(
|
FilePaths paths = device->systemEnvironment().path();
|
||||||
Environment::systemEnvironment().path() + searchGdbPathsFromRegistry());
|
if (!deviceRoot.needsDevice())
|
||||||
|
paths.append(searchGdbPathsFromRegistry());
|
||||||
|
|
||||||
QDir dir;
|
paths = Utils::filteredUnique(paths);
|
||||||
dir.setNameFilters(filters);
|
|
||||||
dir.setFilter(QDir::Files | QDir::Executable);
|
for (const FilePath &path : paths) {
|
||||||
for (const FilePath &base : path) {
|
const FilePath globalPath = path.onDevice(deviceRoot);
|
||||||
dir.setPath(base.toFileInfo().absoluteFilePath());
|
suspects.append(device->directoryEntries(globalPath, filters, QDir::Files | QDir::Executable));
|
||||||
const QStringList entries = dir.entryList();
|
|
||||||
for (const QString &entry : entries)
|
|
||||||
suspects.append(FilePath::fromString(dir.absoluteFilePath(entry)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const FilePath &command : qAsConst(suspects)) {
|
for (const FilePath &command : qAsConst(suspects)) {
|
||||||
@@ -939,7 +942,7 @@ void DebuggerItemManagerPrivate::restoreDebuggers()
|
|||||||
|
|
||||||
// Auto detect current.
|
// Auto detect current.
|
||||||
autoDetectCdbDebuggers();
|
autoDetectCdbDebuggers();
|
||||||
autoDetectGdbOrLldbDebuggers();
|
autoDetectGdbOrLldbDebuggers({});
|
||||||
autoDetectUvscDebuggers();
|
autoDetectUvscDebuggers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1023,4 +1026,9 @@ void DebuggerItemManager::deregisterDebugger(const QVariant &id)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebuggerItemManager::autoDetectDebuggersForDevice(const Utils::FilePath &deviceRoot)
|
||||||
|
{
|
||||||
|
d->autoDetectGdbOrLldbDebuggers(deviceRoot);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ public:
|
|||||||
static QVariant registerDebugger(const DebuggerItem &item);
|
static QVariant registerDebugger(const DebuggerItem &item);
|
||||||
static void deregisterDebugger(const QVariant &id);
|
static void deregisterDebugger(const QVariant &id);
|
||||||
|
|
||||||
|
static void autoDetectDebuggersForDevice(const Utils::FilePath &deviceRoot);
|
||||||
|
|
||||||
static const DebuggerItem *findByCommand(const Utils::FilePath &command);
|
static const DebuggerItem *findByCommand(const Utils::FilePath &command);
|
||||||
static const DebuggerItem *findById(const QVariant &id);
|
static const DebuggerItem *findById(const QVariant &id);
|
||||||
static const DebuggerItem *findByEngineType(DebuggerEngineType engineType);
|
static const DebuggerItem *findByEngineType(DebuggerEngineType engineType);
|
||||||
|
|||||||
@@ -1731,6 +1731,11 @@ void DebuggerPlugin::getEnginesState(QByteArray *json) const
|
|||||||
*json = QJsonDocument(QJsonObject::fromVariantMap(result)).toJson();
|
*json = QJsonDocument(QJsonObject::fromVariantMap(result)).toJson();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebuggerPlugin::autoDetectDebuggersForDevice(const FilePath &deviceRoot)
|
||||||
|
{
|
||||||
|
dd->m_debuggerItemManager.autoDetectDebuggersForDevice(deviceRoot);
|
||||||
|
}
|
||||||
|
|
||||||
void DebuggerPluginPrivate::attachToQmlPort()
|
void DebuggerPluginPrivate::attachToQmlPort()
|
||||||
{
|
{
|
||||||
AttachToQmlPortDialog dlg(ICore::dialogParent());
|
AttachToQmlPortDialog dlg(ICore::dialogParent());
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
namespace ProjectExplorer { class RunControl; }
|
namespace ProjectExplorer { class RunControl; }
|
||||||
|
namespace Utils { class FilePath; }
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -57,6 +58,9 @@ private:
|
|||||||
// Called from GammaRayIntegration
|
// Called from GammaRayIntegration
|
||||||
Q_SLOT void getEnginesState(QByteArray *json) const;
|
Q_SLOT void getEnginesState(QByteArray *json) const;
|
||||||
|
|
||||||
|
// Called from DockerDevice
|
||||||
|
Q_SLOT void autoDetectDebuggersForDevice(const Utils::FilePath &deviceRoot);
|
||||||
|
|
||||||
QVector<QObject *> createTestObjects() const override;
|
QVector<QObject *> createTestObjects() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -260,6 +260,7 @@ public:
|
|||||||
QList<BaseQtVersion *> autoDetectQtVersions(QTextBrowser *log) const;
|
QList<BaseQtVersion *> autoDetectQtVersions(QTextBrowser *log) const;
|
||||||
QList<ToolChain *> autoDetectToolChains(QTextBrowser *log);
|
QList<ToolChain *> autoDetectToolChains(QTextBrowser *log);
|
||||||
void autoDetectCMake(QTextBrowser *log);
|
void autoDetectCMake(QTextBrowser *log);
|
||||||
|
void autoDetectDebugger(QTextBrowser *log);
|
||||||
|
|
||||||
void fetchSystemEnviroment();
|
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)
|
void DockerDevicePrivate::autoDetect(QTextBrowser *log)
|
||||||
{
|
{
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
@@ -511,6 +527,7 @@ void DockerDevicePrivate::autoDetect(QTextBrowser *log)
|
|||||||
QList<BaseQtVersion *> qtVersions = autoDetectQtVersions(log);
|
QList<BaseQtVersion *> qtVersions = autoDetectQtVersions(log);
|
||||||
|
|
||||||
autoDetectCMake(log);
|
autoDetectCMake(log);
|
||||||
|
autoDetectDebugger(log);
|
||||||
|
|
||||||
const auto initializeKit = [this, toolChains, qtVersions](Kit *k) {
|
const auto initializeKit = [this, toolChains, qtVersions](Kit *k) {
|
||||||
k->setAutoDetected(false);
|
k->setAutoDetected(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user