diff --git a/src/plugins/android/androiddebugsupport.cpp b/src/plugins/android/androiddebugsupport.cpp index 195a3e91104..85da99d563d 100644 --- a/src/plugins/android/androiddebugsupport.cpp +++ b/src/plugins/android/androiddebugsupport.cpp @@ -18,6 +18,7 @@ #include +#include #include #include @@ -35,47 +36,45 @@ using namespace Utils; namespace Android { namespace Internal { -static QStringList uniquePaths(const QStringList &files) -{ - QSet paths; - for (const QString &file : files) - paths << QFileInfo(file).absolutePath(); - return Utils::toList(paths); -} - -static QStringList getSoLibSearchPath(const ProjectNode *node) +static FilePaths getSoLibSearchPath(const ProjectNode *node) { if (!node) return {}; - QStringList res; + FilePaths res; node->forEachProjectNode([&res](const ProjectNode *node) { - res.append(node->data(Constants::AndroidSoLibPath).toStringList()); + const QStringList paths = node->data(Constants::AndroidSoLibPath).toStringList(); + res.append(Utils::transform(paths, &FilePath::fromUserInput)); }); - const QString jsonFile = AndroidQtVersion::androidDeploymentSettings( - node->getProject()->activeTarget()).toString(); - QFile deploymentSettings(jsonFile); - if (deploymentSettings.open(QIODevice::ReadOnly)) { + const FilePath jsonFile = AndroidQtVersion::androidDeploymentSettings( + node->getProject()->activeTarget()); + FileReader reader; + if (reader.fetch(jsonFile)) { QJsonParseError error; - QJsonDocument doc = QJsonDocument::fromJson(deploymentSettings.readAll(), &error); + QJsonDocument doc = QJsonDocument::fromJson(reader.data(), &error); if (error.error == QJsonParseError::NoError) { auto rootObj = doc.object(); auto it = rootObj.find("stdcpp-path"); if (it != rootObj.constEnd()) - res.append(QFileInfo(it.value().toString()).absolutePath()); + res.append(FilePath::fromUserInput(it.value().toString())); } } - res.removeDuplicates(); + FilePath::removeDuplicates(res); return res; } -static QStringList getExtraLibs(const ProjectNode *node) +static FilePaths getExtraLibs(const ProjectNode *node) { if (!node) return {}; - return node->data(Android::Constants::AndroidExtraLibs).toStringList(); + + const QStringList paths = node->data(Constants::AndroidExtraLibs).toStringList(); + FilePaths res = Utils::transform(paths, &FilePath::fromUserInput); + + FilePath::removeDuplicates(res); + return res; } AndroidDebugSupport::AndroidDebugSupport(RunControl *runControl, const QString &intentName) @@ -110,23 +109,22 @@ void AndroidDebugSupport::start() if (isCppDebugging()) { qCDebug(androidDebugSupportLog) << "C++ debugging enabled"; const ProjectNode *node = target->project()->findNodeForBuildKey(runControl()->buildKey()); - QStringList solibSearchPath = getSoLibSearchPath(node); - QStringList extraLibs = getExtraLibs(node); + FilePaths solibSearchPath = getSoLibSearchPath(node); if (qtVersion) solibSearchPath.append(qtVersion->qtSoPaths()); - solibSearchPath.append(uniquePaths(extraLibs)); + const FilePaths extraLibs = getExtraLibs(node); + solibSearchPath.append(extraLibs); FilePath buildDir = AndroidManager::buildDirectory(target); const RunConfiguration *activeRunConfig = target->activeRunConfiguration(); if (activeRunConfig) - solibSearchPath.append(activeRunConfig->buildTargetInfo().workingDirectory.toString()); - solibSearchPath.append(buildDir.toString()); - const auto androidLibsPath = AndroidManager::androidBuildDirectory(target) + solibSearchPath.append(activeRunConfig->buildTargetInfo().workingDirectory); + solibSearchPath.append(buildDir); + const FilePath androidLibsPath = AndroidManager::androidBuildDirectory(target) .pathAppended("libs") - .pathAppended(AndroidManager::apkDevicePreferredAbi(target)) - .toString(); + .pathAppended(AndroidManager::apkDevicePreferredAbi(target)); solibSearchPath.append(androidLibsPath); - solibSearchPath.removeDuplicates(); + FilePath::removeDuplicates(solibSearchPath); setSolibSearchPath(solibSearchPath); qCDebug(androidDebugSupportLog).noquote() << "SoLibSearchPath: " << solibSearchPath; setSymbolFile(buildDir.pathAppended("app_process")); diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 0ed1bb3ef57..9dd9769d297 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -100,7 +100,7 @@ public: ProjectExplorer::Runnable inferior; QString displayName; // Used in the Snapshots view. Utils::ProcessHandle attachPID; - QStringList solibSearchPath; + Utils::FilePaths solibSearchPath; // Used by Qml debugging. QUrl qmlServer; diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index d72c57fe6f1..1cdc1ccc8e9 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -705,7 +705,7 @@ DebugServerPortsGatherer *DebuggerRunTool::portsGatherer() const return d->portsGatherer; } -void DebuggerRunTool::setSolibSearchPath(const QStringList &list) +void DebuggerRunTool::setSolibSearchPath(const Utils::FilePaths &list) { m_runParameters.solibSearchPath = list; } @@ -941,7 +941,7 @@ void DebuggerRunTool::addSolibSearchDir(const QString &str) { QString path = str; path.replace("%{sysroot}", m_runParameters.sysRoot.toString()); - m_runParameters.solibSearchPath.append(path); + m_runParameters.solibSearchPath.append(FilePath::fromString(path)); } DebuggerRunTool::~DebuggerRunTool() diff --git a/src/plugins/debugger/debuggerruncontrol.h b/src/plugins/debugger/debuggerruncontrol.h index da539a93207..6daca73a2c4 100644 --- a/src/plugins/debugger/debuggerruncontrol.h +++ b/src/plugins/debugger/debuggerruncontrol.h @@ -44,7 +44,7 @@ public: void setUsePortsGatherer(bool useCpp, bool useQml); DebugServerPortsGatherer *portsGatherer() const; - void setSolibSearchPath(const QStringList &list); + void setSolibSearchPath(const Utils::FilePaths &list); void addSolibSearchDir(const QString &str); static void setBreakOnMainNextTime(); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 0561ca1e211..29e0ab5e426 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -4369,7 +4369,8 @@ void GdbEngine::setupInferior() // postCommand("set architecture " + remoteArch); if (!rp.solibSearchPath.isEmpty()) { DebuggerCommand cmd("appendSolibSearchPath"); - cmd.arg("path", rp.solibSearchPath); + for (const FilePath &path : rp.solibSearchPath) + cmd.arg("path", path); cmd.arg("separator", HostOsInfo::pathListSeparator()); runCommand(cmd); } diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 20040262391..fea71088e74 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -256,8 +256,8 @@ void LldbEngine::handleLldbStarted() "settings append target.source-map " + it.key() + ' ' + expand(it.value())); } - for (const QString &path : rp.solibSearchPath) - executeDebuggerCommand("settings append target.exec-search-paths " + path); + for (const FilePath &path : rp.solibSearchPath) + executeDebuggerCommand("settings append target.exec-search-paths " + path.toString()); DebuggerCommand cmd2("setupInferior"); cmd2.arg("executable", rp.inferior.command.executable().toString()); diff --git a/src/plugins/qnx/qnxdebugsupport.cpp b/src/plugins/qnx/qnxdebugsupport.cpp index a4807a960be..7ee6cedc4fe 100644 --- a/src/plugins/qnx/qnxdebugsupport.cpp +++ b/src/plugins/qnx/qnxdebugsupport.cpp @@ -29,6 +29,7 @@ #include +#include #include #include #include @@ -122,7 +123,7 @@ QnxDebugSupport::QnxDebugSupport(RunControl *runControl) setStartMode(AttachToRemoteServer); setCloseMode(KillAtClose); setUseCtrlCStub(true); - setSolibSearchPath(searchPaths(k)); + setSolibSearchPath(FileUtils::toFilePathList(searchPaths(k))); if (auto qtVersion = dynamic_cast(QtSupport::QtKitAspect::qtVersion(k))) { setSysRoot(qtVersion->qnxTarget()); modifyDebuggerEnvironment(qtVersion->environment()); @@ -233,7 +234,7 @@ void QnxAttachDebugSupport::showProcessesDialog() debugger->setAttachPid(pid); // setRunControlName(Tr::tr("Remote: \"%1\" - Process %2").arg(remoteChannel).arg(m_process.pid)); debugger->setRunControlName(Tr::tr("Remote QNX process %1").arg(pid)); - debugger->setSolibSearchPath(searchPaths(kit)); + debugger->setSolibSearchPath(FileUtils::toFilePathList(searchPaths(kit))); if (auto qtVersion = dynamic_cast(QtSupport::QtKitAspect::qtVersion(kit))) debugger->setSysRoot(qtVersion->qnxTarget()); debugger->setUseContinueInsteadOfRun(true); diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index 6a73da8fc18..93ac024fc89 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -1356,21 +1356,20 @@ FilePath QtVersion::examplesPath() const // QT_INSTALL_EXAMPLES return d->m_data.examplesPath; } -QStringList QtVersion::qtSoPaths() const +FilePaths QtVersion::qtSoPaths() const { + FilePaths paths; const FilePaths qtPaths = {libraryPath(), pluginPath(), qmlPath(), importsPath()}; - QSet paths; - for (const FilePath &p : qtPaths) { - QString path = p.toString(); - if (path.isEmpty()) + for (const FilePath &qtPath : qtPaths) { + if (qtPath.isEmpty()) continue; - QDirIterator it(path, QStringList("*.so"), QDir::Files, QDirIterator::Subdirectories); - while (it.hasNext()) { - it.next(); - paths.insert(it.fileInfo().absolutePath()); - } + + const FilePaths soPaths = + qtPath.dirEntries({{"*.so"}, QDir::Files, QDirIterator::Subdirectories}); + paths.append(soPaths); } - return Utils::toList(paths); + FilePath::removeDuplicates(paths); + return paths; } MacroExpander *QtVersion::macroExpander() const diff --git a/src/plugins/qtsupport/baseqtversion.h b/src/plugins/qtsupport/baseqtversion.h index 03c34885468..670618a49d4 100644 --- a/src/plugins/qtsupport/baseqtversion.h +++ b/src/plugins/qtsupport/baseqtversion.h @@ -99,7 +99,7 @@ public: QString qtVersionString() const; QVersionNumber qtVersion() const; - QStringList qtSoPaths() const; + Utils::FilePaths qtSoPaths() const; bool hasExamples() const; bool hasDocs() const;