Debugger: Transform a few fields of DebuggerRunParameters

Transform projectSourceDirectory and projectSourceFiles.

Task-number: QTCREATORBUG-29168
Change-Id: I3e5f28f22df5b84f82f10e4daff10df2a62016f1
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2025-01-13 16:15:58 +01:00
parent 218139be8d
commit 0b22421da4
5 changed files with 28 additions and 25 deletions

View File

@@ -176,11 +176,11 @@ DebuggerRunParameters DebuggerRunParameters::fromRunControl(ProjectExplorer::Run
params.m_debugger.command.setExecutable(FilePath::fromString(envBinary)); params.m_debugger.command.setExecutable(FilePath::fromString(envBinary));
if (Project *project = runControl->project()) { if (Project *project = runControl->project()) {
params.projectSourceDirectory = project->projectDirectory(); params.m_projectSourceDirectory = project->projectDirectory();
params.projectSourceFiles = project->files(Project::SourceFiles); params.m_projectSourceFiles = project->files(Project::SourceFiles);
} else { } else {
params.projectSourceDirectory = params.debugger().command.executable().parentDir(); params.m_projectSourceDirectory = params.debugger().command.executable().parentDir();
params.projectSourceFiles.clear(); params.m_projectSourceFiles.clear();
} }
params.m_toolChainAbi = ToolchainKitAspect::targetAbi(kit); params.m_toolChainAbi = ToolchainKitAspect::targetAbi(kit);
@@ -322,9 +322,9 @@ void DebuggerRunParameters::setStartMode(DebuggerStartMode startMode)
projects.insert(0, startupProject); projects.insert(0, startupProject);
} }
for (Project *project : std::as_const(projects)) for (Project *project : std::as_const(projects))
projectSourceFiles.append(project->files(Project::SourceFiles)); m_projectSourceFiles.append(project->files(Project::SourceFiles));
if (!projects.isEmpty()) if (!projects.isEmpty())
projectSourceDirectory = projects.first()->projectDirectory(); m_projectSourceDirectory = projects.first()->projectDirectory();
} }
void DebuggerRunParameters::addSolibSearchDir(const QString &str) void DebuggerRunParameters::addSolibSearchDir(const QString &str)
@@ -2911,8 +2911,8 @@ QString DebuggerEngine::formatStartParameters() const
str << "Core: " << rp.coreFile().toUserOutput() << '\n'; str << "Core: " << rp.coreFile().toUserOutput() << '\n';
if (rp.attachPid().isValid()) if (rp.attachPid().isValid())
str << "PID: " << rp.attachPid().pid() << ' ' << rp.crashParameter << '\n'; str << "PID: " << rp.attachPid().pid() << ' ' << rp.crashParameter << '\n';
if (!rp.projectSourceDirectory.isEmpty()) { if (!rp.projectSourceDirectory().isEmpty()) {
str << "Project: " << rp.projectSourceDirectory.toUserOutput() << '\n'; str << "Project: " << rp.projectSourceDirectory().toUserOutput() << '\n';
str << "Additional Search Directories:"; str << "Additional Search Directories:";
for (const FilePath &dir : rp.additionalSearchDirectories()) for (const FilePath &dir : rp.additionalSearchDirectories())
str << ' ' << dir; str << ' ' << dir;

View File

@@ -194,7 +194,7 @@ public:
bool runAsRoot() const { return m_runAsRoot; } bool runAsRoot() const { return m_runAsRoot; }
Utils::ProcessRunData debugger() const { return m_debugger; }; Utils::ProcessRunData debugger() const { return m_debugger; }
void setOverrideStartScript(const Utils::FilePath &script) { m_overrideStartScript = script; } void setOverrideStartScript(const Utils::FilePath &script) { m_overrideStartScript = script; }
Utils::FilePath overrideStartScript() const { return m_overrideStartScript; } Utils::FilePath overrideStartScript() const { return m_overrideStartScript; }
@@ -212,8 +212,8 @@ public:
void setToolChainAbi(const ProjectExplorer::Abi &abi) { m_toolChainAbi = abi; } void setToolChainAbi(const ProjectExplorer::Abi &abi) { m_toolChainAbi = abi; }
ProjectExplorer::Abi toolChainAbi() const { return m_toolChainAbi; } ProjectExplorer::Abi toolChainAbi() const { return m_toolChainAbi; }
Utils::FilePath projectSourceDirectory; Utils::FilePath projectSourceDirectory() const { return m_projectSourceDirectory; }
Utils::FilePaths projectSourceFiles; Utils::FilePaths projectSourceFiles() const { return m_projectSourceFiles; }
// Terminal // Terminal
qint64 applicationPid = 0; qint64 applicationPid = 0;
@@ -317,6 +317,9 @@ private:
QStringList m_debugSourceLocation; // Gdb "directory" QStringList m_debugSourceLocation; // Gdb "directory"
Utils::FilePath m_qtSourceLocation; Utils::FilePath m_qtSourceLocation;
ProjectExplorer::Abi m_toolChainAbi; ProjectExplorer::Abi m_toolChainAbi;
Utils::FilePath m_projectSourceDirectory;
Utils::FilePaths m_projectSourceFiles;
}; };
namespace Internal { namespace Internal {

View File

@@ -542,7 +542,7 @@ void GdbEngine::handleAsyncOutput(const QStringView asyncClass, const GdbMi &res
ba.remove(pos1, pos3 - pos1 + 1); ba.remove(pos1, pos3 - pos1 + 1);
GdbMi res; GdbMi res;
res.fromString(ba); res.fromString(ba);
const FilePath &fileRoot = runParameters().projectSourceDirectory; const FilePath &fileRoot = runParameters().projectSourceDirectory();
BreakHandler *handler = breakHandler(); BreakHandler *handler = breakHandler();
Breakpoint bp; Breakpoint bp;
for (const GdbMi &bkpt : res) { for (const GdbMi &bkpt : res) {
@@ -573,7 +573,7 @@ void GdbEngine::handleAsyncOutput(const QStringView asyncClass, const GdbMi &res
const QString nr = bkpt["number"].data(); const QString nr = bkpt["number"].data();
BreakpointParameters br; BreakpointParameters br;
br.type = BreakpointByFileAndLine; br.type = BreakpointByFileAndLine;
br.updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory); br.updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory());
handler->handleAlienBreakpoint(nr, br); handler->handleAlienBreakpoint(nr, br);
} }
} else if (asyncClass == u"breakpoint-deleted") { } else if (asyncClass == u"breakpoint-deleted") {
@@ -1237,7 +1237,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
lineNumber = lineNumberG.toInt(); lineNumber = lineNumberG.toInt();
fullName = cleanupFullName(frame["fullname"].data()); fullName = cleanupFullName(frame["fullname"].data());
if (fullName.isEmpty()) if (fullName.isEmpty())
fullName = runParameters().projectSourceDirectory.withNewPath(frame["file"].data()); fullName = runParameters().projectSourceDirectory().withNewPath(frame["file"].data());
} // found line number } // found line number
} else { } else {
showMessage("INVALID STOPPED REASON", LogWarning); showMessage("INVALID STOPPED REASON", LogWarning);
@@ -1593,7 +1593,7 @@ FilePath GdbEngine::fullName(const QString &fileName)
FilePath GdbEngine::cleanupFullName(const QString &fileName) FilePath GdbEngine::cleanupFullName(const QString &fileName)
{ {
FilePath cleanFilePath = FilePath cleanFilePath =
runParameters().projectSourceDirectory.withNewPath(fileName).cleanPath(); runParameters().projectSourceDirectory().withNewPath(fileName).cleanPath();
// Gdb running on windows often delivers "fullnames" which // Gdb running on windows often delivers "fullnames" which
// (a) have no drive letter and (b) are not normalized. // (a) have no drive letter and (b) are not normalized.
@@ -2130,7 +2130,7 @@ void GdbEngine::handleInsertInterpreterBreakpoint(const DebuggerResponse &respon
notifyBreakpointInsertOk(bp); notifyBreakpointInsertOk(bp);
} else { } else {
bp->setResponseId(response.data["number"].data()); bp->setResponseId(response.data["number"].data());
bp->updateFromGdbOutput(response.data, runParameters().projectSourceDirectory); bp->updateFromGdbOutput(response.data, runParameters().projectSourceDirectory());
notifyBreakpointInsertOk(bp); notifyBreakpointInsertOk(bp);
} }
} }
@@ -2140,7 +2140,7 @@ void GdbEngine::handleInterpreterBreakpointModified(const GdbMi &data)
int modelId = data["modelid"].toInt(); int modelId = data["modelid"].toInt();
Breakpoint bp = breakHandler()->findBreakpointByModelId(modelId); Breakpoint bp = breakHandler()->findBreakpointByModelId(modelId);
QTC_ASSERT(bp, return); QTC_ASSERT(bp, return);
bp->updateFromGdbOutput(data, runParameters().projectSourceDirectory); bp->updateFromGdbOutput(data, runParameters().projectSourceDirectory());
} }
void GdbEngine::handleWatchInsert(const DebuggerResponse &response, const Breakpoint &bp) void GdbEngine::handleWatchInsert(const DebuggerResponse &response, const Breakpoint &bp)
@@ -2190,7 +2190,7 @@ void GdbEngine::handleBkpt(const GdbMi &bkpt, const Breakpoint &bp)
// A sub-breakpoint. // A sub-breakpoint.
SubBreakpoint sub = bp->findOrCreateSubBreakpoint(nr); SubBreakpoint sub = bp->findOrCreateSubBreakpoint(nr);
QTC_ASSERT(sub, return); QTC_ASSERT(sub, return);
sub->params.updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory); sub->params.updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory());
sub->params.type = bp->type(); sub->params.type = bp->type();
if (usePseudoTracepoints && bp->isTracepoint()) { if (usePseudoTracepoints && bp->isTracepoint()) {
sub->params.tracepoint = true; sub->params.tracepoint = true;
@@ -2208,7 +2208,7 @@ void GdbEngine::handleBkpt(const GdbMi &bkpt, const Breakpoint &bp)
const QString subnr = location["number"].data(); const QString subnr = location["number"].data();
SubBreakpoint sub = bp->findOrCreateSubBreakpoint(subnr); SubBreakpoint sub = bp->findOrCreateSubBreakpoint(subnr);
QTC_ASSERT(sub, return); QTC_ASSERT(sub, return);
sub->params.updateFromGdbOutput(location, runParameters().projectSourceDirectory); sub->params.updateFromGdbOutput(location, runParameters().projectSourceDirectory());
sub->params.type = bp->type(); sub->params.type = bp->type();
if (usePseudoTracepoints && bp->isTracepoint()) { if (usePseudoTracepoints && bp->isTracepoint()) {
sub->params.tracepoint = true; sub->params.tracepoint = true;
@@ -2219,7 +2219,7 @@ void GdbEngine::handleBkpt(const GdbMi &bkpt, const Breakpoint &bp)
// A (the?) primary breakpoint. // A (the?) primary breakpoint.
bp->setResponseId(nr); bp->setResponseId(nr);
bp->updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory); bp->updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory());
if (usePseudoTracepoints && bp->isTracepoint()) if (usePseudoTracepoints && bp->isTracepoint())
bp->setMessage(bp->requestedParameters().message); bp->setMessage(bp->requestedParameters().message);
} }
@@ -2526,7 +2526,7 @@ void GdbEngine::handleTracepointModified(const GdbMi &data)
// A sub-breakpoint. // A sub-breakpoint.
QTC_ASSERT(bp, continue); QTC_ASSERT(bp, continue);
SubBreakpoint loc = bp->findOrCreateSubBreakpoint(nr); SubBreakpoint loc = bp->findOrCreateSubBreakpoint(nr);
loc->params.updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory); loc->params.updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory());
loc->params.type = bp->type(); loc->params.type = bp->type();
if (bp->isTracepoint()) { if (bp->isTracepoint()) {
loc->params.tracepoint = true; loc->params.tracepoint = true;
@@ -2536,7 +2536,7 @@ void GdbEngine::handleTracepointModified(const GdbMi &data)
// A primary breakpoint. // A primary breakpoint.
bp = handler->findBreakpointByResponseId(nr); bp = handler->findBreakpointByResponseId(nr);
if (bp) if (bp)
bp->updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory); bp->updateFromGdbOutput(bkpt, runParameters().projectSourceDirectory());
} }
} }
QTC_ASSERT(bp, return); QTC_ASSERT(bp, return);

View File

@@ -2449,8 +2449,8 @@ FilePath QmlEngine::toFileInProject(const QUrl &fileUrl)
{ {
// make sure file finder is properly initialized // make sure file finder is properly initialized
const DebuggerRunParameters &rp = runParameters(); const DebuggerRunParameters &rp = runParameters();
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());

View File

@@ -171,7 +171,7 @@ void StackFrame::fixQrcFrame(const DebuggerRunParameters &rp)
relativePath = relativePath.mid(1); relativePath = relativePath.mid(1);
relativeFile = relativeFile.withNewPath(relativePath); relativeFile = relativeFile.withNewPath(relativePath);
FilePath absFile = findFile(rp.projectSourceDirectory, relativeFile); FilePath absFile = findFile(rp.projectSourceDirectory(), relativeFile);
if (absFile.isEmpty()) if (absFile.isEmpty())
absFile = findFile(FilePath::fromString(QDir::currentPath()), relativeFile); absFile = findFile(FilePath::fromString(QDir::currentPath()), relativeFile);