Debugger: Simplify some path uses in GdbEngine

Change-Id: I5094fb5e71c664e6f6fc69648733c9307c3bc115
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2021-08-11 08:36:15 +02:00
parent 584217a52f
commit adf1243ed9
3 changed files with 8 additions and 7 deletions

View File

@@ -3979,8 +3979,8 @@ void GdbEngine::setupEngine()
//if (terminal()->isUsable()) //if (terminal()->isUsable())
// runCommand({"set inferior-tty " + QString::fromUtf8(terminal()->slaveDevice())}); // runCommand({"set inferior-tty " + QString::fromUtf8(terminal()->slaveDevice())});
const QFileInfo gdbBinaryFile = rp.debugger.command.executable().toFileInfo(); const QString uninstalledData =
const QString uninstalledData = gdbBinaryFile.absolutePath() + "/data-directory/python"; rp.debugger.command.executable().pathAppended("data-directory/python").path();
runCommand({"python sys.path.insert(1, '" + dumperSourcePath + "')"}); runCommand({"python sys.path.insert(1, '" + dumperSourcePath + "')"});
runCommand({"python sys.path.append('" + uninstalledData + "')"}); runCommand({"python sys.path.append('" + uninstalledData + "')"});
@@ -4430,7 +4430,7 @@ void GdbEngine::setupInferior()
return; return;
} }
executable = FilePath::fromString(cinfo.foundExecutableName); executable = cinfo.foundExecutableName;
if (executable.isEmpty()) { if (executable.isEmpty()) {
AsynchronousMessageBox::warning(tr("Error Loading Symbols"), AsynchronousMessageBox::warning(tr("Error Loading Symbols"),
tr("No executable to load symbols from specified core.")); tr("No executable to load symbols from specified core."));
@@ -4469,7 +4469,7 @@ void GdbEngine::setupInferior()
runCommand({"-exec-arguments " + args}); runCommand({"-exec-arguments " + args});
} }
QString executable = runParameters().inferior.command.executable().toFileInfo().absoluteFilePath(); QString executable = runParameters().inferior.command.executable().path();
runCommand({"-file-exec-and-symbols \"" + executable + '"', runCommand({"-file-exec-and-symbols \"" + executable + '"',
CB(handleFileExecAndSymbols)}); CB(handleFileExecAndSymbols)});
} }
@@ -5002,7 +5002,8 @@ 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 = findExecutableFromName(cinfo.rawStringFromCore, coreFile); cinfo.foundExecutableName =
FilePath::fromString(findExecutableFromName(cinfo.rawStringFromCore, coreFile));
} }
} }
} }

View File

@@ -57,7 +57,7 @@ class MemoryAgentCookie;
struct CoreInfo struct CoreInfo
{ {
QString rawStringFromCore; QString rawStringFromCore;
QString foundExecutableName; // empty if no corresponding exec could be found Utils::FilePath foundExecutableName; // empty if no corresponding exec could be found
bool isCore = false; bool isCore = false;
static CoreInfo readExecutableNameFromCore(const ProjectExplorer::Runnable &debugger, static CoreInfo readExecutableNameFromCore(const ProjectExplorer::Runnable &debugger,

View File

@@ -378,7 +378,7 @@ void AttachCoreDialog::coreFileChanged(const QString &core)
Runnable debugger = DebuggerKitAspect::runnable(k); Runnable debugger = DebuggerKitAspect::runnable(k);
CoreInfo cinfo = CoreInfo::readExecutableNameFromCore(debugger, core); CoreInfo cinfo = CoreInfo::readExecutableNameFromCore(debugger, core);
if (!cinfo.foundExecutableName.isEmpty()) if (!cinfo.foundExecutableName.isEmpty())
d->symbolFileName->setFilePath(FilePath::fromString(cinfo.foundExecutableName)); d->symbolFileName->setFilePath(cinfo.foundExecutableName);
else if (!d->symbolFileName->isValid() && !cinfo.rawStringFromCore.isEmpty()) else if (!d->symbolFileName->isValid() && !cinfo.rawStringFromCore.isEmpty())
d->symbolFileName->setFilePath(FilePath::fromString(cinfo.rawStringFromCore)); d->symbolFileName->setFilePath(FilePath::fromString(cinfo.rawStringFromCore));
} }