forked from qt-creator/qt-creator
Debugger: Use FilePath for core files and surroundings
Change-Id: Icd648147ee907a2c5ba75042f003229bbd9226fe Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -419,7 +419,7 @@ void CdbEngine::setupEngine()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AttachToCore:
|
case AttachToCore:
|
||||||
debugger.addArgs({"-z", sp.coreFile});
|
debugger.addArgs({"-z", sp.coreFile.path()});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
handleSetupFailure(QString("Internal error: Unsupported start mode %1.").arg(sp.startMode));
|
handleSetupFailure(QString("Internal error: Unsupported start mode %1.").arg(sp.startMode));
|
||||||
|
@@ -2632,7 +2632,7 @@ QString DebuggerEngine::formatStartParameters() const
|
|||||||
if (!sp.debugger.command.isEmpty())
|
if (!sp.debugger.command.isEmpty())
|
||||||
str << "Debugger: " << sp.debugger.command.toUserOutput() << '\n';
|
str << "Debugger: " << sp.debugger.command.toUserOutput() << '\n';
|
||||||
if (!sp.coreFile.isEmpty())
|
if (!sp.coreFile.isEmpty())
|
||||||
str << "Core: " << QDir::toNativeSeparators(sp.coreFile) << '\n';
|
str << "Core: " << sp.coreFile.toUserOutput() << '\n';
|
||||||
if (sp.attachPID.isValid())
|
if (sp.attachPID.isValid())
|
||||||
str << "PID: " << sp.attachPID.pid() << ' ' << sp.crashParameter << '\n';
|
str << "PID: " << sp.attachPID.pid() << ' ' << sp.crashParameter << '\n';
|
||||||
if (!sp.projectSourceDirectory.isEmpty()) {
|
if (!sp.projectSourceDirectory.isEmpty()) {
|
||||||
|
@@ -158,7 +158,7 @@ public:
|
|||||||
Utils::FilePath sysRoot;
|
Utils::FilePath sysRoot;
|
||||||
|
|
||||||
// Used by general core file debugging. Public access requested in QTCREATORBUG-17158.
|
// Used by general core file debugging. Public access requested in QTCREATORBUG-17158.
|
||||||
QString coreFile;
|
Utils::FilePath coreFile;
|
||||||
|
|
||||||
// Macro-expanded and passed to debugger startup.
|
// Macro-expanded and passed to debugger startup.
|
||||||
QString additionalStartupCommands;
|
QString additionalStartupCommands;
|
||||||
@@ -172,7 +172,7 @@ public:
|
|||||||
bool runAsRoot = false;
|
bool runAsRoot = false;
|
||||||
|
|
||||||
ProjectExplorer::Runnable debugger;
|
ProjectExplorer::Runnable debugger;
|
||||||
QString overrideStartScript; // Used in attach to core and remote debugging
|
Utils::FilePath overrideStartScript; // Used in attach to core and remote debugging
|
||||||
QString startMessage; // First status message shown.
|
QString startMessage; // First status message shown.
|
||||||
Utils::FilePath debugInfoLocation; // Gdb "set-debug-file-directory".
|
Utils::FilePath debugInfoLocation; // Gdb "set-debug-file-directory".
|
||||||
QStringList debugSourceLocation; // Gdb "directory"
|
QStringList debugSourceLocation; // Gdb "directory"
|
||||||
|
@@ -1255,7 +1255,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
|
|||||||
DebuggerStartMode startMode = StartExternal;
|
DebuggerStartMode startMode = StartExternal;
|
||||||
FilePath executable;
|
FilePath executable;
|
||||||
QString remoteChannel;
|
QString remoteChannel;
|
||||||
QString coreFile;
|
FilePath coreFile;
|
||||||
QString sysRoot;
|
QString sysRoot;
|
||||||
bool useTerminal = false;
|
bool useTerminal = false;
|
||||||
|
|
||||||
@@ -1281,7 +1281,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
|
|||||||
remoteChannel = val;
|
remoteChannel = val;
|
||||||
} else if (key == "core") {
|
} else if (key == "core") {
|
||||||
startMode = AttachToCore;
|
startMode = AttachToCore;
|
||||||
coreFile = val;
|
coreFile = FilePath::fromUserInput(val);
|
||||||
} else if (key == "terminal") {
|
} else if (key == "terminal") {
|
||||||
useTerminal = true;
|
useTerminal = true;
|
||||||
} else if (key == "sysroot") {
|
} else if (key == "sysroot") {
|
||||||
@@ -1312,9 +1312,9 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
|
|||||||
} else if (startMode == AttachToCore) {
|
} else if (startMode == AttachToCore) {
|
||||||
debugger->setStartMode(AttachToCore);
|
debugger->setStartMode(AttachToCore);
|
||||||
debugger->setCloseMode(DetachAtClose);
|
debugger->setCloseMode(DetachAtClose);
|
||||||
debugger->setCoreFileName(coreFile);
|
debugger->setCoreFilePath(coreFile);
|
||||||
debugger->setRunControlName(tr("Core file \"%1\"").arg(coreFile));
|
debugger->setRunControlName(tr("Core file \"%1\"").arg(coreFile.toUserOutput()));
|
||||||
debugger->setStartMessage(tr("Attaching to core file %1.").arg(coreFile));
|
debugger->setStartMessage(tr("Attaching to core file %1.").arg(coreFile.toUserOutput()));
|
||||||
} else {
|
} else {
|
||||||
debugger->setStartMode(StartExternal);
|
debugger->setStartMode(StartExternal);
|
||||||
debugger->setRunControlName(tr("Executable file \"%1\"").arg(executable.toUserOutput()));
|
debugger->setRunControlName(tr("Executable file \"%1\"").arg(executable.toUserOutput()));
|
||||||
@@ -1521,31 +1521,32 @@ void DebuggerPluginPrivate::attachCore()
|
|||||||
const QString lastExternalKit = configValue("LastExternalKit").toString();
|
const QString lastExternalKit = configValue("LastExternalKit").toString();
|
||||||
if (!lastExternalKit.isEmpty())
|
if (!lastExternalKit.isEmpty())
|
||||||
dlg.setKitId(Id::fromString(lastExternalKit));
|
dlg.setKitId(Id::fromString(lastExternalKit));
|
||||||
dlg.setSymbolFile(configValue("LastExternalExecutableFile").toString());
|
dlg.setSymbolFile(FilePath::fromVariant(configValue("LastExternalExecutableFile")));
|
||||||
dlg.setLocalCoreFile(configValue("LastLocalCoreFile").toString());
|
dlg.setLocalCoreFile(FilePath::fromVariant(configValue("LastLocalCoreFile")));
|
||||||
dlg.setRemoteCoreFile(configValue("LastRemoteCoreFile").toString());
|
dlg.setRemoteCoreFile(FilePath::fromVariant(configValue("LastRemoteCoreFile")));
|
||||||
dlg.setOverrideStartScript(configValue("LastExternalStartScript").toString());
|
dlg.setOverrideStartScript(FilePath::fromVariant(configValue("LastExternalStartScript")));
|
||||||
dlg.setSysRoot(configValue("LastSysRoot").toString());
|
dlg.setSysRoot(FilePath::fromVariant(configValue("LastSysRoot")));
|
||||||
dlg.setForceLocalCoreFile(configValue("LastForceLocalCoreFile").toBool());
|
dlg.setForceLocalCoreFile(configValue("LastForceLocalCoreFile").toBool());
|
||||||
|
|
||||||
if (dlg.exec() != QDialog::Accepted)
|
if (dlg.exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setConfigValue("LastExternalExecutableFile", dlg.symbolFile().toVariant());
|
setConfigValue("LastExternalExecutableFile", dlg.symbolFile().toVariant());
|
||||||
setConfigValue("LastLocalCoreFile", dlg.localCoreFile());
|
setConfigValue("LastLocalCoreFile", dlg.localCoreFile().toVariant());
|
||||||
setConfigValue("LastRemoteCoreFile", dlg.remoteCoreFile());
|
setConfigValue("LastRemoteCoreFile", dlg.remoteCoreFile().toVariant());
|
||||||
setConfigValue("LastExternalKit", dlg.kit()->id().toSetting());
|
setConfigValue("LastExternalKit", dlg.kit()->id().toSetting());
|
||||||
setConfigValue("LastExternalStartScript", dlg.overrideStartScript());
|
setConfigValue("LastExternalStartScript", dlg.overrideStartScript().toVariant());
|
||||||
setConfigValue("LastSysRoot", dlg.sysRoot().toString());
|
setConfigValue("LastSysRoot", dlg.sysRoot().toVariant());
|
||||||
setConfigValue("LastForceLocalCoreFile", dlg.forcesLocalCoreFile());
|
setConfigValue("LastForceLocalCoreFile", dlg.forcesLocalCoreFile());
|
||||||
|
|
||||||
auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||||
runControl->setKit(dlg.kit());
|
runControl->setKit(dlg.kit());
|
||||||
runControl->setDisplayName(tr("Core file \"%1\"")
|
runControl->setDisplayName(tr("Core file \"%1\"")
|
||||||
.arg(dlg.useLocalCoreFile() ? dlg.localCoreFile() : dlg.remoteCoreFile()));
|
.arg(dlg.useLocalCoreFile() ? dlg.localCoreFile().toUserOutput()
|
||||||
|
: dlg.remoteCoreFile().toUserOutput()));
|
||||||
auto debugger = new DebuggerRunTool(runControl);
|
auto debugger = new DebuggerRunTool(runControl);
|
||||||
debugger->setInferiorExecutable(dlg.symbolFile());
|
debugger->setInferiorExecutable(dlg.symbolFile());
|
||||||
debugger->setCoreFileName(dlg.localCoreFile());
|
debugger->setCoreFilePath(dlg.localCoreFile());
|
||||||
debugger->setStartMode(AttachToCore);
|
debugger->setStartMode(AttachToCore);
|
||||||
debugger->setCloseMode(DetachAtClose);
|
debugger->setCloseMode(DetachAtClose);
|
||||||
debugger->setOverrideStartScript(dlg.overrideStartScript());
|
debugger->setOverrideStartScript(dlg.overrideStartScript());
|
||||||
|
@@ -108,11 +108,11 @@ static QString noDebuggerInKitMessage()
|
|||||||
class CoreUnpacker final : public RunWorker
|
class CoreUnpacker final : public RunWorker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CoreUnpacker(RunControl *runControl, const QString &coreFileName)
|
CoreUnpacker(RunControl *runControl, const FilePath &coreFilePath)
|
||||||
: RunWorker(runControl), m_coreFileName(coreFileName)
|
: RunWorker(runControl), m_coreFilePath(coreFilePath)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QString coreFileName() const { return m_tempCoreFileName; }
|
FilePath coreFileName() const { return m_tempCoreFilePath; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~CoreUnpacker() final
|
~CoreUnpacker() final
|
||||||
@@ -123,7 +123,7 @@ private:
|
|||||||
if (m_tempCoreFile.isOpen())
|
if (m_tempCoreFile.isOpen())
|
||||||
m_tempCoreFile.close();
|
m_tempCoreFile.close();
|
||||||
|
|
||||||
QFile::remove(m_tempCoreFileName);
|
m_tempCoreFilePath.removeFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void start() final
|
void start() final
|
||||||
@@ -131,40 +131,41 @@ private:
|
|||||||
{
|
{
|
||||||
Utils::TemporaryFile tmp("tmpcore-XXXXXX");
|
Utils::TemporaryFile tmp("tmpcore-XXXXXX");
|
||||||
tmp.open();
|
tmp.open();
|
||||||
m_tempCoreFileName = tmp.fileName();
|
m_tempCoreFilePath = FilePath::fromString(tmp.fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_coreUnpackProcess.setWorkingDirectory(FilePath::fromString(TemporaryDirectory::masterDirectoryPath()));
|
m_coreUnpackProcess.setWorkingDirectory(FilePath::fromString(TemporaryDirectory::masterDirectoryPath()));
|
||||||
connect(&m_coreUnpackProcess, &QtcProcess::finished, this, &CoreUnpacker::reportStarted);
|
connect(&m_coreUnpackProcess, &QtcProcess::finished, this, &CoreUnpacker::reportStarted);
|
||||||
|
|
||||||
const QString msg = DebuggerRunTool::tr("Unpacking core file to %1");
|
const QString msg = DebuggerRunTool::tr("Unpacking core file to %1");
|
||||||
appendMessage(msg.arg(m_tempCoreFileName), LogMessageFormat);
|
appendMessage(msg.arg(m_tempCoreFilePath.toUserOutput()), LogMessageFormat);
|
||||||
|
|
||||||
if (m_coreFileName.endsWith(".lzo")) {
|
if (m_coreFilePath.endsWith(".lzo")) {
|
||||||
m_coreUnpackProcess.setCommand({"lzop", {"-o", m_tempCoreFileName, "-x", m_coreFileName}});
|
m_coreUnpackProcess.setCommand({"lzop", {"-o", m_tempCoreFilePath.path(),
|
||||||
|
"-x", m_coreFilePath.path()}});
|
||||||
m_coreUnpackProcess.start();
|
m_coreUnpackProcess.start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_coreFileName.endsWith(".gz")) {
|
if (m_coreFilePath.endsWith(".gz")) {
|
||||||
appendMessage(msg.arg(m_tempCoreFileName), LogMessageFormat);
|
appendMessage(msg.arg(m_tempCoreFilePath.toUserOutput()), LogMessageFormat);
|
||||||
m_tempCoreFile.setFileName(m_tempCoreFileName);
|
m_tempCoreFile.setFileName(m_tempCoreFilePath.path());
|
||||||
m_tempCoreFile.open(QFile::WriteOnly);
|
m_tempCoreFile.open(QFile::WriteOnly);
|
||||||
connect(&m_coreUnpackProcess, &QtcProcess::readyReadStandardOutput, this, [this] {
|
connect(&m_coreUnpackProcess, &QtcProcess::readyReadStandardOutput, this, [this] {
|
||||||
m_tempCoreFile.write(m_coreUnpackProcess.readAllStandardOutput());
|
m_tempCoreFile.write(m_coreUnpackProcess.readAllStandardOutput());
|
||||||
});
|
});
|
||||||
m_coreUnpackProcess.setCommand({"gzip", {"-c", "-d", m_coreFileName}});
|
m_coreUnpackProcess.setCommand({"gzip", {"-c", "-d", m_coreFilePath.path()}});
|
||||||
m_coreUnpackProcess.start();
|
m_coreUnpackProcess.start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTC_CHECK(false);
|
QTC_CHECK(false);
|
||||||
reportFailure("Unknown file extension in " + m_coreFileName);
|
reportFailure("Unknown file extension in " + m_coreFilePath.toUserOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile m_tempCoreFile;
|
QFile m_tempCoreFile;
|
||||||
QString m_coreFileName;
|
FilePath m_coreFilePath;
|
||||||
QString m_tempCoreFileName;
|
FilePath m_tempCoreFilePath;
|
||||||
QtcProcess m_coreUnpackProcess;
|
QtcProcess m_coreUnpackProcess;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -369,7 +370,7 @@ void DebuggerRunTool::setTestCase(int testCase)
|
|||||||
m_runParameters.testCase = testCase;
|
m_runParameters.testCase = testCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerRunTool::setOverrideStartScript(const QString &script)
|
void DebuggerRunTool::setOverrideStartScript(const FilePath &script)
|
||||||
{
|
{
|
||||||
m_runParameters.overrideStartScript = script;
|
m_runParameters.overrideStartScript = script;
|
||||||
}
|
}
|
||||||
@@ -409,7 +410,7 @@ void DebuggerRunTool::setStartMessage(const QString &msg)
|
|||||||
m_runParameters.startMessage = msg;
|
m_runParameters.startMessage = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerRunTool::setCoreFileName(const QString &coreFile, bool isSnapshot)
|
void DebuggerRunTool::setCoreFilePath(const FilePath &coreFile, bool isSnapshot)
|
||||||
{
|
{
|
||||||
if (coreFile.endsWith(".gz") || coreFile.endsWith(".lzo")) {
|
if (coreFile.endsWith(".gz") || coreFile.endsWith(".lzo")) {
|
||||||
d->coreUnpacker = new CoreUnpacker(runControl(), coreFile);
|
d->coreUnpacker = new CoreUnpacker(runControl(), coreFile);
|
||||||
@@ -588,7 +589,7 @@ void DebuggerRunTool::start()
|
|||||||
auto debugger = new DebuggerRunTool(rc);
|
auto debugger = new DebuggerRunTool(rc);
|
||||||
debugger->setStartMode(AttachToCore);
|
debugger->setStartMode(AttachToCore);
|
||||||
debugger->setRunControlName(name);
|
debugger->setRunControlName(name);
|
||||||
debugger->setCoreFileName(coreFile, true);
|
debugger->setCoreFilePath(FilePath::fromString(coreFile), true);
|
||||||
debugger->startRunControl();
|
debugger->startRunControl();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -962,7 +963,7 @@ void DebuggerRunTool::addSolibSearchDir(const QString &str)
|
|||||||
DebuggerRunTool::~DebuggerRunTool()
|
DebuggerRunTool::~DebuggerRunTool()
|
||||||
{
|
{
|
||||||
if (m_runParameters.isSnapshot && !m_runParameters.coreFile.isEmpty())
|
if (m_runParameters.isSnapshot && !m_runParameters.coreFile.isEmpty())
|
||||||
QFile::remove(m_runParameters.coreFile);
|
m_runParameters.coreFile.removeFile();
|
||||||
|
|
||||||
delete m_engine2;
|
delete m_engine2;
|
||||||
m_engine2 = nullptr;
|
m_engine2 = nullptr;
|
||||||
|
@@ -119,13 +119,13 @@ public:
|
|||||||
void setQmlServer(const QUrl &qmlServer);
|
void setQmlServer(const QUrl &qmlServer);
|
||||||
QUrl qmlServer() const; // Used in GammaRay integration.
|
QUrl qmlServer() const; // Used in GammaRay integration.
|
||||||
|
|
||||||
void setCoreFileName(const QString &core, bool isSnapshot = false);
|
void setCoreFilePath(const Utils::FilePath &core, bool isSnapshot = false);
|
||||||
|
|
||||||
void setIosPlatform(const QString &platform);
|
void setIosPlatform(const QString &platform);
|
||||||
void setDeviceSymbolsRoot(const QString &deviceSymbolsRoot);
|
void setDeviceSymbolsRoot(const QString &deviceSymbolsRoot);
|
||||||
|
|
||||||
void setTestCase(int testCase);
|
void setTestCase(int testCase);
|
||||||
void setOverrideStartScript(const QString &script);
|
void setOverrideStartScript(const Utils::FilePath &script);
|
||||||
|
|
||||||
void setAbi(const ProjectExplorer::Abi &abi);
|
void setAbi(const ProjectExplorer::Abi &abi);
|
||||||
|
|
||||||
|
@@ -245,7 +245,7 @@ QVariant EngineItem::data(int column, int role) const
|
|||||||
return myName;
|
return myName;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
return rp.coreFile.isEmpty() ? rp.inferior.command.executable().toUserOutput() : rp.coreFile;
|
return (rp.coreFile.isEmpty() ? rp.inferior.command.executable() : rp.coreFile).toUserOutput();
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
|
@@ -4018,17 +4018,17 @@ void GdbEngine::handleGdbStartFailed()
|
|||||||
|
|
||||||
void GdbEngine::loadInitScript()
|
void GdbEngine::loadInitScript()
|
||||||
{
|
{
|
||||||
const QString script = runParameters().overrideStartScript;
|
const FilePath script = runParameters().overrideStartScript;
|
||||||
if (!script.isEmpty()) {
|
if (!script.isEmpty()) {
|
||||||
if (QFileInfo(script).isReadable()) {
|
if (script.isReadableFile()) {
|
||||||
runCommand({"source " + script});
|
runCommand({"source " + script.path()});
|
||||||
} else {
|
} else {
|
||||||
AsynchronousMessageBox::warning(
|
AsynchronousMessageBox::warning(
|
||||||
tr("Cannot Find Debugger Initialization Script"),
|
tr("Cannot Find Debugger Initialization Script"),
|
||||||
tr("The debugger settings point to a script file at \"%1\", "
|
tr("The debugger settings point to a script file at \"%1\", "
|
||||||
"which is not accessible. If a script file is not needed, "
|
"which is not accessible. If a script file is not needed, "
|
||||||
"consider clearing that entry to avoid this warning."
|
"consider clearing that entry to avoid this warning."
|
||||||
).arg(script));
|
).arg(script.toUserOutput()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const QString commands = nativeStartupCommands().trimmed();
|
const QString commands = nativeStartupCommands().trimmed();
|
||||||
@@ -4537,7 +4537,7 @@ void GdbEngine::runEngine()
|
|||||||
} else if (isCoreEngine()) {
|
} else if (isCoreEngine()) {
|
||||||
|
|
||||||
claimInitialBreakpoints();
|
claimInitialBreakpoints();
|
||||||
runCommand({"target core " + runParameters().coreFile, CB(handleTargetCore)});
|
runCommand({"target core " + runParameters().coreFile.path(), CB(handleTargetCore)});
|
||||||
|
|
||||||
} else if (isTermEngine()) {
|
} else if (isTermEngine()) {
|
||||||
|
|
||||||
@@ -4714,12 +4714,12 @@ void GdbEngine::handleFileExecAndSymbols(const DebuggerResponse &response)
|
|||||||
|
|
||||||
} else if (isCoreEngine()) {
|
} else if (isCoreEngine()) {
|
||||||
|
|
||||||
QString core = runParameters().coreFile;
|
const FilePath core = runParameters().coreFile;
|
||||||
if (response.resultClass == ResultDone) {
|
if (response.resultClass == ResultDone) {
|
||||||
showMessage(tr("Symbols found."), StatusBar);
|
showMessage(tr("Symbols found."), StatusBar);
|
||||||
handleInferiorPrepared();
|
handleInferiorPrepared();
|
||||||
} else {
|
} else {
|
||||||
QString msg = tr("No symbols found in the core file \"%1\".").arg(core)
|
QString msg = tr("No symbols found in the core file \"%1\".").arg(core.toUserOutput())
|
||||||
+ ' ' + tr("This can be caused by a path length limitation "
|
+ ' ' + tr("This can be caused by a path length limitation "
|
||||||
"in the core file.")
|
"in the core file.")
|
||||||
+ ' ' + tr("Try to specify the binary in "
|
+ ' ' + tr("Try to specify the binary in "
|
||||||
@@ -4956,41 +4956,35 @@ void GdbEngine::handleStubAttached(const DebuggerResponse &response, qint64 main
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString findExecutableFromName(const QString &fileNameFromCore, const QString &coreFile)
|
static FilePath findExecutableFromName(const QString &fileNameFromCore, const FilePath &coreFile)
|
||||||
{
|
{
|
||||||
if (fileNameFromCore.isEmpty())
|
if (fileNameFromCore.isEmpty())
|
||||||
return fileNameFromCore;
|
return {};
|
||||||
QFileInfo fi(fileNameFromCore);
|
|
||||||
if (fi.isFile())
|
FilePath filePathFromCore = FilePath::fromUserInput(fileNameFromCore);
|
||||||
return fileNameFromCore;
|
if (filePathFromCore.isFile())
|
||||||
|
return filePathFromCore;
|
||||||
|
|
||||||
// turn the filename into an absolute path, using the location of the core as a hint
|
// turn the filename into an absolute path, using the location of the core as a hint
|
||||||
QString absPath;
|
const FilePath coreDir = coreFile.absoluteFilePath().parentDir();
|
||||||
if (fi.isAbsolute()) {
|
const FilePath absPath = coreDir.resolvePath(fileNameFromCore);
|
||||||
absPath = fileNameFromCore;
|
|
||||||
} else {
|
if (absPath.isFile() || absPath.isEmpty())
|
||||||
QFileInfo coreInfo(coreFile);
|
|
||||||
FilePath coreDir = FilePath::fromString(coreInfo.dir().absolutePath());
|
|
||||||
absPath = coreDir.resolvePath(fileNameFromCore).toString();
|
|
||||||
}
|
|
||||||
if (QFileInfo(absPath).isFile() || absPath.isEmpty())
|
|
||||||
return absPath;
|
return absPath;
|
||||||
|
|
||||||
// remove possible trailing arguments
|
// remove possible trailing arguments
|
||||||
QChar sep(' ');
|
QStringList pathFragments = absPath.path().split(' ');
|
||||||
QStringList pathFragments = absPath.split(sep);
|
|
||||||
while (pathFragments.size() > 0) {
|
while (pathFragments.size() > 0) {
|
||||||
QString joined_path = pathFragments.join(sep);
|
const FilePath joined_path = FilePath::fromString(pathFragments.join(' '));
|
||||||
if (QFileInfo(joined_path).isFile()) {
|
if (joined_path.isFile())
|
||||||
return joined_path;
|
return joined_path;
|
||||||
}
|
|
||||||
pathFragments.pop_back();
|
pathFragments.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreInfo CoreInfo::readExecutableNameFromCore(const Runnable &debugger, const QString &coreFile)
|
CoreInfo CoreInfo::readExecutableNameFromCore(const Runnable &debugger, const FilePath &coreFile)
|
||||||
{
|
{
|
||||||
CoreInfo cinfo;
|
CoreInfo cinfo;
|
||||||
#if 0
|
#if 0
|
||||||
@@ -5002,7 +4996,7 @@ CoreInfo CoreInfo::readExecutableNameFromCore(const Runnable &debugger, const QS
|
|||||||
// Multiarch GDB on Windows crashes if osabi is cygwin (the default) when opening a core dump.
|
// Multiarch GDB on Windows crashes if osabi is cygwin (the default) when opening a core dump.
|
||||||
if (HostOsInfo::isWindowsHost())
|
if (HostOsInfo::isWindowsHost())
|
||||||
args += {"-ex", "set osabi GNU/Linux"};
|
args += {"-ex", "set osabi GNU/Linux"};
|
||||||
args += {"-ex", "core " + coreFile};
|
args += {"-ex", "core " + coreFile.toUserOutput()};
|
||||||
|
|
||||||
QtcProcess proc;
|
QtcProcess proc;
|
||||||
Environment envLang(Environment::systemEnvironment());
|
Environment envLang(Environment::systemEnvironment());
|
||||||
@@ -5022,8 +5016,7 @@ CoreInfo CoreInfo::readExecutableNameFromCore(const Runnable &debugger, const QS
|
|||||||
if (pos2 != -1) {
|
if (pos2 != -1) {
|
||||||
cinfo.isCore = true;
|
cinfo.isCore = true;
|
||||||
cinfo.rawStringFromCore = output.mid(pos1, pos2 - pos1);
|
cinfo.rawStringFromCore = output.mid(pos1, pos2 - pos1);
|
||||||
cinfo.foundExecutableName =
|
cinfo.foundExecutableName = findExecutableFromName(cinfo.rawStringFromCore, coreFile);
|
||||||
FilePath::fromString(findExecutableFromName(cinfo.rawStringFromCore, coreFile));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5040,7 +5033,7 @@ void GdbEngine::handleTargetCore(const DebuggerResponse &response)
|
|||||||
// We'll accept any kind of error e.g. &"Cannot access memory at address 0x2abc2a24\n"
|
// We'll accept any kind of error e.g. &"Cannot access memory at address 0x2abc2a24\n"
|
||||||
// Even without the stack, the user can find interesting stuff by exploring
|
// Even without the stack, the user can find interesting stuff by exploring
|
||||||
// the memory, globals etc.
|
// the memory, globals etc.
|
||||||
showStatusMessage(tr("Attach to core \"%1\" failed:").arg(runParameters().coreFile)
|
showStatusMessage(tr("Attach to core \"%1\" failed:").arg(runParameters().coreFile.toUserOutput())
|
||||||
+ '\n' + response.data["msg"].data()
|
+ '\n' + response.data["msg"].data()
|
||||||
+ '\n' + tr("Continuing nevertheless."));
|
+ '\n' + tr("Continuing nevertheless."));
|
||||||
}
|
}
|
||||||
|
@@ -61,7 +61,7 @@ struct CoreInfo
|
|||||||
bool isCore = false;
|
bool isCore = false;
|
||||||
|
|
||||||
static CoreInfo readExecutableNameFromCore(const ProjectExplorer::Runnable &debugger,
|
static CoreInfo readExecutableNameFromCore(const ProjectExplorer::Runnable &debugger,
|
||||||
const QString &coreFile);
|
const Utils::FilePath &coreFile);
|
||||||
};
|
};
|
||||||
|
|
||||||
class GdbEngine final : public CppDebuggerEngine
|
class GdbEngine final : public CppDebuggerEngine
|
||||||
|
@@ -73,8 +73,8 @@ public:
|
|||||||
explicit SelectRemoteFileDialog(QWidget *parent);
|
explicit SelectRemoteFileDialog(QWidget *parent);
|
||||||
|
|
||||||
void attachToDevice(Kit *k);
|
void attachToDevice(Kit *k);
|
||||||
QString localFile() const { return m_localFile; }
|
FilePath localFile() const { return m_localFile; }
|
||||||
QString remoteFile() const { return m_remoteFile; }
|
FilePath remoteFile() const { return m_remoteFile; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleSftpOperationFinished(SftpJobId, const QString &error);
|
void handleSftpOperationFinished(SftpJobId, const QString &error);
|
||||||
@@ -88,8 +88,8 @@ private:
|
|||||||
QTreeView *m_fileSystemView;
|
QTreeView *m_fileSystemView;
|
||||||
QTextBrowser *m_textBrowser;
|
QTextBrowser *m_textBrowser;
|
||||||
QDialogButtonBox *m_buttonBox;
|
QDialogButtonBox *m_buttonBox;
|
||||||
QString m_localFile;
|
FilePath m_localFile;
|
||||||
QString m_remoteFile;
|
FilePath m_remoteFile;
|
||||||
SftpJobId m_sftpJobId;
|
SftpJobId m_sftpJobId;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -185,12 +185,12 @@ void SelectRemoteFileDialog::selectFile()
|
|||||||
{
|
{
|
||||||
Utils::TemporaryFile localFile("remotecore-XXXXXX");
|
Utils::TemporaryFile localFile("remotecore-XXXXXX");
|
||||||
localFile.open();
|
localFile.open();
|
||||||
m_localFile = localFile.fileName();
|
m_localFile = FilePath::fromString(localFile.fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
idx = idx.sibling(idx.row(), 1);
|
idx = idx.sibling(idx.row(), 1);
|
||||||
m_remoteFile = m_fileSystemModel.data(idx, SftpFileSystemModel::PathRole).toString();
|
m_remoteFile = FilePath::fromVariant(m_fileSystemModel.data(idx, SftpFileSystemModel::PathRole));
|
||||||
m_sftpJobId = m_fileSystemModel.downloadFile(idx, m_localFile);
|
m_sftpJobId = m_fileSystemModel.downloadFile(idx, m_localFile.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
@@ -372,11 +372,12 @@ bool AttachCoreDialog::useLocalCoreFile() const
|
|||||||
|
|
||||||
void AttachCoreDialog::coreFileChanged(const QString &core)
|
void AttachCoreDialog::coreFileChanged(const QString &core)
|
||||||
{
|
{
|
||||||
if (!HostOsInfo::isWindowsHost() && QFile::exists(core)) {
|
const FilePath coreFile = FilePath::fromUserInput(core);
|
||||||
|
if (coreFile.osType() != OsType::OsTypeWindows && coreFile.exists()) {
|
||||||
Kit *k = d->kitChooser->currentKit();
|
Kit *k = d->kitChooser->currentKit();
|
||||||
QTC_ASSERT(k, return);
|
QTC_ASSERT(k, return);
|
||||||
Runnable debugger = DebuggerKitAspect::runnable(k);
|
Runnable debugger = DebuggerKitAspect::runnable(k);
|
||||||
CoreInfo cinfo = CoreInfo::readExecutableNameFromCore(debugger, core);
|
CoreInfo cinfo = CoreInfo::readExecutableNameFromCore(debugger, coreFile);
|
||||||
if (!cinfo.foundExecutableName.isEmpty())
|
if (!cinfo.foundExecutableName.isEmpty())
|
||||||
d->symbolFileName->setFilePath(cinfo.foundExecutableName);
|
d->symbolFileName->setFilePath(cinfo.foundExecutableName);
|
||||||
else if (!d->symbolFileName->isValid() && !cinfo.rawStringFromCore.isEmpty())
|
else if (!d->symbolFileName->isValid() && !cinfo.rawStringFromCore.isEmpty())
|
||||||
@@ -413,14 +414,14 @@ void AttachCoreDialog::selectRemoteCoreFile()
|
|||||||
dlg.attachToDevice(d->kitChooser->currentKit());
|
dlg.attachToDevice(d->kitChooser->currentKit());
|
||||||
if (dlg.exec() == QDialog::Rejected)
|
if (dlg.exec() == QDialog::Rejected)
|
||||||
return;
|
return;
|
||||||
d->localCoreFileName->setPath(dlg.localFile());
|
d->localCoreFileName->setFilePath(dlg.localFile());
|
||||||
d->remoteCoreFileName->setText(dlg.remoteFile());
|
d->remoteCoreFileName->setText(dlg.remoteFile().toUserOutput());
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AttachCoreDialog::localCoreFile() const
|
FilePath AttachCoreDialog::localCoreFile() const
|
||||||
{
|
{
|
||||||
return d->localCoreFileName->filePath().toString();
|
return d->localCoreFileName->filePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath AttachCoreDialog::symbolFile() const
|
FilePath AttachCoreDialog::symbolFile() const
|
||||||
@@ -428,24 +429,24 @@ FilePath AttachCoreDialog::symbolFile() const
|
|||||||
return d->symbolFileName->filePath();
|
return d->symbolFileName->filePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttachCoreDialog::setSymbolFile(const QString &symbolFileName)
|
void AttachCoreDialog::setSymbolFile(const FilePath &symbolFilePath)
|
||||||
{
|
{
|
||||||
d->symbolFileName->setPath(symbolFileName);
|
d->symbolFileName->setFilePath(symbolFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttachCoreDialog::setLocalCoreFile(const QString &fileName)
|
void AttachCoreDialog::setLocalCoreFile(const FilePath &coreFilePath)
|
||||||
{
|
{
|
||||||
d->localCoreFileName->setPath(fileName);
|
d->localCoreFileName->setFilePath(coreFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttachCoreDialog::setRemoteCoreFile(const QString &fileName)
|
void AttachCoreDialog::setRemoteCoreFile(const FilePath &coreFilePath)
|
||||||
{
|
{
|
||||||
d->remoteCoreFileName->setText(fileName);
|
d->remoteCoreFileName->setText(coreFilePath.toUserOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AttachCoreDialog::remoteCoreFile() const
|
FilePath AttachCoreDialog::remoteCoreFile() const
|
||||||
{
|
{
|
||||||
return d->remoteCoreFileName->text();
|
return FilePath::fromUserInput(d->remoteCoreFileName->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttachCoreDialog::setKitId(Id id)
|
void AttachCoreDialog::setKitId(Id id)
|
||||||
@@ -468,14 +469,14 @@ Kit *AttachCoreDialog::kit() const
|
|||||||
return d->kitChooser->currentKit();
|
return d->kitChooser->currentKit();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AttachCoreDialog::overrideStartScript() const
|
FilePath AttachCoreDialog::overrideStartScript() const
|
||||||
{
|
{
|
||||||
return d->overrideStartScriptFileName->filePath().toString();
|
return d->overrideStartScriptFileName->filePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttachCoreDialog::setOverrideStartScript(const QString &scriptName)
|
void AttachCoreDialog::setOverrideStartScript(const FilePath &scriptName)
|
||||||
{
|
{
|
||||||
d->overrideStartScriptFileName->setPath(scriptName);
|
d->overrideStartScriptFileName->setFilePath(scriptName);
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath AttachCoreDialog::sysRoot() const
|
FilePath AttachCoreDialog::sysRoot() const
|
||||||
@@ -483,9 +484,9 @@ FilePath AttachCoreDialog::sysRoot() const
|
|||||||
return d->sysRootDirectory->filePath();
|
return d->sysRootDirectory->filePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttachCoreDialog::setSysRoot(const QString &sysRoot)
|
void AttachCoreDialog::setSysRoot(const FilePath &sysRoot)
|
||||||
{
|
{
|
||||||
d->sysRootDirectory->setPath(sysRoot);
|
d->sysRootDirectory->setFilePath(sysRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -48,9 +48,9 @@ public:
|
|||||||
int exec() override;
|
int exec() override;
|
||||||
|
|
||||||
Utils::FilePath symbolFile() const;
|
Utils::FilePath symbolFile() const;
|
||||||
QString localCoreFile() const;
|
Utils::FilePath localCoreFile() const;
|
||||||
QString remoteCoreFile() const;
|
Utils::FilePath remoteCoreFile() const;
|
||||||
QString overrideStartScript() const;
|
Utils::FilePath overrideStartScript() const;
|
||||||
Utils::FilePath sysRoot() const;
|
Utils::FilePath sysRoot() const;
|
||||||
bool useLocalCoreFile() const;
|
bool useLocalCoreFile() const;
|
||||||
bool forcesLocalCoreFile() const;
|
bool forcesLocalCoreFile() const;
|
||||||
@@ -58,11 +58,11 @@ public:
|
|||||||
|
|
||||||
// For persistance.
|
// For persistance.
|
||||||
ProjectExplorer::Kit *kit() const;
|
ProjectExplorer::Kit *kit() const;
|
||||||
void setSymbolFile(const QString &symbolFileName);
|
void setSymbolFile(const Utils::FilePath &symbolFilePath);
|
||||||
void setLocalCoreFile(const QString &core);
|
void setLocalCoreFile(const Utils::FilePath &coreFilePath);
|
||||||
void setRemoteCoreFile(const QString &core);
|
void setRemoteCoreFile(const Utils::FilePath &coreFilePath);
|
||||||
void setOverrideStartScript(const QString &scriptName);
|
void setOverrideStartScript(const Utils::FilePath &scriptName);
|
||||||
void setSysRoot(const QString &sysRoot);
|
void setSysRoot(const Utils::FilePath &sysRoot);
|
||||||
void setKitId(Utils::Id id);
|
void setKitId(Utils::Id id);
|
||||||
void setForceLocalCoreFile(bool on);
|
void setForceLocalCoreFile(bool on);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user