diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 6f9f07ea47a..521ee2394dd 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -377,7 +377,7 @@ void CdbEngine::setupEngine() } break; case AttachToCore: - debugger.addArgs({"-z", sp.coreFile.path()}); + debugger.addArgs({"-z", sp.coreFile().path()}); break; default: handleSetupFailure(QString("Internal error: Unsupported start mode %1.").arg(sp.startMode())); diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index d3b707a8be2..aafd4c6e36e 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -109,7 +109,7 @@ QDebug operator<<(QDebug str, const DebuggerRunParameters &rp) { QDebug nospace = str.nospace(); nospace << "executable=" << rp.inferior().command.executable() - << " coreFile=" << rp.coreFile + << " coreFile=" << rp.coreFile() << " processArgs=" << rp.inferior().command.arguments() << " inferior environment=<" << rp.inferior().environment.toStringList().size() << " variables>" << " debugger environment=<" << rp.debugger.environment.toStringList().size() << " variables>" @@ -2912,8 +2912,8 @@ QString DebuggerEngine::formatStartParameters() const } if (!rp.debugger.command.isEmpty()) str << "Debugger: " << rp.debugger.command.toUserOutput() << '\n'; - if (!rp.coreFile.isEmpty()) - str << "Core: " << rp.coreFile.toUserOutput() << '\n'; + if (!rp.coreFile().isEmpty()) + str << "Core: " << rp.coreFile().toUserOutput() << '\n'; if (rp.attachPid().isValid()) str << "PID: " << rp.attachPid().pid() << ' ' << rp.crashParameter << '\n'; if (!rp.projectSourceDirectory.isEmpty()) { diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 17006554867..5e1e44e0bbc 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -170,8 +170,11 @@ public: void setDeviceUuid(const QString &uuid) { m_deviceUuid = uuid; } QString deviceUuid() const { return m_deviceUuid; } - // Used by general core file debugging. Public access requested in QTCREATORBUG-17158. - Utils::FilePath coreFile; + void setCoreFilePath(const Utils::FilePath &coreFile) { m_coreFile = coreFile; } + Utils::FilePath coreFile() const { return m_coreFile; } + + void setSnapshot(bool isSnapshot) { m_isSnapshot = isSnapshot; } + bool isSnapshot() const { return m_isSnapshot; } // Macro-expanded and passed to debugger startup. QString additionalStartupCommands; @@ -191,7 +194,6 @@ public: Utils::FilePath debugInfoLocation; // Gdb "set-debug-file-directory". QStringList debugSourceLocation; // Gdb "directory" Utils::FilePath qtSourceLocation; - bool isSnapshot = false; // Set if created internally. ProjectExplorer::Abi toolChainAbi; Utils::FilePath projectSourceDirectory; @@ -273,6 +275,10 @@ private: Utils::FilePath m_sysRoot; QString m_deviceUuid; // iOS 17+ + + // Used by general core file debugging. Public access requested in QTCREATORBUG-17158. + Utils::FilePath m_coreFile; + bool m_isSnapshot = false; // Set if created internally. }; namespace Internal { diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 262ffc03ee0..615bf32a9a9 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1411,7 +1411,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, } else if (startMode == AttachToCore) { rp.setStartMode(AttachToCore); rp.setCloseMode(DetachAtClose); - debugger->setCoreFilePath(coreFile); + rp.setCoreFilePath(coreFile); rp.setDisplayName(Tr::tr("Core file \"%1\"").arg(coreFile.toUserOutput())); debugger->setStartMessage(Tr::tr("Attaching to core file %1.").arg(coreFile.toUserOutput())); } else { @@ -1625,7 +1625,7 @@ void DebuggerPluginPrivate::attachToLastCore() auto debugger = new DebuggerRunTool(runControl); DebuggerRunParameters &rp = debugger->runParameters(); rp.setInferiorExecutable(lastCore.binary); - debugger->setCoreFilePath(lastCore.coreFile); + rp.setCoreFilePath(lastCore.coreFile); rp.setStartMode(AttachToCore); rp.setCloseMode(DetachAtClose); diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index 88f5450e130..bf5df1b6cb7 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -138,12 +138,6 @@ void DebuggerRunTool::setStartMessage(const QString &msg) m_runParameters.startMessage = msg; } -void DebuggerRunTool::setCoreFilePath(const FilePath &coreFile, bool isSnapshot) -{ - m_runParameters.coreFile = coreFile; - m_runParameters.isSnapshot = isSnapshot; -} - void DebuggerRunTool::addQmlServerInferiorCommandLineArgumentIfNeeded() { d->addQmlServerInferiorCommandLineArgumentIfNeeded = true; @@ -166,7 +160,7 @@ void DebuggerRunTool::start() void DebuggerRunTool::startCoreFileSetupIfNeededAndContinueStartup() { - const FilePath coreFile = m_runParameters.coreFile; + const FilePath coreFile = m_runParameters.coreFile(); if (!coreFile.endsWith(".gz") && !coreFile.endsWith(".lzo")) { continueAfterCoreFileSetup(); return; @@ -181,11 +175,11 @@ void DebuggerRunTool::startCoreFileSetupIfNeededAndContinueStartup() d->m_coreUnpackProcess.setWorkingDirectory(TemporaryDirectory::masterDirectoryFilePath()); connect(&d->m_coreUnpackProcess, &Process::done, this, [this] { if (d->m_coreUnpackProcess.error() == QProcess::UnknownError) { - m_runParameters.coreFile = d->m_tempCoreFilePath; + m_runParameters.setCoreFilePath(d->m_tempCoreFilePath); continueAfterCoreFileSetup(); return; } - reportFailure("Error unpacking " + m_runParameters.coreFile.toUserOutput()); + reportFailure("Error unpacking " + m_runParameters.coreFile().toUserOutput()); }); const QString msg = Tr::tr("Unpacking core file to %1"); @@ -441,7 +435,8 @@ void DebuggerRunTool::continueAfterDebugServerStart() rp.setStartMode(AttachToCore); rp.setCloseMode(DetachAtClose); rp.setDisplayName(name); - debugger->setCoreFilePath(FilePath::fromString(coreFile), true); + rp.setCoreFilePath(FilePath::fromString(coreFile)); + rp.setSnapshot(true); rc->start(); }); @@ -602,8 +597,8 @@ DebuggerRunTool::~DebuggerRunTool() if (d->m_tempCoreFilePath.exists()) d->m_tempCoreFilePath.removeFile(); - if (m_runParameters.isSnapshot && !m_runParameters.coreFile.isEmpty()) - m_runParameters.coreFile.removeFile(); + if (m_runParameters.isSnapshot() && !m_runParameters.coreFile().isEmpty()) + m_runParameters.coreFile().removeFile(); qDeleteAll(m_engines); m_engines.clear(); diff --git a/src/plugins/debugger/debuggerruncontrol.h b/src/plugins/debugger/debuggerruncontrol.h index 712bf99c14a..d1283bbb661 100644 --- a/src/plugins/debugger/debuggerruncontrol.h +++ b/src/plugins/debugger/debuggerruncontrol.h @@ -39,8 +39,6 @@ public: void setDebugInfoLocation(const Utils::FilePath &debugInfoLocation); - void setCoreFilePath(const Utils::FilePath &core, bool isSnapshot = false); - void setTestCase(int testCase); void setOverrideStartScript(const Utils::FilePath &script); diff --git a/src/plugins/debugger/enginemanager.cpp b/src/plugins/debugger/enginemanager.cpp index c1f043b7db2..5cb00e1a76a 100644 --- a/src/plugins/debugger/enginemanager.cpp +++ b/src/plugins/debugger/enginemanager.cpp @@ -353,7 +353,7 @@ QVariant EngineItem::data(int column, int role) const return myName; } case 1: - return (rp.coreFile.isEmpty() ? rp.inferior().command.executable() : rp.coreFile).toUserOutput(); + return (rp.coreFile().isEmpty() ? rp.inferior().command.executable() : rp.coreFile()).toUserOutput(); } return QVariant(); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index f695a748f61..dc0310703b3 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -4524,7 +4524,7 @@ void GdbEngine::setupInferior() FilePath executable = rp.inferior().command.executable(); if (executable.isEmpty()) { - CoreInfo cinfo = CoreInfo::readExecutableNameFromCore(rp.debugger, rp.coreFile); + CoreInfo cinfo = CoreInfo::readExecutableNameFromCore(rp.debugger, rp.coreFile()); if (!cinfo.isCore) { AsynchronousMessageBox::warning(Tr::tr("Error Loading Core File"), @@ -4626,7 +4626,7 @@ void GdbEngine::runEngine() } else if (isCoreEngine()) { claimInitialBreakpoints(); - runCommand({"target core " + runParameters().coreFile.path(), CB(handleTargetCore)}); + runCommand({"target core " + runParameters().coreFile().path(), CB(handleTargetCore)}); } else if (isTermEngine()) { @@ -4802,7 +4802,7 @@ void GdbEngine::handleFileExecAndSymbols(const DebuggerResponse &response) } else if (isCoreEngine()) { - const FilePath core = runParameters().coreFile; + const FilePath core = runParameters().coreFile(); if (response.resultClass == ResultDone) { showMessage(Tr::tr("Symbols found."), StatusBar); handleInferiorPrepared(); @@ -5128,7 +5128,7 @@ void GdbEngine::handleTargetCore(const DebuggerResponse &response) // Even without the stack, the user can find interesting stuff by exploring // the memory, globals etc. showStatusMessage( - Tr::tr("Attach to core \"%1\" failed:").arg(runParameters().coreFile.toUserOutput()) + Tr::tr("Attach to core \"%1\" failed:").arg(runParameters().coreFile().toUserOutput()) + '\n' + response.data["msg"].data() + '\n' + Tr::tr("Continuing nevertheless.")); } // Due to the auto-solib-add off setting, we don't have any diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 7634d824add..f85bc8ef29f 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -359,7 +359,7 @@ void LldbEngine::runEngine() showStatusMessage(Tr::tr("Running requested..."), 5000); DebuggerCommand cmd("runEngine"); if (rp.startMode() == AttachToCore) - cmd.arg("coreFile", rp.coreFile.path()); + cmd.arg("coreFile", rp.coreFile().path()); runCommand(cmd); } diff --git a/src/plugins/debugger/loadcoredialog.cpp b/src/plugins/debugger/loadcoredialog.cpp index c16037dd2cc..2d73d2f0f03 100644 --- a/src/plugins/debugger/loadcoredialog.cpp +++ b/src/plugins/debugger/loadcoredialog.cpp @@ -352,7 +352,7 @@ void runAttachToCoreDialog() auto debugger = new DebuggerRunTool(runControl); DebuggerRunParameters &rp = debugger->runParameters(); rp.setInferiorExecutable(dlg.symbolFileCopy()); - debugger->setCoreFilePath(dlg.coreFileCopy()); + rp.setCoreFilePath(dlg.coreFileCopy()); rp.setStartMode(AttachToCore); rp.setCloseMode(DetachAtClose); debugger->setOverrideStartScript(dlg.overrideStartScript());