Debugger: Remove some uses of FilePath::toFileInfo()

Change-Id: I78037741084630fc6852f5805595ec2943db64d2
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-08-20 17:18:59 +02:00
parent 94141aecb4
commit 4ceeeca715
4 changed files with 13 additions and 22 deletions

View File

@@ -143,31 +143,22 @@ void DebuggerItem::createId()
m_id = QUuid::createUuid().toString(); m_id = QUuid::createUuid().toString();
} }
static bool isUVisionExecutable(const QFileInfo &fileInfo)
{
if (!HostOsInfo::isWindowsHost())
return false;
const QString baseName = fileInfo.baseName();
return baseName == "UV4";
}
void DebuggerItem::reinitializeFromFile(const Environment &sysEnv, QString *error) void DebuggerItem::reinitializeFromFile(const Environment &sysEnv, QString *error)
{ {
// CDB only understands the single-dash -version, whereas GDB and LLDB are // CDB only understands the single-dash -version, whereas GDB and LLDB are
// happy with both -version and --version. So use the "working" -version // happy with both -version and --version. So use the "working" -version
// except for the experimental LLDB-MI which insists on --version. // except for the experimental LLDB-MI which insists on --version.
QString version = "-version"; QString version = "-version";
const QFileInfo fileInfo = m_command.toFileInfo(); m_lastModified = m_command.lastModified();
m_lastModified = fileInfo.lastModified(); if (m_command.baseName().toLower().contains("lldb-mi"))
if (fileInfo.baseName().toLower().contains("lldb-mi"))
version = "--version"; version = "--version";
// We don't need to start the uVision executable to // We don't need to start the uVision executable to
// determine its version. // determine its version.
if (isUVisionExecutable(fileInfo)) { if (HostOsInfo::isWindowsHost() && m_command.baseName() == "UV4") {
QString errorMessage; QString errorMessage;
m_version = winGetDLLVersion(WinDLLFileVersion, m_version = winGetDLLVersion(WinDLLFileVersion,
fileInfo.absoluteFilePath(), m_command.absoluteFilePath().path(),
&errorMessage); &errorMessage);
m_engineType = UvscEngineType; m_engineType = UvscEngineType;
m_abis.clear(); m_abis.clear();
@@ -179,7 +170,7 @@ void DebuggerItem::reinitializeFromFile(const Environment &sysEnv, QString *erro
if (HostOsInfo::isWindowsHost() && m_command.fileName().startsWith("lldb")) { if (HostOsInfo::isWindowsHost() && m_command.fileName().startsWith("lldb")) {
QString errorMessage; QString errorMessage;
m_version = winGetDLLVersion(WinDLLFileVersion, m_version = winGetDLLVersion(WinDLLFileVersion,
fileInfo.absoluteFilePath(), m_command.absoluteFilePath().path(),
&errorMessage); &errorMessage);
m_engineType = LldbEngineType; m_engineType = LldbEngineType;
m_abis = Abi::abisOfBinary(m_command); m_abis = Abi::abisOfBinary(m_command);
@@ -305,7 +296,7 @@ QIcon DebuggerItem::decoration() const
{ {
if (m_engineType == NoEngineType) if (m_engineType == NoEngineType)
return Icons::CRITICAL.icon(); return Icons::CRITICAL.icon();
if (!m_command.toFileInfo().isExecutable()) if (!m_command.isExecutableFile())
return Icons::WARNING.icon(); return Icons::WARNING.icon();
if (!m_workingDirectory.isEmpty() && !m_workingDirectory.isDir()) if (!m_workingDirectory.isEmpty() && !m_workingDirectory.isDir())
return Icons::WARNING.icon(); return Icons::WARNING.icon();

View File

@@ -938,7 +938,7 @@ void DebuggerItemManagerPrivate::readDebuggers(const FilePath &fileName, bool is
.arg(item.command().toUserOutput(), item.id().toString(), fileName.toUserOutput()); .arg(item.command().toUserOutput(), item.id().toString(), fileName.toUserOutput());
continue; continue;
} }
if (!item.command().toFileInfo().isExecutable()) { if (!item.command().isExecutableFile()) {
qWarning() << QString("DebuggerItem \"%1\" (%2) read from \"%3\" dropped since the command is not executable.") qWarning() << QString("DebuggerItem \"%1\" (%2) read from \"%3\" dropped since the command is not executable.")
.arg(item.command().toUserOutput(), item.id().toString(), fileName.toUserOutput()); .arg(item.command().toUserOutput(), item.id().toString(), fileName.toUserOutput());
continue; continue;

View File

@@ -307,10 +307,10 @@ DebuggerKitAspect::ConfigurationErrors DebuggerKitAspect::configurationErrors(co
return NoDebugger; return NoDebugger;
ConfigurationErrors result = NoConfigurationError; ConfigurationErrors result = NoConfigurationError;
const QFileInfo fi = item->command().toFileInfo(); const FilePath debugger = item->command();
if (!fi.exists() || fi.isDir()) if (!debugger.exists() || debugger.isDir())
result |= DebuggerNotFound; result |= DebuggerNotFound;
else if (!fi.isExecutable()) else if (!debugger.isExecutableFile())
result |= DebuggerNotExecutable; result |= DebuggerNotExecutable;
const Abi tcAbi = ToolChainKitAspect::targetAbi(k); const Abi tcAbi = ToolChainKitAspect::targetAbi(k);
@@ -321,13 +321,13 @@ DebuggerKitAspect::ConfigurationErrors DebuggerKitAspect::configurationErrors(co
result |= DebuggerDoesNotMatch; result |= DebuggerDoesNotMatch;
} }
if (!fi.exists() || fi.isDir()) { if (!debugger.exists() || debugger.isDir()) {
if (item->engineType() == NoEngineType) if (item->engineType() == NoEngineType)
return NoDebugger; return NoDebugger;
// We need an absolute path to be able to locate Python on Windows. // We need an absolute path to be able to locate Python on Windows.
if (item->engineType() == GdbEngineType) { if (item->engineType() == GdbEngineType) {
if (tcAbi.os() == Abi::WindowsOS && !fi.isAbsolute()) if (tcAbi.os() == Abi::WindowsOS && !debugger.isAbsolutePath())
result |= DebuggerNeedsAbsolutePath; result |= DebuggerNeedsAbsolutePath;
} }
} }

View File

@@ -68,7 +68,7 @@ constexpr int kRootStackFrameLevel = 1;
static void allowRootLocals(const FilePath &projectFile) static void allowRootLocals(const FilePath &projectFile)
{ {
const QFileInfo fi(projectFile.toFileInfo()); const QFileInfo fi(projectFile.toFileInfo());
if (!fi.exists()) if (!projectFile.exists())
return; return;
const QString baseName = fi.baseName(); const QString baseName = fi.baseName();
const QDir dir(fi.dir()); const QDir dir(fi.dir());