Debugger: Update debugger details when executable is replaced

Store last modified time in persistent storage, and if it is changed,
reinitialize the item.

Change-Id: I15e8c843fecd3cebd528f2dadb64645828a2b221
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2016-03-06 23:26:01 +02:00
committed by Orgad Shaneh
parent 24f34420fd
commit 383737d020
4 changed files with 22 additions and 5 deletions

View File

@@ -57,6 +57,7 @@ const char DEBUGGER_INFORMATION_AUTODETECTED[] = "AutoDetected";
const char DEBUGGER_INFORMATION_AUTODETECTION_SOURCE[] = "AutoDetectionSource";
const char DEBUGGER_INFORMATION_VERSION[] = "Version";
const char DEBUGGER_INFORMATION_ABIS[] = "Abis";
const char DEBUGGER_INFORMATION_LASTMODIFIED[] = "LastModified";
namespace Debugger {
@@ -87,6 +88,7 @@ DebuggerItem::DebuggerItem(const QVariantMap &data)
m_version = data.value(QLatin1String(DEBUGGER_INFORMATION_VERSION)).toString();
m_engineType = DebuggerEngineType(data.value(QLatin1String(DEBUGGER_INFORMATION_ENGINETYPE),
static_cast<int>(NoEngineType)).toInt());
m_lastModified = data.value(QLatin1String(DEBUGGER_INFORMATION_LASTMODIFIED)).toDateTime();
foreach (const QString &a, data.value(QLatin1String(DEBUGGER_INFORMATION_ABIS)).toStringList()) {
Abi abi(a);
@@ -110,7 +112,9 @@ void DebuggerItem::reinitializeFromFile()
// happy with both -version and --version. So use the "working" -version
// except for the experimental LLDB-MI which insists on --version.
const char *version = "-version";
if (m_command.toFileInfo().baseName().toLower().contains(QLatin1String("lldb-mi")))
const QFileInfo fileInfo = m_command.toFileInfo();
m_lastModified = fileInfo.lastModified();
if (fileInfo.baseName().toLower().contains(QLatin1String("lldb-mi")))
version = "--version";
QProcess proc;
@@ -203,6 +207,11 @@ QStringList DebuggerItem::abiNames() const
return list;
}
QDateTime DebuggerItem::lastModified() const
{
return m_lastModified;
}
bool DebuggerItem::isGood() const
{
return m_engineType != NoEngineType;
@@ -234,6 +243,7 @@ QVariantMap DebuggerItem::toMap() const
data.insert(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTION_SOURCE), m_autoDetectionSource);
data.insert(QLatin1String(DEBUGGER_INFORMATION_VERSION), m_version);
data.insert(QLatin1String(DEBUGGER_INFORMATION_ABIS), abiNames());
data.insert(QLatin1String(DEBUGGER_INFORMATION_LASTMODIFIED), m_lastModified);
return data;
}

View File

@@ -33,6 +33,7 @@
#include <utils/fileutils.h>
#include <QDateTime>
#include <QList>
#include <QVariant>
@@ -92,6 +93,7 @@ public:
MatchLevel matchTarget(const ProjectExplorer::Abi &targetAbi) const;
QStringList abiNames() const;
QDateTime lastModified() const;
bool isGood() const;
QString validityMessage() const;
@@ -112,6 +114,7 @@ private:
QString m_autoDetectionSource;
QString m_version;
QList<ProjectExplorer::Abi> m_abis;
QDateTime m_lastModified;
friend class Internal::DebuggerConfigWidget;
friend class Internal::DebuggerItemConfigWidget;

View File

@@ -256,8 +256,12 @@ void DebuggerItemManager::autoDetectGdbOrLldbDebuggers()
}
foreach (const FileName &command, suspects) {
if (findByCommand(command))
DebuggerItem *existingItem = findByCommand(command);
if (existingItem) {
if (command.toFileInfo().lastModified() != existingItem->lastModified())
existingItem->reinitializeFromFile();
continue;
}
DebuggerItem item;
item.createId();
item.setCommand(command);
@@ -309,9 +313,9 @@ void DebuggerItemManager::readLegacyDebuggers(const FileName &file)
}
}
const DebuggerItem *DebuggerItemManager::findByCommand(const FileName &command)
DebuggerItem *DebuggerItemManager::findByCommand(const FileName &command)
{
foreach (const DebuggerItem &item, m_debuggers)
for (auto &item: m_debuggers)
if (item.command() == command)
return &item;

View File

@@ -55,7 +55,7 @@ public:
static QVariant registerDebugger(const DebuggerItem &item);
static void deregisterDebugger(const QVariant &id);
static const DebuggerItem *findByCommand(const Utils::FileName &command);
static DebuggerItem *findByCommand(const Utils::FileName &command);
static const DebuggerItem *findById(const QVariant &id);
static const DebuggerItem *findByEngineType(DebuggerEngineType engineType);