forked from qt-creator/qt-creator
Debugger: FilePath-ify .so libs handling
Side-effect is the stabilization of the order in which the paths are passed to the debugger (was random, before). Change-Id: I2dba3ae6f2feef57b26eab93dee0903ee2f93dde Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
#include <QHostAddress>
|
||||
@@ -35,47 +36,45 @@ using namespace Utils;
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
static QStringList uniquePaths(const QStringList &files)
|
||||
{
|
||||
QSet<QString> 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"));
|
||||
|
@@ -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;
|
||||
|
@@ -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()
|
||||
|
@@ -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();
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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());
|
||||
|
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/portlist.h>
|
||||
#include <utils/processinfo.h>
|
||||
@@ -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<QnxQtVersion *>(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<QnxQtVersion *>(QtSupport::QtKitAspect::qtVersion(kit)))
|
||||
debugger->setSysRoot(qtVersion->qnxTarget());
|
||||
debugger->setUseContinueInsteadOfRun(true);
|
||||
|
@@ -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<QString> 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
|
||||
|
@@ -99,7 +99,7 @@ public:
|
||||
QString qtVersionString() const;
|
||||
QVersionNumber qtVersion() const;
|
||||
|
||||
QStringList qtSoPaths() const;
|
||||
Utils::FilePaths qtSoPaths() const;
|
||||
|
||||
bool hasExamples() const;
|
||||
bool hasDocs() const;
|
||||
|
Reference in New Issue
Block a user