Debugger: Transform DebuggerRunParameters::sysRoot

Task-number: QTCREATORBUG-29168
Change-Id: Ib4421ecb0a8ca26473960858f9ca257107d694a4
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2025-01-10 14:56:51 +01:00
parent b661262750
commit 14107e8d6c
13 changed files with 23 additions and 27 deletions

View File

@@ -143,7 +143,7 @@ public:
/ devicePreferredAbi; // Legacy Ndk structure / devicePreferredAbi; // Legacy Ndk structure
if (!sysRoot.exists()) if (!sysRoot.exists())
sysRoot = AndroidConfig::toolchainPathFromNdk(ndkLocation) / "sysroot"; sysRoot = AndroidConfig::toolchainPathFromNdk(ndkLocation) / "sysroot";
setSysRoot(sysRoot); rp.setSysRoot(sysRoot);
qCDebug(androidDebugSupportLog).noquote() << "Sysroot: " << sysRoot.toUserOutput(); qCDebug(androidDebugSupportLog).noquote() << "Sysroot: " << sysRoot.toUserOutput();
} }
} }

View File

@@ -422,7 +422,7 @@ void StartApplicationDialog::run(bool attachRemote)
debugger->setUseTerminal(newParameters.runInTerminal); debugger->setUseTerminal(newParameters.runInTerminal);
rp.setUseExtendedRemote(newParameters.useTargetExtendedRemote); rp.setUseExtendedRemote(newParameters.useTargetExtendedRemote);
if (!newParameters.sysRoot.isEmpty()) if (!newParameters.sysRoot.isEmpty())
debugger->setSysRoot(newParameters.sysRoot); rp.setSysRoot(newParameters.sysRoot);
bool isLocal = dev->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; bool isLocal = dev->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
if (isLocal) // FIXME: Restriction needed? if (isLocal) // FIXME: Restriction needed?

View File

