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 <qtsupport/qtkitinformation.h>
|
||||||
|
|
||||||
|
#include <utils/fileutils.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
@@ -35,47 +36,45 @@ using namespace Utils;
|
|||||||
namespace Android {
|
namespace Android {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static QStringList uniquePaths(const QStringList &files)
|
static FilePaths getSoLibSearchPath(const ProjectNode *node)
|
||||||
{
|
|
||||||
QSet<QString> paths;
|
|
||||||
for (const QString &file : files)
|
|
||||||
paths << QFileInfo(file).absolutePath();
|
|
||||||
return Utils::toList(paths);
|
|
||||||
}
|
|
||||||
|
|
||||||
static QStringList getSoLibSearchPath(const ProjectNode *node)
|
|
||||||
{
|
{
|
||||||
if (!node)
|
if (!node)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
QStringList res;
|
FilePaths res;
|
||||||
node->forEachProjectNode([&res](const ProjectNode *node) {
|
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(
|
const FilePath jsonFile = AndroidQtVersion::androidDeploymentSettings(
|
||||||
node->getProject()->activeTarget()).toString();
|
node->getProject()->activeTarget());
|
||||||
QFile deploymentSettings(jsonFile);
|
FileReader reader;
|
||||||
if (deploymentSettings.open(QIODevice::ReadOnly)) {
|
if (reader.fetch(jsonFile)) {
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(deploymentSettings.readAll(), &error);
|
QJsonDocument doc = QJsonDocument::fromJson(reader.data(), &error);
|
||||||
if (error.error == QJsonParseError::NoError) {
|
if (error.error == QJsonParseError::NoError) {
|
||||||
auto rootObj = doc.object();
|
auto rootObj = doc.object();
|
||||||
auto it = rootObj.find("stdcpp-path");
|
auto it = rootObj.find("stdcpp-path");
|
||||||
if (it != rootObj.constEnd())
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QStringList getExtraLibs(const ProjectNode *node)
|
static FilePaths getExtraLibs(const ProjectNode *node)
|
||||||
{
|
{
|
||||||
if (!node)
|
if (!node)
|
||||||
return {};
|
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)
|
AndroidDebugSupport::AndroidDebugSupport(RunControl *runControl, const QString &intentName)
|
||||||
@@ -110,23 +109,22 @@ void AndroidDebugSupport::start()
|
|||||||
if (isCppDebugging()) {
|
if (isCppDebugging()) {
|
||||||
qCDebug(androidDebugSupportLog) << "C++ debugging enabled";
|
qCDebug(androidDebugSupportLog) << "C++ debugging enabled";
|
||||||
const ProjectNode *node = target->project()->findNodeForBuildKey(runControl()->buildKey());
|
const ProjectNode *node = target->project()->findNodeForBuildKey(runControl()->buildKey());
|
||||||
QStringList solibSearchPath = getSoLibSearchPath(node);
|
FilePaths solibSearchPath = getSoLibSearchPath(node);
|
||||||
QStringList extraLibs = getExtraLibs(node);
|
|
||||||
if (qtVersion)
|
if (qtVersion)
|
||||||
solibSearchPath.append(qtVersion->qtSoPaths());
|
solibSearchPath.append(qtVersion->qtSoPaths());
|
||||||
solibSearchPath.append(uniquePaths(extraLibs));
|
const FilePaths extraLibs = getExtraLibs(node);
|
||||||
|
solibSearchPath.append(extraLibs);
|
||||||
|
|
||||||
FilePath buildDir = AndroidManager::buildDirectory(target);
|
FilePath buildDir = AndroidManager::buildDirectory(target);
|
||||||
const RunConfiguration *activeRunConfig = target->activeRunConfiguration();
|
const RunConfiguration *activeRunConfig = target->activeRunConfiguration();
|
||||||
if (activeRunConfig)
|
if (activeRunConfig)
|
||||||
solibSearchPath.append(activeRunConfig->buildTargetInfo().workingDirectory.toString());
|
solibSearchPath.append(activeRunConfig->buildTargetInfo().workingDirectory);
|
||||||
solibSearchPath.append(buildDir.toString());
|
solibSearchPath.append(buildDir);
|
||||||
const auto androidLibsPath = AndroidManager::androidBuildDirectory(target)
|
const FilePath androidLibsPath = AndroidManager::androidBuildDirectory(target)
|
||||||
.pathAppended("libs")
|
.pathAppended("libs")
|
||||||
.pathAppended(AndroidManager::apkDevicePreferredAbi(target))
|
.pathAppended(AndroidManager::apkDevicePreferredAbi(target));
|
||||||
.toString();
|
|
||||||
solibSearchPath.append(androidLibsPath);
|
solibSearchPath.append(androidLibsPath);
|
||||||
solibSearchPath.removeDuplicates();
|
FilePath::removeDuplicates(solibSearchPath);
|
||||||
setSolibSearchPath(solibSearchPath);
|
setSolibSearchPath(solibSearchPath);
|
||||||
qCDebug(androidDebugSupportLog).noquote() << "SoLibSearchPath: " << solibSearchPath;
|
qCDebug(androidDebugSupportLog).noquote() << "SoLibSearchPath: " << solibSearchPath;
|
||||||
setSymbolFile(buildDir.pathAppended("app_process"));
|
setSymbolFile(buildDir.pathAppended("app_process"));
|
||||||
|
@@ -100,7 +100,7 @@ public:
|
|||||||
ProjectExplorer::Runnable inferior;
|
ProjectExplorer::Runnable inferior;
|
||||||
QString displayName; // Used in the Snapshots view.
|
QString displayName; // Used in the Snapshots view.
|
||||||
Utils::ProcessHandle attachPID;
|
Utils::ProcessHandle attachPID;
|
||||||
QStringList solibSearchPath;
|
Utils::FilePaths solibSearchPath;
|
||||||
|
|
||||||
// Used by Qml debugging.
|
// Used by Qml debugging.
|
||||||
QUrl qmlServer;
|
QUrl qmlServer;
|
||||||
|
@@ -705,7 +705,7 @@ DebugServerPortsGatherer *DebuggerRunTool::portsGatherer() const
|
|||||||
return d->portsGatherer;
|
return d->portsGatherer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerRunTool::setSolibSearchPath(const QStringList &list)
|
void DebuggerRunTool::setSolibSearchPath(const Utils::FilePaths &list)
|
||||||
{
|
{
|
||||||
m_runParameters.solibSearchPath = list;
|
m_runParameters.solibSearchPath = list;
|
||||||
}
|
}
|
||||||
@@ -941,7 +941,7 @@ void DebuggerRunTool::addSolibSearchDir(const QString &str)
|
|||||||
{
|
{
|
||||||
QString path = str;
|
QString path = str;
|
||||||
path.replace("%{sysroot}", m_runParameters.sysRoot.toString());
|
path.replace("%{sysroot}", m_runParameters.sysRoot.toString());
|
||||||
m_runParameters.solibSearchPath.append(path);
|
m_runParameters.solibSearchPath.append(FilePath::fromString(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
DebuggerRunTool::~DebuggerRunTool()
|
DebuggerRunTool::~DebuggerRunTool()
|
||||||
|
@@ -44,7 +44,7 @@ public:
|
|||||||
void setUsePortsGatherer(bool useCpp, bool useQml);
|
void setUsePortsGatherer(bool useCpp, bool useQml);
|
||||||
DebugServerPortsGatherer *portsGatherer() const;
|
DebugServerPortsGatherer *portsGatherer() const;
|
||||||
|
|
||||||
void setSolibSearchPath(const QStringList &list);
|
void setSolibSearchPath(const Utils::FilePaths &list);
|
||||||
void addSolibSearchDir(const QString &str);
|
void addSolibSearchDir(const QString &str);
|
||||||
|
|
||||||
static void setBreakOnMainNextTime();
|
static void setBreakOnMainNextTime();
|
||||||
|
@@ -4369,7 +4369,8 @@ void GdbEngine::setupInferior()
|
|||||||
// postCommand("set architecture " + remoteArch);
|
// postCommand("set architecture " + remoteArch);
|
||||||
if (!rp.solibSearchPath.isEmpty()) {
|
if (!rp.solibSearchPath.isEmpty()) {
|
||||||
DebuggerCommand cmd("appendSolibSearchPath");
|
DebuggerCommand cmd("appendSolibSearchPath");
|
||||||
cmd.arg("path", rp.solibSearchPath);
|
for (const FilePath &path : rp.solibSearchPath)
|
||||||
|
cmd.arg("path", path);
|
||||||
cmd.arg("separator", HostOsInfo::pathListSeparator());
|
cmd.arg("separator", HostOsInfo::pathListSeparator());
|
||||||
runCommand(cmd);
|
runCommand(cmd);
|
||||||
}
|
}
|
||||||
|
@@ -256,8 +256,8 @@ void LldbEngine::handleLldbStarted()
|
|||||||
"settings append target.source-map " + it.key() + ' ' + expand(it.value()));
|
"settings append target.source-map " + it.key() + ' ' + expand(it.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const QString &path : rp.solibSearchPath)
|
for (const FilePath &path : rp.solibSearchPath)
|
||||||
executeDebuggerCommand("settings append target.exec-search-paths " + path);
|
executeDebuggerCommand("settings append target.exec-search-paths " + path.toString());
|
||||||
|
|
||||||
DebuggerCommand cmd2("setupInferior");
|
DebuggerCommand cmd2("setupInferior");
|
||||||
cmd2.arg("executable", rp.inferior.command.executable().toString());
|
cmd2.arg("executable", rp.inferior.command.executable().toString());
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
|
|
||||||
|
#include <utils/fileutils.h>
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/portlist.h>
|
#include <utils/portlist.h>
|
||||||
#include <utils/processinfo.h>
|
#include <utils/processinfo.h>
|
||||||
@@ -122,7 +123,7 @@ QnxDebugSupport::QnxDebugSupport(RunControl *runControl)
|
|||||||
setStartMode(AttachToRemoteServer);
|
setStartMode(AttachToRemoteServer);
|
||||||
setCloseMode(KillAtClose);
|
setCloseMode(KillAtClose);
|
||||||
setUseCtrlCStub(true);
|
setUseCtrlCStub(true);
|
||||||
setSolibSearchPath(searchPaths(k));
|
setSolibSearchPath(FileUtils::toFilePathList(searchPaths(k)));
|
||||||
if (auto qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitAspect::qtVersion(k))) {
|
if (auto qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitAspect::qtVersion(k))) {
|
||||||
setSysRoot(qtVersion->qnxTarget());
|
setSysRoot(qtVersion->qnxTarget());
|
||||||
modifyDebuggerEnvironment(qtVersion->environment());
|
modifyDebuggerEnvironment(qtVersion->environment());
|
||||||
@@ -233,7 +234,7 @@ void QnxAttachDebugSupport::showProcessesDialog()
|
|||||||
debugger->setAttachPid(pid);
|
debugger->setAttachPid(pid);
|
||||||
// setRunControlName(Tr::tr("Remote: \"%1\" - Process %2").arg(remoteChannel).arg(m_process.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->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)))
|
if (auto qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitAspect::qtVersion(kit)))
|
||||||
debugger->setSysRoot(qtVersion->qnxTarget());
|
debugger->setSysRoot(qtVersion->qnxTarget());
|
||||||
debugger->setUseContinueInsteadOfRun(true);
|
debugger->setUseContinueInsteadOfRun(true);
|
||||||
|
@@ -1356,21 +1356,20 @@ FilePath QtVersion::examplesPath() const // QT_INSTALL_EXAMPLES
|
|||||||
return d->m_data.examplesPath;
|
return d->m_data.examplesPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QtVersion::qtSoPaths() const
|
FilePaths QtVersion::qtSoPaths() const
|
||||||
{
|
{
|
||||||
|
FilePaths paths;
|
||||||
const FilePaths qtPaths = {libraryPath(), pluginPath(), qmlPath(), importsPath()};
|
const FilePaths qtPaths = {libraryPath(), pluginPath(), qmlPath(), importsPath()};
|
||||||
QSet<QString> paths;
|
for (const FilePath &qtPath : qtPaths) {
|
||||||
for (const FilePath &p : qtPaths) {
|
if (qtPath.isEmpty())
|
||||||
QString path = p.toString();
|
|
||||||
if (path.isEmpty())
|
|
||||||
continue;
|
continue;
|
||||||
QDirIterator it(path, QStringList("*.so"), QDir::Files, QDirIterator::Subdirectories);
|
|
||||||
while (it.hasNext()) {
|
const FilePaths soPaths =
|
||||||
it.next();
|
qtPath.dirEntries({{"*.so"}, QDir::Files, QDirIterator::Subdirectories});
|
||||||
paths.insert(it.fileInfo().absolutePath());
|
paths.append(soPaths);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return Utils::toList(paths);
|
FilePath::removeDuplicates(paths);
|
||||||
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
MacroExpander *QtVersion::macroExpander() const
|
MacroExpander *QtVersion::macroExpander() const
|
||||||
|
@@ -99,7 +99,7 @@ public:
|
|||||||
QString qtVersionString() const;
|
QString qtVersionString() const;
|
||||||
QVersionNumber qtVersion() const;
|
QVersionNumber qtVersion() const;
|
||||||
|
|
||||||
QStringList qtSoPaths() const;
|
Utils::FilePaths qtSoPaths() const;
|
||||||
|
|
||||||
bool hasExamples() const;
|
bool hasExamples() const;
|
||||||
bool hasDocs() const;
|
bool hasDocs() const;
|
||||||
|
Reference in New Issue
Block a user