@@ -136,7 +136,7 @@ DebuggerRunParameters DebuggerRunParameters::fromRunControl(ProjectExplorer::Run
if (auto runAsRootAspect = runControl->aspectData<RunAsRootAspect>()) if (auto runAsRootAspect = runControl->aspectData<RunAsRootAspect>())
params.runAsRoot = runAsRootAspect->value; params.runAsRoot = runAsRootAspect->value;
params.sysRoot = SysRootKitAspect::sysRoot(kit); params.setSysRoot(SysRootKitAspect::sysRoot(kit));
params.macroExpander = runControl->macroExpander(); params.macroExpander = runControl->macroExpander();
params.debugger = DebuggerKitAspect::runnable(kit); params.debugger = DebuggerKitAspect::runnable(kit);
params.cppEngineType = DebuggerKitAspect::engineType(kit); params.cppEngineType = DebuggerKitAspect::engineType(kit);
@@ -244,9 +244,9 @@ Result DebuggerRunParameters::fixupParameters(ProjectExplorer::RunControl *runCo
if (settings().autoEnrichParameters()) { if (settings().autoEnrichParameters()) {
if (debugInfoLocation.isEmpty()) if (debugInfoLocation.isEmpty())
debugInfoLocation = sysRoot / "/usr/lib/debug"; debugInfoLocation = m_sysRoot / "/usr/lib/debug";
if (debugSourceLocation.isEmpty()) { if (debugSourceLocation.isEmpty()) {
const QString base = sysRoot.toUrlishString() + "/usr/src/debug/"; const QString base = m_sysRoot.toUrlishString() + "/usr/src/debug/";
debugSourceLocation.append(base + "qt5base/src/corelib"); debugSourceLocation.append(base + "qt5base/src/corelib");
debugSourceLocation.append(base + "qt5base/src/gui"); debugSourceLocation.append(base + "qt5base/src/gui");
debugSourceLocation.append(base + "qt5base/src/network"); debugSourceLocation.append(base + "qt5base/src/network");
@@ -330,7 +330,7 @@ void DebuggerRunParameters::setStartMode(DebuggerStartMode startMode)
void DebuggerRunParameters::addSolibSearchDir(const QString &str) void DebuggerRunParameters::addSolibSearchDir(const QString &str)
{ {
QString path = str; QString path = str;
path.replace("%{sysroot}", sysRoot.toUrlishString()); path.replace("%{sysroot}", m_sysRoot.toUrlishString());
m_solibSearchPath.append(FilePath::fromString(path)); m_solibSearchPath.append(FilePath::fromString(path));
} }
@@ -2927,7 +2927,7 @@ QString DebuggerEngine::formatStartParameters() const
str << "Remote: " << sp.remoteChannel() << '\n'; str << "Remote: " << sp.remoteChannel() << '\n';
if (!sp.qmlServer().host().isEmpty()) if (!sp.qmlServer().host().isEmpty())
str << "QML server: " << sp.qmlServer().host() << ':' << sp.qmlServer().port() << '\n'; str << "QML server: " << sp.qmlServer().host() << ':' << sp.qmlServer().port() << '\n';
str << "Sysroot: " << sp.sysRoot << '\n'; str << "Sysroot: " << sp.sysRoot() << '\n';
str << "Debug Source Location: " << sp.debugSourceLocation.join(':') << '\n'; str << "Debug Source Location: " << sp.debugSourceLocation.join(':') << '\n';
return rc; return rc;
} }

View File

@@ -161,7 +161,9 @@ public:
void setContinueAfterAttach(bool on) { m_continueAfterAttach = on; } void setContinueAfterAttach(bool on) { m_continueAfterAttach = on; }
bool continueAfterAttach() const { return m_continueAfterAttach; } bool continueAfterAttach() const { return m_continueAfterAttach; }
Utils::FilePath sysRoot; void setSysRoot(const Utils::FilePath &sysRoot) { m_sysRoot = sysRoot; }
Utils::FilePath sysRoot() const { return m_sysRoot; }
// iOS 17+ // iOS 17+
QString deviceUuid; QString deviceUuid;
@@ -265,6 +267,7 @@ private:
QString m_deviceSymbolsRoot; QString m_deviceSymbolsRoot;
bool m_continueAfterAttach = false; bool m_continueAfterAttach = false;
Utils::FilePath m_sysRoot;
}; };
namespace Internal { namespace Internal {

View File

@@ -1396,7 +1396,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
DebuggerRunParameters &rp = debugger->runParameters(); DebuggerRunParameters &rp = debugger->runParameters();
rp.setInferiorExecutable(executable); rp.setInferiorExecutable(executable);
if (!sysRoot.isEmpty()) if (!sysRoot.isEmpty())
debugger->setSysRoot(FilePath::fromUserInput(sysRoot)); rp.setSysRoot(FilePath::fromUserInput(sysRoot));
if (pid) { if (pid) {
rp.setStartMode(AttachToLocalProcess); rp.setStartMode(AttachToLocalProcess);
rp.setCloseMode(DetachAtClose); rp.setCloseMode(DetachAtClose);

View File

@@ -103,11 +103,6 @@ public:
} // namespace Internal } // namespace Internal
void DebuggerRunTool::setSysRoot(const Utils::FilePath &sysRoot)
{
m_runParameters.sysRoot = sysRoot;
}
void DebuggerRunTool::setBreakOnMain(bool on) void DebuggerRunTool::setBreakOnMain(bool on)
{ {
m_runParameters.breakOnMain = on; m_runParameters.breakOnMain = on;

View File

@@ -33,8 +33,6 @@ public:
void setStartMessage(const QString &msg); void setStartMessage(const QString &msg);
void setCrashParameter(const QString &event); void setCrashParameter(const QString &event);
void setSysRoot(const Utils::FilePath &sysRoot);
void setBreakOnMain(bool on); void setBreakOnMain(bool on);
void setUseTerminal(bool on); void setUseTerminal(bool on);
void setUseDebugServer(Utils::ProcessHandle attachPid, bool essential, bool useMulti); void setUseDebugServer(Utils::ProcessHandle attachPid, bool essential, bool useMulti);

View File

@@ -1608,7 +1608,7 @@ FilePath GdbEngine::cleanupFullName(const QString &fileName)
if (cleanFilePath.isReadableFile()) if (cleanFilePath.isReadableFile())
return cleanFilePath; return cleanFilePath;
const FilePath sysroot = runParameters().sysRoot; const FilePath sysroot = runParameters().sysRoot();
if (!sysroot.isEmpty() && fileName.startsWith('/')) { if (!sysroot.isEmpty() && fileName.startsWith('/')) {
cleanFilePath = sysroot.pathAppended(fileName.mid(1)); cleanFilePath = sysroot.pathAppended(fileName.mid(1));
if (cleanFilePath.isReadableFile()) if (cleanFilePath.isReadableFile())
@@ -3971,11 +3971,11 @@ void GdbEngine::handleGdbStarted()
showMessage("# directory does not exist: " + src, LogInput); showMessage("# directory does not exist: " + src, LogInput);
} }
if (!rp.sysRoot.isEmpty()) { if (!rp.sysRoot().isEmpty()) {
runCommand({"set sysroot " + rp.sysRoot.path()}); runCommand({"set sysroot " + rp.sysRoot().path()});
// sysroot is not enough to correctly locate the sources, so explicitly // sysroot is not enough to correctly locate the sources, so explicitly
// relocate the most likely place for the debug source // relocate the most likely place for the debug source
runCommand({"set substitute-path /usr/src " + rp.sysRoot.path() + "/usr/src"}); runCommand({"set substitute-path /usr/src " + rp.sysRoot().path() + "/usr/src"});
} }
//QByteArray ba = QFileInfo(sp.dumperLibrary).path().toLocal8Bit(); //QByteArray ba = QFileInfo(sp.dumperLibrary).path().toLocal8Bit();

View File

@@ -308,7 +308,7 @@ void LldbEngine::handleLldbStarted()
&& (rp.startMode() == AttachToRemoteProcess || rp.startMode() == AttachToLocalProcess && (rp.startMode() == AttachToRemoteProcess || rp.startMode() == AttachToLocalProcess
|| rp.startMode() == AttachToRemoteServer || rp.startMode() == AttachToIosDevice)); || rp.startMode() == AttachToRemoteServer || rp.startMode() == AttachToIosDevice));
cmd2.arg("attachpid", rp.attachPid().pid()); cmd2.arg("attachpid", rp.attachPid().pid());
cmd2.arg("sysroot", rp.deviceSymbolsRoot().isEmpty() ? rp.sysRoot.toUrlishString() cmd2.arg("sysroot", rp.deviceSymbolsRoot().isEmpty() ? rp.sysRoot().toUrlishString()
: rp.deviceSymbolsRoot()); : rp.deviceSymbolsRoot());
cmd2.arg("remotechannel", ((rp.startMode() == AttachToRemoteProcess cmd2.arg("remotechannel", ((rp.startMode() == AttachToRemoteProcess
|| rp.startMode() == AttachToRemoteServer) || rp.startMode() == AttachToRemoteServer)

View File

@@ -358,7 +358,7 @@ void runAttachToCoreDialog()
debugger->setOverrideStartScript(dlg.overrideStartScript()); debugger->setOverrideStartScript(dlg.overrideStartScript());
const FilePath sysRoot = dlg.sysRoot(); const FilePath sysRoot = dlg.sysRoot();
if (!sysRoot.isEmpty()) if (!sysRoot.isEmpty())
debugger->setSysRoot(sysRoot); rp.setSysRoot(sysRoot);
runControl->start(); runControl->start();
} }

View File

@@ -2452,7 +2452,7 @@ FilePath QmlEngine::toFileInProject(const QUrl &fileUrl)
d->fileFinder.setProjectDirectory(rp.projectSourceDirectory); d->fileFinder.setProjectDirectory(rp.projectSourceDirectory);
d->fileFinder.setProjectFiles(rp.projectSourceFiles); d->fileFinder.setProjectFiles(rp.projectSourceFiles);
d->fileFinder.setAdditionalSearchDirectories(rp.additionalSearchDirectories()); d->fileFinder.setAdditionalSearchDirectories(rp.additionalSearchDirectories());
d->fileFinder.setSysroot(rp.sysRoot); d->fileFinder.setSysroot(rp.sysRoot());
return d->fileFinder.findFile(fileUrl).constFirst(); return d->fileFinder.findFile(fileUrl).constFirst();
} }

View File

@@ -156,7 +156,7 @@ void showAttachToProcessDialog()
rp.setDisplayName(Tr::tr("Remote QNX process %1").arg(pid)); rp.setDisplayName(Tr::tr("Remote QNX process %1").arg(pid));
rp.setSolibSearchPath(FileUtils::toFilePathList(searchPaths(kit))); rp.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()); rp.setSysRoot(qtVersion->qnxTarget());
rp.setUseContinueInsteadOfRun(true); rp.setUseContinueInsteadOfRun(true);
runControl->start(); runControl->start();
@@ -209,7 +209,7 @@ public:
rp.setUseCtrlCStub(true); rp.setUseCtrlCStub(true);
rp.setSolibSearchPath(FileUtils::toFilePathList(searchPaths(k))); rp.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))) {
debugger->setSysRoot(qtVersion->qnxTarget()); rp.setSysRoot(qtVersion->qnxTarget());
debugger->modifyDebuggerEnvironment(qtVersion->environment()); debugger->modifyDebuggerEnvironment(qtVersion->environment());
} }

View File

@@ -174,9 +174,9 @@ private:
auto sysroot = SysRootKitAspect().sysRoot(runControl()->kit()); auto sysroot = SysRootKitAspect().sysRoot(runControl()->kit());
if (sysroot.isEmpty()) if (sysroot.isEmpty())
setSysRoot("/"); rp.setSysRoot("/");
else else
setSysRoot(sysroot); rp.setSysRoot(sysroot);
} }
DebuggerRunTool::start(); DebuggerRunTool::start();